forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / games / minetest / default.nix
blobde566217b1baa338b5a1d9adfff86787d64b05c9
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , gitUpdater
5 , cmake
6 , coreutils
7 , libpng
8 , bzip2
9 , curl
10 , libogg
11 , jsoncpp
12 , libjpeg
13 , libGLU
14 , openal
15 , libvorbis
16 , sqlite
17 , luajit
18 , freetype
19 , gettext
20 , doxygen
21 , ncurses
22 , graphviz
23 , xorg
24 , gmp
25 , libspatialindex
26 , leveldb
27 , postgresql
28 , hiredis
29 , libiconv
30 , ninja
31 , prometheus-cpp
32 , OpenGL
33 , OpenAL ? openal
34 , Carbon
35 , Cocoa
36 , Kernel
37 , buildClient ? true
38 , buildServer ? true
39 , SDL2
40 , useSDL2 ? false
43 stdenv.mkDerivation (finalAttrs: {
44   pname = "minetest";
45   version = "5.9.1";
47   src = fetchFromGitHub {
48     owner = "minetest";
49     repo = "minetest";
50     rev = finalAttrs.version;
51     hash = "sha256-0WTDhFt7GDzN4AK8U17iLkjeSMK+gOWZRq46HBTeO3w=";
52   };
54   cmakeFlags = [
55     (lib.cmakeBool "BUILD_CLIENT" buildClient)
56     (lib.cmakeBool "BUILD_SERVER" buildServer)
57     (lib.cmakeBool "BUILD_UNITTESTS" (finalAttrs.doCheck or false))
58     (lib.cmakeBool "ENABLE_PROMETHEUS" buildServer)
59     (lib.cmakeBool "USE_SDL2" useSDL2)
60     # Ensure we use system libraries
61     (lib.cmakeBool "ENABLE_SYSTEM_GMP" true)
62     (lib.cmakeBool "ENABLE_SYSTEM_JSONCPP" true)
63     # Updates are handled by nix anyway
64     (lib.cmakeBool "ENABLE_UPDATE_CHECKER" false)
65     # ...but make it clear that this is a nix package
66     (lib.cmakeFeature "VERSION_EXTRA" "NixOS")
68     # Remove when https://github.com/NixOS/nixpkgs/issues/144170 is fixed
69     (lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin")
70     (lib.cmakeFeature "CMAKE_INSTALL_DATADIR" "share")
71     (lib.cmakeFeature "CMAKE_INSTALL_DOCDIR" "share/doc/minetest")
72     (lib.cmakeFeature "CMAKE_INSTALL_MANDIR" "share/man")
73     (lib.cmakeFeature "CMAKE_INSTALL_LOCALEDIR" "share/locale")
75   ];
77   nativeBuildInputs = [
78     cmake
79     doxygen
80     graphviz
81     ninja
82   ];
84   buildInputs = [
85     jsoncpp
86     gettext
87     freetype
88     sqlite
89     curl
90     bzip2
91     ncurses
92     gmp
93     libspatialindex
94   ] ++ lib.optional (lib.meta.availableOn stdenv.hostPlatform luajit) luajit
95   ++ lib.optionals stdenv.hostPlatform.isDarwin [
96     libiconv
97     OpenGL
98     OpenAL
99     Carbon
100     Cocoa
101     Kernel
102   ] ++ lib.optionals buildClient [
103     libpng
104     libjpeg
105     libGLU
106     openal
107     libogg
108     libvorbis
109   ] ++ lib.optionals (buildClient && useSDL2) [
110     SDL2
111   ] ++ lib.optionals (buildClient && !stdenv.hostPlatform.isDarwin && !useSDL2) [
112     xorg.libX11
113     xorg.libXi
114   ] ++ lib.optionals buildServer [
115     leveldb
116     postgresql
117     hiredis
118     prometheus-cpp
119   ];
121   postPatch = ''
122     substituteInPlace src/filesys.cpp \
123       --replace-fail "/bin/rm" "${coreutils}/bin/rm"
124   '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
125     sed -i '/pagezero_size/d;/fixup_bundle/d' src/CMakeLists.txt
126   '';
128   postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
129     patchShebangs $out
130   '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
131     mkdir -p $out/Applications
132     mv $out/minetest.app $out/Applications
133   '';
135   doCheck = true;
137   passthru.updateScript = gitUpdater {
138     allowedVersions = "\\.";
139     ignoredVersions = "-android$";
140   };
142   meta = with lib; {
143     homepage = "https://minetest.net/";
144     description = "Infinite-world block sandbox game";
145     license = licenses.lgpl21Plus;
146     platforms = platforms.linux ++ platforms.darwin;
147     maintainers = with maintainers; [ pyrolagus fpletz fgaz ];
148     mainProgram = if buildClient then "minetest" else "minetestserver";
149   };