nix: add netradiant minizip dependency
[xonotic/xonotic.git] / default.nix
1 # nix-shell -A xonotic
2 # --argstr cc clang
3 {
4     nixpkgs ? <nixpkgs>,
5     pkgs ? (import nixpkgs) {},
6     cc ? null,
7 }:
8 with pkgs;
9 let
10     VERSION = "0.8.2";
11     stdenv = if (cc != null) then overrideCC pkgs.stdenv pkgs."${cc}" else pkgs.stdenv;
12     targets = rec {
13         xonotic = stdenv.mkDerivation rec {
14             name = "xonotic-${version}";
15             version = VERSION;
16
17             XON_NO_DAEMON = true;
18             XON_NO_RADIANT = true;
19
20             XON_NO_QCC = true;
21             QCC = "${gmqcc}/gmqcc";
22
23             src = lib.sourceFilesBySuffices ./. [
24                 ".txt" ".cmake" ".in"
25                 ".c" ".cpp" ".h"
26                 ".inc" ".def"
27                 ".qc" ".qh"
28                 ".sh"
29             ];
30
31             enableParallelBuilding = true;
32
33             cmakeFlags = [
34                 "-DDOWNLOAD_MAPS=0"
35             ];
36
37             nativeBuildInputs = [
38                 cmake   # for building
39                 git     # for versioning
40                 # unzip # for downloading maps
41             ];
42
43             buildInputs = [
44                 openssl # for d0_blind_id
45                 SDL2    # for darkplaces
46             ];
47
48             runtimeInputs = [
49                 zlib
50                 curl
51
52                 libjpeg
53                 libpng
54
55                 freetype
56
57                 libogg
58                 libtheora
59                 libvorbis
60             ];
61
62             shellHook = ''
63                 export LD_LIBRARY_PATH=''${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}${lib.makeLibraryPath runtimeInputs}
64             '';
65
66             installPhase = ''
67                 mkdir $out
68
69                 exe=darkplaces/darkplaces
70                 rpath=$(patchelf --print-rpath $exe)
71                 rpath_firstparty=$out/d0_blind_id
72                 rpath_thirdparty=${lib.makeLibraryPath runtimeInputs}
73                 rpath=''${rpath:+$rpath:}$rpath_firstparty:$rpath_thirdparty
74                 patchelf --set-rpath $rpath $exe
75
76                 cp -r . $out
77             '';
78
79             dontPatchELF = true;
80         };
81
82         gmqcc = stdenv.mkDerivation rec {
83             name = "gmqcc-${version}";
84             version = "xonotic-${VERSION}";
85
86             src = ./gmqcc;
87
88             enableParallelBuilding = true;
89
90             installPhase = ''
91                 mkdir $out
92                 cp -r . $out
93             '';
94         };
95
96         netradiant = stdenv.mkDerivation rec {
97             name = "netradiant-${version}";
98             version = VERSION;
99
100             XON_NO_DAEMON = true;
101             XON_NO_DP = true;
102             XON_NO_PKI = true;
103             XON_NO_QCC = true;
104             XON_NO_DATA = true;
105
106             src = ./netradiant;
107
108             enableParallelBuilding = true;
109
110             cmakeFlags = [
111                 "-DDOWNLOAD_MAPS=0"
112                 "-DGTK_NS=GTK"
113             ];
114
115             nativeBuildInputs = [
116                 cmake   # for building
117                 git     # for versioning
118             ];
119
120             buildInputs = [
121                 pkgconfig
122                 glib
123                 libxml2
124                 ncurses
125                 libjpeg
126                 libpng
127                 minizip
128
129                 mesa
130
131                 xorg.libXt
132                 xorg.libXmu
133                 xorg.libSM
134                 xorg.libICE
135
136                 gnome2.gtk
137                 gnome2.gtkglext
138             ];
139         };
140     };
141 in targets