ultrastardx: on darwin (#521960)

This commit is contained in:
Weijia Wang
2026-08-18 07:09:24 +00:00
committed by GitHub

View File

@@ -36,12 +36,13 @@ let
sqlite
lua
zlib
ffmpeg
]
++ lib.optionals stdenv.hostPlatform.isLinux [
libx11
libGLU
libGL
ffmpeg
];
in
stdenv.mkDerivation (finalAttrs: {
pname = "ultrastardx";
@@ -58,19 +59,44 @@ stdenv.mkDerivation (finalAttrs: {
pkg-config
autoreconfHook
];
buildInputs = [
fpc
libpng
]
++ sharedLibs;
preBuild =
let
items = lib.concatMapStringsSep " " (x: "-rpath ${lib.getLib x}/lib") sharedLibs;
in
''
export NIX_LDFLAGS="$NIX_LDFLAGS ${items}"
'';
env = {
NIX_LDFLAGS = lib.concatMapStringsSep " " (x: "-rpath ${lib.getLib x}/lib") sharedLibs;
}
// lib.optionalAttrs stdenv.hostPlatform.isDarwin {
MACOSX_DEPLOYMENT_TARGET = "10.13";
};
# fpc's fpc.cfg hardcodes -FD/Applications/Xcode.app/.../usr/bin to find `as`/`ld`,
# which is unreachable in the build sandbox and has no sysroot.
preBuild = lib.optionalString stdenv.hostPlatform.isDarwin ''
export PFLAGS_EXTRA="-FD${lib.getBin stdenv.cc.bintools}/bin -XR$SDKROOT $PFLAGS_EXTRA"
'';
installPhase = ''
runHook preInstall
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
make macos-app
mkdir -p "$out/Applications" "$out/bin"
cp -R UltraStarDeluxe.app "$out/Applications/"
ln -s "$out/Applications/UltraStarDeluxe.app/Contents/MacOS/ultrastardx" \
"$out/bin/ultrastardx"
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
make install
install -Dm644 dists/ultrastardx.desktop \
"$out/share/applications/ultrastardx.desktop"
''
+ ''
runHook postInstall
'';
# dlopened libgcc requires the rpath not to be shrunk
dontPatchELF = true;
@@ -82,7 +108,8 @@ stdenv.mkDerivation (finalAttrs: {
license = lib.licenses.gpl2Plus;
maintainers = with lib.maintainers; [
diogotcorreia
philocalyst
];
platforms = lib.platforms.linux;
platforms = with lib.platforms; linux ++ darwin ++ windows;
};
})