Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / games / space-cadet-pinball / default.nix
blob3957bf4fc1bc30afd629c1188335d5164e06b5e0
1 { lib, stdenv, fetchFromGitHub, fetchzip
2 , cmake, SDL2, SDL2_mixer, Cocoa
3 , unrar-wrapper, makeWrapper
4 , fetchpatch
5 }:
7 let
8   assets = (fetchzip {
9     url = "https://archive.org/download/SpaceCadet_Plus95/Space_Cadet.rar";
10     sha256 = "sha256-fC+zsR8BY6vXpUkVd6i1jF0IZZxVKVvNi6VWCKT+pA4=";
11     stripRoot = false;
12   }).overrideAttrs (old: {
13     nativeBuildInputs = old.nativeBuildInputs ++ [ unrar-wrapper ];
14   });
16 stdenv.mkDerivation rec {
17   pname = "SpaceCadetPinball";
18   version = "2.0.1";
20   src = fetchFromGitHub {
21     owner = "k4zmu2a";
22     repo = pname;
23     rev = "Release_${version}";
24     sha256 = "sha256-LmYplJr1Mg4yNg9eP02FXf9mL1FnzNBhpted3GpmlQ0=";
25   };
27   patches = [
28     # remove when updating past 2.0.1
29     (fetchpatch {
30       name = "fix-install-directories";
31       url = "https://github.com/k4zmu2a/SpaceCadetPinball/commit/d8ee1b9bfeee21d3981a40e735411393392bc1f6.patch";
32       sha256 = "sha256-BtCDJ+a9AFaOM8nyId0eU9GN/gUQT2kFCO4RIVTzZlE=";
33     })
34   ];
36   nativeBuildInputs = [ cmake makeWrapper ];
37   buildInputs = [
38     SDL2
39     SDL2_mixer
40   ] ++ lib.optional stdenv.isDarwin Cocoa;
42   # Darwin needs a custom installphase since it is excluded from the cmake install
43   # https://github.com/k4zmu2a/SpaceCadetPinball/blob/0f88e43ba261bc21fa5c3ef9d44969a2a079d0de/CMakeLists.txt#L221
44   installPhase = lib.optionalString stdenv.isDarwin ''
45     runHook preInstall
46     mkdir -p $out/bin
47     install ../bin/SpaceCadetPinball $out/bin
48     runHook postInstall
49   '';
51   postInstall = ''
52     mkdir -p $out/lib/SpaceCadetPinball
53     install ${assets}/*.{DAT,DOC,MID,BMP,INF} ${assets}/Sounds/*.WAV $out/lib/SpaceCadetPinball
55     # Assets are loaded from the directory of the program is stored in
56     # https://github.com/k4zmu2a/SpaceCadetPinball/blob/de13d4e326b2dfa8e6dfb59815c0a8b9657f942d/SpaceCadetPinball/winmain.cpp#L119
57     mv $out/bin/SpaceCadetPinball $out/lib/SpaceCadetPinball
58     makeWrapper $out/lib/SpaceCadetPinball/SpaceCadetPinball $out/bin/SpaceCadetPinball
59   '';
61   meta = with lib; {
62     description = "Reverse engineering of 3D Pinball for Windows – Space Cadet, a game bundled with Windows";
63     homepage = "https://github.com/k4zmu2a/SpaceCadetPinball";
64     # The assets are unfree while the code is labeled as MIT
65     license = with licenses; [ unfree mit ];
66     maintainers = [ maintainers.hqurve ];
67     platforms = platforms.all;
68     mainProgram = "SpaceCadetPinball";
69   };