40 , withTouchSupport ? false
46 boolToCMake = b: if b then "ON" else "OFF";
48 irrlichtmtInput = irrlichtmt.override { inherit withTouchSupport; };
50 generic = { version, rev ? version, sha256, dataRev ? version, dataSha256, buildClient ? true, buildServer ? false }: let
52 src = fetchFromGitHub {
57 data = fetchFromGitHub {
59 repo = "minetest_game";
64 in stdenv.mkDerivation {
72 "-DBUILD_CLIENT=${boolToCMake buildClient}"
73 "-DBUILD_SERVER=${boolToCMake buildServer}"
76 "-DENABLE_SYSTEM_JSONCPP=1"
78 # Remove when https://github.com/NixOS/nixpkgs/issues/144170 is fixed
79 "-DCMAKE_INSTALL_BINDIR=bin"
80 "-DCMAKE_INSTALL_DATADIR=share"
81 "-DCMAKE_INSTALL_DOCDIR=share/doc"
82 "-DCMAKE_INSTALL_DOCDIR=share/doc"
83 "-DCMAKE_INSTALL_MANDIR=share/man"
84 "-DCMAKE_INSTALL_LOCALEDIR=share/locale"
86 ] ++ optionals buildServer [
87 "-DENABLE_PROMETHEUS=1"
88 ] ++ optionals withTouchSupport [
92 env.NIX_CFLAGS_COMPILE = "-DluaL_reg=luaL_Reg"; # needed since luajit-2.1.0-beta3
94 nativeBuildInputs = [ cmake doxygen graphviz ninja ];
97 irrlichtmtInput jsoncpp gettext freetype sqlite curl bzip2 ncurses
99 ] ++ [ (if lib.meta.availableOn stdenv.hostPlatform luajit then luajit else lua5_1) ] ++ [
100 ] ++ optionals stdenv.isDarwin [
101 libiconv OpenGL OpenAL Carbon Cocoa
102 ] ++ optionals buildClient [
103 libpng libjpeg libGLU openal libogg libvorbis xorg.libX11
104 ] ++ optionals buildServer [
105 leveldb postgresql hiredis prometheus-cpp
109 substituteInPlace src/filesys.cpp --replace "/bin/rm" "${coreutils}/bin/rm"
110 '' + lib.optionalString stdenv.isDarwin ''
111 sed -i '/pagezero_size/d;/fixup_bundle/d' src/CMakeLists.txt
114 postInstall = lib.optionalString stdenv.isLinux ''
115 mkdir -pv $out/share/minetest/games/minetest_game/
116 cp -rv ${sources.data}/* $out/share/minetest/games/minetest_game/
118 '' + lib.optionalString stdenv.isDarwin ''
119 mkdir -p $out/Applications
120 mv $out/minetest.app $out/Applications
124 homepage = "http://minetest.net/";
125 description = "Infinite-world block sandbox game";
126 license = licenses.lgpl21Plus;
127 platforms = platforms.linux ++ platforms.darwin;
128 maintainers = with maintainers; [ pyrolagus fpletz fgaz ];
134 sha256 = "sha256-9AL6gTmy05yTeYfCq3EMK4gqpBWdHwvJ5Flpzj8hFAE=";
135 dataSha256 = "sha256-wWgeO8513N5jQdWvZrq357fPpAU5ik06mgZraWCQawo=";
138 mkClient = version: generic (version // { buildClient = true; buildServer = false; });
139 mkServer = version: generic (version // { buildClient = false; buildServer = true; });
141 minetestclient_5 = mkClient v5;
142 minetestserver_5 = mkServer v5;