pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / games / megaglest / default.nix
blob3e720aaf9fa409dcb8fa337863a4c7e3fc97b415
1 { lib, stdenv, cmake, pkg-config, git, curl, SDL2, xercesc, openal, lua, libvlc
2 , libjpeg, wxGTK32, cppunit, ftgl, glew, libogg, libvorbis, buildEnv, libpng
3 , fontconfig, freetype, xorg, makeWrapper, bash, which, zenity, libGLU, glib
4 , fetchFromGitHub, fetchpatch
5 }:
6 let
7   version = "3.13.0";
8   lib-env = buildEnv {
9     name = "megaglest-lib-env";
10     paths = [ SDL2 xorg.libSM xorg.libICE xorg.libX11 xorg.libXext
11       xercesc openal libvorbis lua libjpeg libpng curl fontconfig ftgl freetype
12       stdenv.cc.cc glew libGLU wxGTK32 ];
13   };
14   path-env = buildEnv {
15     name = "megaglest-path-env";
16     paths = [ bash which zenity ];
17   };
19 stdenv.mkDerivation {
20   pname = "megaglest";
21   inherit version;
23   src = fetchFromGitHub {
24     owner = "MegaGlest";
25     repo = "megaglest-source";
26     rev = version;
27     fetchSubmodules = true;
28     sha256 = "0fb58a706nic14ss89zrigphvdiwy5s9dwvhscvvgrfvjpahpcws";
29   };
31   patches = [
32     # Pull upstream fix for -fno-common toolchains
33     (fetchpatch {
34       name = "fno-common.patch";
35       url = "https://github.com/MegaGlest/megaglest-source/commit/5a3520540276a6fd06f7c88e571b6462978e3eab.patch";
36       sha256 = "0y554kjw56dikq87vs709pmq97hdx9hvqsk27f81v4g90m3b3qhi";
37     })
38     # Pull upstream and Debian fixes for wxWidgets 3.2
39     (fetchpatch {
40       name = "get-rid-of-manual-wxPaintEvent-creation-1.patch";
41       url = "https://github.com/MegaGlest/megaglest-source/commit/e09ba53c436279588f769d6ce8852e74d58f8391.patch";
42       hash = "sha256-1ZG6AjnLXW18wwad05kjH7W5rTaP1SDpZ5zLH4nRQt4=";
43     })
44     (fetchpatch {
45       name = "get-rid-of-manual-wxPaintEvent-creation-2.patch";
46       url = "https://sources.debian.org/data/main/m/megaglest/3.13.0-9/debian/patches/fbd0cfb17ed759d24aeb577a602b0d97f7895cc2.patch";
47       hash = "sha256-aMDDboNdH22r7YOiZCEApwz+FpM60anBp82tLwiIH6g=";
48     })
49     (fetchpatch {
50       name = "get-rid-of-manual-wxPaintEvent-creation-3.patch";
51       url = "https://github.com/MegaGlest/megaglest-source/commit/5801b1fafff8ad9618248d4d5d5c751fdf52be2f.patch";
52       hash = "sha256-/RpBoT1JsSFtOrAXphHrPp9DnTbaEN/2h8EZmQ9PIPU=";
53     })
54     (fetchpatch {
55       name = "fix-editor-and-g3dviewer-for-wx-3.1.x.patch";
56       url = "https://github.com/MegaGlest/megaglest-source/commit/789e1cdf371137b729e832e28a5feb6e97a3a243.patch";
57       hash = "sha256-fK7vkHCu6bqVB6I7vMsWMGiczSdxVgo1KqqBNMkEbfM=";
58     })
59   ];
61   nativeBuildInputs = [ cmake pkg-config makeWrapper git ];
62   buildInputs = [ curl SDL2 xercesc openal lua libpng libjpeg libvlc wxGTK32
63     glib cppunit fontconfig freetype ftgl glew libogg libvorbis libGLU ];
65   cmakeFlags = [
66     "-DCMAKE_INSTALL_PREFIX=${placeholder "out"}"
67     "-DBUILD_MEGAGLEST=On"
68     "-DBUILD_MEGAGLEST_MAP_EDITOR=On"
69     "-DBUILD_MEGAGLEST_MODEL_IMPORT_EXPORT_TOOLS=On"
70     "-DBUILD_MEGAGLEST_MODEL_VIEWER=On"
71   ];
73   postInstall =  ''
74     for i in $out/bin/*; do
75       wrapProgram $i \
76         --prefix LD_LIBRARY_PATH ":" "${lib-env}/lib" \
77         --prefix PATH ":" "${path-env}/bin"
78     done
79   '';
81   meta = with lib; {
82     description = "Entertaining free (freeware and free software) and open source cross-platform 3D real-time strategy (RTS) game";
83     license = licenses.gpl3;
84     homepage = "https://megaglest.org/";
85     maintainers = [ maintainers.matejc ];
86     platforms = platforms.linux;
87   };