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