2021-12-08 02:34:17 +01:00
|
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchzip
|
2022-03-31 02:46:19 +02:00
|
|
|
|
, cmake, SDL2, SDL2_mixer, Cocoa
|
2021-12-08 02:34:17 +01:00
|
|
|
|
, unrar-wrapper, makeWrapper
|
2022-01-01 00:59:33 +01:00
|
|
|
|
, fetchpatch
|
2021-12-08 02:34:17 +01:00
|
|
|
|
}:
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
assets = (fetchzip {
|
|
|
|
|
url = "https://archive.org/download/SpaceCadet_Plus95/Space_Cadet.rar";
|
|
|
|
|
sha256 = "sha256-fC+zsR8BY6vXpUkVd6i1jF0IZZxVKVvNi6VWCKT+pA4=";
|
|
|
|
|
stripRoot = false;
|
|
|
|
|
}).overrideAttrs (old: {
|
|
|
|
|
nativeBuildInputs = old.nativeBuildInputs ++ [ unrar-wrapper ];
|
|
|
|
|
});
|
|
|
|
|
in
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
|
pname = "SpaceCadetPinball";
|
2022-01-01 00:59:33 +01:00
|
|
|
|
version = "2.0.1";
|
2021-12-08 02:34:17 +01:00
|
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
|
owner = "k4zmu2a";
|
|
|
|
|
repo = pname;
|
2022-01-01 00:59:33 +01:00
|
|
|
|
rev = "Release_${version}";
|
|
|
|
|
sha256 = "sha256-LmYplJr1Mg4yNg9eP02FXf9mL1FnzNBhpted3GpmlQ0=";
|
2021-12-08 02:34:17 +01:00
|
|
|
|
};
|
|
|
|
|
|
2022-01-01 00:59:33 +01:00
|
|
|
|
patches = [
|
|
|
|
|
# remove when updating past 2.0.1
|
|
|
|
|
(fetchpatch {
|
|
|
|
|
name = "fix-install-directories";
|
|
|
|
|
url = "https://github.com/k4zmu2a/SpaceCadetPinball/commit/d8ee1b9bfeee21d3981a40e735411393392bc1f6.patch";
|
|
|
|
|
sha256 = "sha256-BtCDJ+a9AFaOM8nyId0eU9GN/gUQT2kFCO4RIVTzZlE=";
|
|
|
|
|
})
|
|
|
|
|
];
|
|
|
|
|
|
2022-03-30 23:35:38 +02:00
|
|
|
|
nativeBuildInputs = [ cmake ];
|
2021-12-08 02:34:17 +01:00
|
|
|
|
buildInputs = [
|
|
|
|
|
SDL2
|
|
|
|
|
SDL2_mixer
|
|
|
|
|
makeWrapper
|
2022-04-01 13:40:09 +02:00
|
|
|
|
] ++ lib.optional stdenv.isDarwin Cocoa;
|
2021-12-08 02:34:17 +01:00
|
|
|
|
|
2022-04-01 13:40:09 +02:00
|
|
|
|
# Darwin needs a custom installphase since it is excluded from the cmake install
|
|
|
|
|
# https://github.com/k4zmu2a/SpaceCadetPinball/blob/0f88e43ba261bc21fa5c3ef9d44969a2a079d0de/CMakeLists.txt#L221
|
|
|
|
|
installPhase = lib.optionalString stdenv.isDarwin ''
|
|
|
|
|
runHook preInstall
|
2022-03-31 02:46:19 +02:00
|
|
|
|
mkdir -p $out/bin
|
2022-04-01 13:40:09 +02:00
|
|
|
|
install ../bin/SpaceCadetPinball $out/bin
|
|
|
|
|
runHook postInstall
|
2022-03-31 02:46:19 +02:00
|
|
|
|
'';
|
|
|
|
|
|
2022-04-01 13:13:52 +02:00
|
|
|
|
postInstall = ''
|
2021-12-08 02:34:17 +01:00
|
|
|
|
mkdir -p $out/lib/SpaceCadetPinball
|
|
|
|
|
install ${assets}/*.{DAT,DOC,MID,BMP,INF} ${assets}/Sounds/*.WAV $out/lib/SpaceCadetPinball
|
|
|
|
|
|
|
|
|
|
# Assets are loaded from the directory of the program is stored in
|
|
|
|
|
# https://github.com/k4zmu2a/SpaceCadetPinball/blob/de13d4e326b2dfa8e6dfb59815c0a8b9657f942d/SpaceCadetPinball/winmain.cpp#L119
|
2022-04-01 13:13:52 +02:00
|
|
|
|
mv $out/bin/SpaceCadetPinball $out/lib/SpaceCadetPinball
|
2021-12-08 02:34:17 +01:00
|
|
|
|
makeWrapper $out/lib/SpaceCadetPinball/SpaceCadetPinball $out/bin/SpaceCadetPinball
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
|
description = "Reverse engineering of 3D Pinball for Windows – Space Cadet, a game bundled with Windows";
|
|
|
|
|
homepage = "https://github.com/k4zmu2a/SpaceCadetPinball";
|
|
|
|
|
# The assets are unfree while the code is labeled as MIT
|
|
|
|
|
license = with licenses; [ unfree mit ];
|
|
|
|
|
maintainers = [ maintainers.hqurve ];
|
|
|
|
|
platforms = platforms.all;
|
2022-03-31 02:46:19 +02:00
|
|
|
|
mainProgram = "SpaceCadetPinball";
|
2021-12-08 02:34:17 +01:00
|
|
|
|
};
|
|
|
|
|
}
|