]> de.git.xonotic.org Git - xonotic/xonotic.git/blob - default.nix
d4d10211e692af99ee9ab3f2a010a9c85302ae62
[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
12             XON_NO_DAEMON = true;
13             XON_NO_RADIANT = true;
14
15             XON_NO_QCC = true;
16             QCC = "${gmqcc}/gmqcc";
17
18             version = VERSION;
19
20             name = "xonotic-${version}";
21
22             src = lib.sourceFilesBySuffices ./. [
23                 ".txt" ".cmake" ".in"
24                 ".c" ".cpp" ".h"
25                 ".inc" ".def"
26                 ".qc" ".qh"
27                 ".sh"
28             ];
29
30             enableParallelBuilding = true;
31
32             cmakeFlags = [
33                 "-DDOWNLOAD_MAPS=0"
34             ];
35
36             nativeBuildInputs = [
37                 cmake   # for building
38                 git     # for versioning
39                 # unzip # for downloading maps
40             ];
41
42             buildInputs = [
43                 openssl # for d0_blind_id
44                 SDL2    # for darkplaces
45             ];
46
47             runtimeInputs = [
48                 zlib
49                 curl
50
51                 libjpeg
52                 libpng
53
54                 freetype
55
56                 libogg
57                 libtheora
58                 libvorbis
59             ];
60
61             shellHook = ''
62                 export LD_LIBRARY_PATH=''${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}${lib.makeLibraryPath runtimeInputs}
63             '';
64
65             installPhase = ''
66                 mkdir $out
67
68                 exe=darkplaces/darkplaces
69                 rpath=$(patchelf --print-rpath $exe)
70                 rpath_firstparty=$out/d0_blind_id
71                 rpath_thirdparty=${lib.makeLibraryPath runtimeInputs}
72                 rpath=''${rpath:+$rpath:}$rpath_firstparty:$rpath_thirdparty
73                 patchelf --set-rpath $rpath $exe
74
75                 cp -r . $out
76             '';
77
78             dontPatchELF = true;
79         };
80
81         gmqcc = stdenv.mkDerivation rec {
82             version = "xonotic-${VERSION}";
83
84             name = "gmqcc-${version}";
85
86             src = ./gmqcc;
87
88             enableParallelBuilding = true;
89
90             installPhase = ''
91                 mkdir $out
92                 cp -r . $out
93             '';
94         };
95     };
96 in targets