pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / games / mudlet / default.nix
blobeef4560e386a52795096e4bb65ba035620fa998c
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , fetchpatch
5 , cmake
6 , git
7 , pkg-config
8 , qttools
9 , which
10 , wrapQtAppsHook
11 , boost
12 , hunspell
13 , libGLU
14 , libsForQt5
15 , libsecret
16 , libzip
17 , lua
18 , pcre
19 , pugixml
20 , qtbase
21 , qtmultimedia
22 , discord-rpc
23 , yajl
24 , AppKit
27 let
28   overrideLua =
29     let
30       packageOverrides = self: super: {
31         # luasql-sqlite3 master branch broke compatibility with lua 5.1. Pin to
32         # an earlier commit.
33         # https://github.com/lunarmodules/luasql/issues/147
34         luasql-sqlite3 = super.luaLib.overrideLuarocks super.luasql-sqlite3
35           (drv: {
36             version = "2.6.0-1-custom";
37             src = fetchFromGitHub {
38               owner = "lunarmodules";
39               repo = "luasql";
40               rev = "8c58fd6ee32faf750daf6e99af015a31402578d1";
41               hash = "sha256-XlTB5O81yWCrx56m0cXQp7EFzeOyfNeqGbuiYqMrTUk=";
42             };
43           });
44       };
45     in
46     lua.override { inherit packageOverrides; };
48   luaEnv = overrideLua.withPackages (ps: with ps; [
49     luazip
50     luafilesystem
51     lrexlib-pcre
52     luasql-sqlite3
53     lua-yajl
54     luautf8
55   ]);
57 stdenv.mkDerivation rec {
58   pname = "mudlet";
59   version = "4.17.2";
61   src = fetchFromGitHub {
62     owner = "Mudlet";
63     repo = "Mudlet";
64     rev = "Mudlet-${version}";
65     fetchSubmodules = true;
66     hash = "sha256-K75frptePKfHeGQNXaX4lKsLwO6Rs6AAka6hvP8MA+k=";
67   };
69   patches = [
70     (fetchpatch {
71       name = "darwin-AppKit.patch";
72       url = "https://github.com/Mudlet/Mudlet/commit/68cdd404f81a6d16c80068c45fe0f10802f08d9e.patch";
73       hash = "sha256-74FtcjOR/lu9ohtcoup0+gUfCQRznO48zMmb97INhdY=";
74     })
75   ];
77   nativeBuildInputs = [
78     cmake
79     git
80     pkg-config
81     qttools
82     which
83     wrapQtAppsHook
84   ];
86   buildInputs = [
87     boost
88     hunspell
89     libGLU
90     libsForQt5.qtkeychain
91     libsecret
92     libzip
93     luaEnv
94     pcre
95     pugixml
96     qtbase
97     qtmultimedia
98     yajl
99     discord-rpc
100   ] ++ lib.optional stdenv.hostPlatform.isDarwin [
101     AppKit
102   ];
104   cmakeFlags = [
105     # RPATH of binary /nix/store/.../bin/... contains a forbidden reference to /build/
106     "-DCMAKE_SKIP_BUILD_RPATH=ON"
107   ];
109   WITH_FONTS = "NO";
110   WITH_UPDATER = "NO";
112   installPhase = ''
113     runHook preInstall
115     mkdir -pv $out/lib
116     cp 3rdparty/edbee-lib/edbee-lib/qslog/lib/libQsLog${stdenv.hostPlatform.extensions.sharedLibrary} $out/lib
117     mkdir -pv $out/share/mudlet
118     cp -r ../src/mudlet-lua/lua $out/share/mudlet/
120     mkdir -pv $out/share/pixmaps
121     cp -r ../mudlet.png $out/share/pixmaps/
123     cp -r ../translations $out/share/
125   '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
126     mkdir -p $out/Applications
127     cp -r src/mudlet.app/ $out/Applications/mudlet.app
128     mv $out/Applications/mudlet.app/Contents/MacOS/mudlet $out/Applications/mudlet.app/Contents/MacOS/mudlet-unwrapped
129     makeQtWrapper $out/Applications/Mudlet.app/Contents/MacOS/mudlet-unwrapped $out/Applications/Mudlet.app/Contents/MacOS/mudlet \
130       --set LUA_CPATH "${luaEnv}/lib/lua/${lua.luaversion}/?.so" \
131       --prefix LUA_PATH : "$NIX_LUA_PATH" \
132       --prefix DYLD_LIBRARY_PATH : "${lib.makeLibraryPath [ libsForQt5.qtkeychain discord-rpc ]}:$out/lib" \
133       --chdir "$out";
135   '' + lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
136     mkdir -pv $out/bin
137     cp src/mudlet $out/bin/mudlet-unwrapped
138     makeQtWrapper $out/bin/mudlet-unwrapped $out/bin/mudlet \
139       --set LUA_CPATH "${luaEnv}/lib/lua/${lua.luaversion}/?.so" \
140       --prefix LUA_PATH : "$NIX_LUA_PATH" \
141       --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libsForQt5.qtkeychain discord-rpc ]}" \
142       --chdir "$out";
144     mkdir -pv $out/share/applications
145     cp ../mudlet.desktop $out/share/applications/
147   '' + ''
148     runHook postInstall
149   '';
151   meta = with lib; {
152     description = "Crossplatform mud client";
153     homepage = "https://www.mudlet.org/";
154     maintainers = with maintainers; [ wyvie pstn cpu felixalbrigtsen ];
155     platforms = platforms.linux ++ platforms.darwin;
156     license = licenses.gpl2Plus;
157     mainProgram = "mudlet";
158   };