]> git.xonotic.org Git - xonotic/xonotic.git/blob - default.nix
Support nix-build
[xonotic/xonotic.git] / default.nix
1 # nix-build
2 with import <nixpkgs> {}; { xonoticEnv =
3 stdenv.mkDerivation rec {
4
5   version = "0.8.1";
6
7   name = "xonotic-${version}";
8
9   src = lib.sourceFilesBySuffices ./. [
10     ".txt" ".cmake" ".in"
11     ".c" ".cpp" ".h"
12     ".inc" ".def"
13     ".qc" ".qh"
14     ".sh"
15   ];
16
17   enableParallelBuilding = true;
18
19   cmakeFlags = [
20     "-DCMAKE_BUILD_TYPE=Release"
21     "-DDOWNLOAD_MAPS=0"
22   ];
23
24   postPatch = ''
25     NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE ${lib.concatStringsSep " " [
26       "-I${SDL2}/include/SDL2"  # for darkplaces
27     ]}"
28   '';
29
30   buildInputs = [
31     cmake  # for building
32     git  # for versioning
33     openssl  # for d0_blind_id
34     SDL2  # for darkplaces
35     # unzip  # for downloading maps
36   ];
37
38   runtimeInputs = [
39     zlib
40     curl
41
42     libjpeg
43     libpng
44
45     freetype
46
47     libogg
48     libtheora
49     libvorbis
50   ];
51
52   installPhase = ''
53     mkdir $out
54     exe=darkplaces/darkplaces
55     rpath=$(patchelf --print-rpath $exe)
56     rpath_firstparty=$out/d0_blind_id
57     rpath_thirdparty=${lib.makeLibraryPath runtimeInputs}
58     rpath=$rpath:$rpath_firstparty:$rpath_thirdparty
59     patchelf --set-rpath $rpath $exe
60     cp -r . $out
61   '';
62   dontPatchELF = true;
63 };}