Skip to content

Commit e41b7ce

Browse files
dwtafh
andcommitted
ut1999: fix Darwin build
- Update the build script pull the sources for [x86,aarch64]-darwin - Extract duplication from linux build script With grammar and spelling fixes: Co-authored-by: Alexis Hildebrandt <[email protected]>
1 parent 03a8c8b commit e41b7ce

File tree

1 file changed

+37
-28
lines changed

1 file changed

+37
-28
lines changed

pkgs/by-name/ut/ut1999/package.nix

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
let
2323
version = "469d";
24-
srcs = {
24+
srcs = rec {
2525
x86_64-linux = fetchurl {
2626
url = "https://github.com/OldUnreal/UnrealTournamentPatches/releases/download/v${version}/OldUnreal-UTPatch${version}-Linux-amd64.tar.bz2";
2727
hash = "sha256-aoGzWuakwN/OL4+xUq8WEpd2c1rrNN/DkffI2vDVGjs=";
@@ -38,6 +38,8 @@ let
3838
url = "https://github.com/OldUnreal/UnrealTournamentPatches/releases/download/v${version}/OldUnreal-UTPatch${version}-macOS-Sonoma.dmg";
3939
hash = "sha256-TbhJbOH4E5WOb6XR9dmqLkXziK3/CzhNjd1ypBkkmvw=";
4040
};
41+
# fat binary
42+
aarch64-darwin = x86_64-darwin;
4143
};
4244
unpackIso =
4345
runCommand "ut1999-iso"
@@ -56,11 +58,12 @@ let
5658
cp -r Music Sounds Textures Maps $out
5759
'';
5860
systemDir =
59-
{
61+
rec {
6062
x86_64-linux = "System64";
6163
aarch64-linux = "SystemARM64";
62-
x86_64-darwin = "System";
6364
i686-linux = "System";
65+
x86_64-darwin = "System";
66+
aarch64-darwin = x86_64-darwin;
6467
}
6568
.${stdenv.hostPlatform.system} or (throw "unsupported system: ${stdenv.hostPlatform.system}");
6669
in
@@ -98,43 +101,49 @@ stdenv.mkDerivation {
98101
in
99102
''
100103
runHook preInstall
101-
104+
mkdir -p $out
105+
''
106+
+ lib.optionalString (stdenv.hostPlatform.isLinux) ''
102107
mkdir -p $out/bin
108+
''
109+
+ ''
103110
cp -r ${if stdenv.hostPlatform.isDarwin then "UnrealTournament.app" else "./*"} $out
104111
chmod -R 755 $out
105112
cd ${outPrefix}
106-
107-
# NOTE: OldUnreal patch doesn't include these folders but could in the future
108-
rm -rf ./{Music,Sounds,Maps}
109-
ln -s ${unpackIso}/{Music,Sounds,Maps} .
110-
111-
# TODO: unpack compressed maps with ucc
112-
113+
# NOTE: OldUnreal patch doesn't include these folders on linux but could in the future
114+
# on darwin it does, but they are empty
115+
rm -rf ./{Music,Sounds}
116+
ln -s ${unpackIso}/{Music,Sounds} .
117+
''
118+
+ lib.optionalString (stdenv.hostPlatform.isLinux) ''
119+
# maps need no post-processing on linux, therefore linking them is ok
120+
rm -rf ./Maps
121+
ln -s ${unpackIso}/Maps .
122+
''
123+
+ lib.optionalString (stdenv.hostPlatform.isDarwin) ''
124+
# Maps need post-processing on darwin, therefore need to be copied
125+
cp -n ${unpackIso}/Maps/* ./Maps || true
126+
# unpack compressed maps with ucc (needs absolute paths)
127+
for map in $PWD/Maps/*.uz; do ./UCC decompress $map; done
128+
mv ${systemDir}/*.unr ./Maps || true
129+
rm ./Maps/*.uz
130+
''
131+
+ ''
113132
cp -n ${unpackIso}/Textures/* ./Textures || true
114-
cp -n ${unpackIso}/System/*.{u,int} ./System || true
115133
''
116134
+ lib.optionalString (stdenv.hostPlatform.isLinux) ''
135+
cp -n ${unpackIso}/System/*.{u,int} ./System || true
117136
ln -s "$out/${systemDir}/ut-bin" "$out/bin/ut1999"
118137
ln -s "$out/${systemDir}/ucc-bin" "$out/bin/ut1999-ucc"
119138
120139
install -D "${./ut1999.svg}" "$out/share/pixmaps/ut1999.svg"
121-
${imagemagick}/bin/magick -background none ${./ut1999.svg} -resize 16x16 ut1999_16x16.png
122-
${imagemagick}/bin/magick -background none ${./ut1999.svg} -resize 24x24 ut1999_24x24.png
123-
${imagemagick}/bin/magick -background none ${./ut1999.svg} -resize 32x32 ut1999_32x32.png
124-
${imagemagick}/bin/magick -background none ${./ut1999.svg} -resize 48x48 ut1999_48x48.png
125-
${imagemagick}/bin/magick -background none ${./ut1999.svg} -resize 64x64 ut1999_64x64.png
126-
${imagemagick}/bin/magick -background none ${./ut1999.svg} -resize 128x128 ut1999_128x128.png
127-
${imagemagick}/bin/magick -background none ${./ut1999.svg} -resize 192x192 ut1999_192x192.png
128-
${imagemagick}/bin/magick -background none ${./ut1999.svg} -resize 256x256 ut1999_256x256.png
129-
install -D "ut1999_16x16.png" "$out/share/icons/hicolor/16x16/apps/ut1999.png"
130-
install -D "ut1999_24x24.png" "$out/share/icons/hicolor/24x24/apps/ut1999.png"
131-
install -D "ut1999_32x32.png" "$out/share/icons/hicolor/32x32/apps/ut1999.png"
132-
install -D "ut1999_48x48.png" "$out/share/icons/hicolor/48x48/apps/ut1999.png"
133-
install -D "ut1999_64x64.png" "$out/share/icons/hicolor/64x64/apps/ut1999.png"
134-
install -D "ut1999_128x128.png" "$out/share/icons/hicolor/128x128/apps/ut1999.png"
135-
install -D "ut1999_192x192.png" "$out/share/icons/hicolor/192x192/apps/ut1999.png"
136-
install -D "ut1999_256x256.png" "$out/share/icons/hicolor/256x256/apps/ut1999.png"
140+
for size in 16 24 32 48 64 128 192 256; do
141+
square=$(printf "%sx%s" $size $size)
142+
${imagemagick}/bin/magick -background none ${./ut1999.svg} -resize $square ut1999_$square.png
143+
install -D "ut1999_$square.png" "$out/share/icons/hicolor/$square/apps/ut1999.png"
144+
done
137145
146+
# TODO consider to remove shared libraries that can be provided by nixpkgs for darwin too
138147
# Remove bundled libraries to use native versions instead
139148
rm $out/${systemDir}/libmpg123.so* \
140149
$out/${systemDir}/libopenal.so* \

0 commit comments

Comments
 (0)