pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / games / space-cadet-pinball / default.nix
blob0f3009e4abe51d965c16309cc335277f5250dc09
1 { lib, stdenv, fetchFromGitHub, fetchzip
2 , cmake, SDL2, SDL2_mixer, Cocoa
3 , unrar-wrapper, makeWrapper
4 }:
6 let
7   assets = (fetchzip {
8     url = "https://archive.org/download/SpaceCadet_Plus95/Space_Cadet.rar";
9     sha256 = "sha256-fC+zsR8BY6vXpUkVd6i1jF0IZZxVKVvNi6VWCKT+pA4=";
10     stripRoot = false;
11   }).overrideAttrs (old: {
12     nativeBuildInputs = old.nativeBuildInputs ++ [ unrar-wrapper ];
13   });
15 stdenv.mkDerivation rec {
16   pname = "SpaceCadetPinball";
17   version = "2.1.0";
19   src = fetchFromGitHub {
20     owner = "k4zmu2a";
21     repo = pname;
22     rev = "Release_${version}";
23     hash = "sha256-W2P7Txv3RtmKhQ5c0+b4ghf+OMsN+ydUZt+6tB+LClM=";
24   };
26   nativeBuildInputs = [ cmake makeWrapper ];
27   buildInputs = [
28     SDL2
29     SDL2_mixer
30   ] ++ lib.optional stdenv.hostPlatform.isDarwin Cocoa;
32   # Darwin needs a custom installphase since it is excluded from the cmake install
33   # https://github.com/k4zmu2a/SpaceCadetPinball/blob/0f88e43ba261bc21fa5c3ef9d44969a2a079d0de/CMakeLists.txt#L221
34   installPhase = lib.optionalString stdenv.hostPlatform.isDarwin ''
35     runHook preInstall
36     mkdir -p $out/bin
37     install ../bin/SpaceCadetPinball $out/bin
38     runHook postInstall
39   '';
41   postInstall = ''
42     mkdir -p $out/lib/SpaceCadetPinball
43     install ${assets}/*.{DAT,DOC,MID,BMP,INF} ${assets}/Sounds/*.WAV $out/lib/SpaceCadetPinball
45     # Assets are loaded from the directory of the program is stored in
46     # https://github.com/k4zmu2a/SpaceCadetPinball/blob/de13d4e326b2dfa8e6dfb59815c0a8b9657f942d/SpaceCadetPinball/winmain.cpp#L119
47     mv $out/bin/SpaceCadetPinball $out/lib/SpaceCadetPinball
48     makeWrapper $out/lib/SpaceCadetPinball/SpaceCadetPinball $out/bin/SpaceCadetPinball
49   '';
51   meta = with lib; {
52     description = "Reverse engineering of 3D Pinball for Windows – Space Cadet, a game bundled with Windows";
53     homepage = "https://github.com/k4zmu2a/SpaceCadetPinball";
54     # The assets are unfree while the code is labeled as MIT
55     license = with licenses; [ unfree mit ];
56     maintainers = [ maintainers.hqurve ];
57     platforms = platforms.all;
58     mainProgram = "SpaceCadetPinball";
59   };