trezor-suite: 24.4.3 -> 24.5.2
[NixPkgs.git] / pkgs / games / openrct2 / default.nix
blob4a8a1c255e894b3f2ff6ea5bed879cef8a0802db
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , fetchpatch
6 , SDL2
7 , cmake
8 , curl
9 , discord-rpc
10 , duktape
11 , expat
12 , flac
13 , fontconfig
14 , freetype
15 , gbenchmark
16 , icu
17 , jansson
18 , libGLU
19 , libiconv
20 , libogg
21 , libpng
22 , libpthreadstubs
23 , libvorbis
24 , libzip
25 , nlohmann_json
26 , openssl
27 , pkg-config
28 , speexdsp
29 , zlib
32 let
33   openrct2-version = "0.4.11";
35   # Those versions MUST match the pinned versions within the CMakeLists.txt
36   # file. The REPLAYS repository from the CMakeLists.txt is not necessary.
37   objects-version = "1.4.4";
38   openmsx-version = "1.5";
39   opensfx-version = "1.0.5";
40   title-sequences-version = "0.4.6";
42   openrct2-src = fetchFromGitHub {
43     owner = "OpenRCT2";
44     repo = "OpenRCT2";
45     rev = "v${openrct2-version}";
46     hash = "sha256-zaaVieU/hulc2G/F19diJug3xuj3ejn5ihnmKfkBDcQ=";
47   };
49   objects-src = fetchFromGitHub {
50     owner = "OpenRCT2";
51     repo = "objects";
52     rev = "v${objects-version}";
53     hash = "sha256-wKxWp/DSKkxCEI0lp4X8F9LxQsUKZfLk2CgajQ+y84k=";
54   };
56   openmsx-src = fetchFromGitHub {
57     owner = "OpenRCT2";
58     repo = "OpenMusic";
59     rev = "v${openmsx-version}";
60     hash = "sha256-p/wlvQFfu3R+jIuCcRbTMvxt0VKGGwJw0NDIsf6URWI=";
61   };
63   opensfx-src = fetchFromGitHub {
64     owner = "OpenRCT2";
65     repo = "OpenSoundEffects";
66     rev = "v${opensfx-version}";
67     hash = "sha256-ucADnMLGm36eAo+NiioxEzeMqtu7YbGF9wsydK1mmoE=";
68   };
70   title-sequences-src = fetchFromGitHub {
71     owner = "OpenRCT2";
72     repo = "title-sequences";
73     rev = "v${title-sequences-version}";
74     hash = "sha256-HWp2ecClNM/7O3oaydVipOnEsYNP/bZnZFS+SDidPi0=";
75   };
77 stdenv.mkDerivation {
78   pname = "openrct2";
79   version = openrct2-version;
81   src = openrct2-src;
83   patches = [
84     # https://github.com/OpenRCT2/OpenRCT2/pull/21043
85     #
86     # Basically <https://github.com/OpenRCT2/OpenRCT2/pull/19785> has broken
87     # OpenRCT2 - at least with older maps, as were used for testing - as stated
88     # in <https://github.com/NixOS/nixpkgs/issues/263025>.
89     (fetchpatch {
90       name = "remove-openrct2-music.patch";
91       url = "https://github.com/OpenRCT2/OpenRCT2/commit/9ea13848be0b974336c34e6eb119c49ba42a907c.patch";
92       hash = "sha256-2PPRqUZf4+ys89mdzp5nvdtdv00V9Vzj3v/95rmlf1c=";
93     })
94   ];
96   nativeBuildInputs = [
97     cmake
98     pkg-config
99   ];
101   buildInputs = [
102     SDL2
103     curl
104     discord-rpc
105     duktape
106     expat
107     flac
108     fontconfig
109     freetype
110     gbenchmark
111     icu
112     jansson
113     libGLU
114     libiconv
115     libogg
116     libpng
117     libpthreadstubs
118     libvorbis
119     libzip
120     nlohmann_json
121     openssl
122     speexdsp
123     zlib
124   ];
126   cmakeFlags = [
127     "-DDOWNLOAD_OBJECTS=OFF"
128     "-DDOWNLOAD_OPENMSX=OFF"
129     "-DDOWNLOAD_OPENSFX=OFF"
130     "-DDOWNLOAD_TITLE_SEQUENCES=OFF"
131   ];
133   env.NIX_CFLAGS_COMPILE = toString [
134     # Needed with GCC 12
135     "-Wno-error=maybe-uninitialized"
136   ];
138   postUnpack = ''
139     mkdir -p $sourceRoot/data/assetpack
141     cp -r ${objects-src}         $sourceRoot/data/object
142     cp -r ${openmsx-src}         $sourceRoot/data/assetpack/openrct2.music.alternative.parkap
143     cp -r ${opensfx-src}         $sourceRoot/data/assetpack/openrct2.sound.parkap
144     cp -r ${title-sequences-src} $sourceRoot/data/sequence
145   '';
147   preConfigure =
148     # Verify that the correct version of each third party repository is used.
149     (let
150       versionCheck = cmakeKey: version: ''
151         grep -q '^set(${cmakeKey}_VERSION "${version}")$' CMakeLists.txt \
152           || (echo "${cmakeKey} differs from expected version!"; exit 1)
153       '';
154     in
155     (versionCheck "OBJECTS" objects-version) +
156     (versionCheck "OPENMSX" openmsx-version) +
157     (versionCheck "OPENSFX" opensfx-version) +
158     (versionCheck "TITLE_SEQUENCE" title-sequences-version));
160   preFixup = "ln -s $out/share/openrct2 $out/bin/data";
162   meta = with lib; {
163     description = "Open source re-implementation of RollerCoaster Tycoon 2 (original game required)";
164     homepage = "https://openrct2.io/";
165     downloadPage = "https://github.com/OpenRCT2/OpenRCT2/releases";
166     license = licenses.gpl3Only;
167     platforms = platforms.linux;
168     maintainers = with maintainers; [ oxzi ];
169   };