Skip to content

Commit 8a312b1

Browse files
authored
space-cadet-pinball: Improve packaging (#354555)
2 parents 60b321b + 5ebcfc7 commit 8a312b1

File tree

4 files changed

+93
-64
lines changed

4 files changed

+93
-64
lines changed

maintainers/maintainer-list.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15206,6 +15206,13 @@
1520615206
githubId = 1234956;
1520715207
"keys" = [ { "fingerprint" = "F21A 6194 C9DB 9899 CD09 E24E 434B 2C14 B8C3 3422"; } ];
1520815208
};
15209+
nadiaholmquist = {
15210+
name = "Nadia Holmquist Pedersen";
15211+
email = "[email protected]";
15212+
matrix = "@nhp:matrix.org";
15213+
github = "nadiaholmquist";
15214+
githubId = 893884;
15215+
};
1520915216
nadir-ishiguro = {
1521015217
github = "nadir-ishiguro";
1521115218
githubId = 23151917;
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
lib,
3+
stdenv,
4+
fetchFromGitHub,
5+
fetchzip,
6+
cmake,
7+
SDL2,
8+
SDL2_mixer,
9+
unrar,
10+
}:
11+
12+
let
13+
assets = fetchzip {
14+
url = "https://archive.org/download/SpaceCadet_Plus95/Space_Cadet.rar";
15+
hash = "sha256-fC+zsR8BY6vXpUkVd6i1jF0IZZxVKVvNi6VWCKT+pA4=";
16+
stripRoot = false;
17+
nativeBuildInputs = [ unrar ];
18+
};
19+
darwinApp = "$out/Applications/SpaceCadetPinball.app/Contents";
20+
assetsDest =
21+
if stdenv.hostPlatform.isDarwin then darwinApp + "/Resources" else "$out/share/SpaceCadetPinball";
22+
in
23+
stdenv.mkDerivation rec {
24+
pname = "SpaceCadetPinball";
25+
version = "2.1.0";
26+
27+
src = fetchFromGitHub {
28+
owner = "k4zmu2a";
29+
repo = "SpaceCadetPinball";
30+
rev = "Release_${version}";
31+
hash = "sha256-W2P7Txv3RtmKhQ5c0+b4ghf+OMsN+ydUZt+6tB+LClM=";
32+
};
33+
34+
nativeBuildInputs = [ cmake ];
35+
buildInputs = [
36+
SDL2
37+
SDL2_mixer
38+
];
39+
40+
postPatch = ''
41+
# Change the hardcoded FHS assets path
42+
substituteInPlace SpaceCadetPinball/pch.h \
43+
--replace-fail /usr/share ${placeholder "out"}/share
44+
# Disable building a universal binary on Darwin, otherwise the cc wrapper passing -arch breaks the build
45+
substituteInPlace CMakeLists.txt \
46+
--replace-fail "arm64;x86_64" ""
47+
'';
48+
49+
# Darwin needs a custom installPhase since it is excluded from the cmake install
50+
# https://github.com/k4zmu2a/SpaceCadetPinball/blob/0f88e43ba261bc21fa5c3ef9d44969a2a079d0de/CMakeLists.txt#L221
51+
# This builds a bundle similar to what upstream's build script produces
52+
# https://github.com/k4zmu2a/SpaceCadetPinball/blob/cb9b7b886244a27773f66b0b19fdc2998392565e/build-mac-app.sh
53+
installPhase = lib.optionalString stdenv.hostPlatform.isDarwin ''
54+
runHook preInstall
55+
install -D ../bin/SpaceCadetPinball -t ${darwinApp}/MacOS
56+
install -Dm644 ../Platform/macOS/SpaceCadetPinball.icns -t ${darwinApp}/Resources
57+
substitute ../Platform/macOS/Info.plist ${darwinApp}/Info.plist \
58+
--replace-fail CHANGEME_SW_VERSION ${version}
59+
echo -n "APPL????" > ${darwinApp}/PkgInfo
60+
runHook postInstall
61+
'';
62+
63+
# The game uses SDL_GetBasePath to find the assets directory.
64+
# On Darwin, this will return Resources/ inside the bundle,
65+
# on other platforms, the fallback path the game checks is used instead.
66+
postInstall = ''
67+
install -Dm644 ${assets}/*.{DAT,DOC,MID,BMP,INF} \
68+
${assets}/Sounds/*.WAV -t ${assetsDest}
69+
'';
70+
71+
meta = {
72+
description = "Reverse engineering of 3D Pinball for Windows – Space Cadet, a game bundled with Windows";
73+
homepage = "https://github.com/k4zmu2a/SpaceCadetPinball";
74+
# The assets are unfree while the code is labeled as MIT
75+
license = with lib.licenses; [
76+
unfree
77+
mit
78+
];
79+
maintainers = with lib.maintainers; [
80+
hqurve
81+
nadiaholmquist
82+
];
83+
platforms = lib.platforms.all;
84+
mainProgram = "SpaceCadetPinball";
85+
};
86+
}

pkgs/games/space-cadet-pinball/default.nix

Lines changed: 0 additions & 60 deletions
This file was deleted.

pkgs/top-level/all-packages.nix

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17336,10 +17336,6 @@ with pkgs;
1733617336
buildShareware = true;
1733717337
};
1733817338

17339-
space-cadet-pinball = callPackage ../games/space-cadet-pinball {
17340-
inherit (darwin.apple_sdk.frameworks) Cocoa;
17341-
};
17342-
1734317339
starsector = callPackage ../games/starsector {
1734417340
openjdk = openjdk8;
1734517341
};

0 commit comments

Comments
 (0)