]> git.rm.cloudns.org Git - xonotic/xonotic.git/commitdiff
Support nix-build TimePath/buildsys
authorTimePath <andrew.hardaker1995@gmail.com>
Thu, 29 Dec 2016 13:10:23 +0000 (00:10 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Thu, 29 Dec 2016 13:10:23 +0000 (00:10 +1100)
default.nix

index 945547f3e4602101da123d0e6be7641020e45279..7209f729ce307d461663e022f5fddc1a27acdd8c 100644 (file)
@@ -1,22 +1,63 @@
-# nix-shell .
-# dst=.
-# cmake -GNinja -H. -B $dst && (cd $dst && cmake --build .)
-# nix-shell . --run './all compile'
-# nix-shell . --run 'LD_LIBRARY_PATH="$HOME/.nix-profile/lib:${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" LD_PRELOAD=/run/opengl-driver/lib/libGL.so.1 ./all run'
-with import <nixpkgs> {}; {
-       xonoticEnv = stdenv.mkDerivation {
-               name = "xonotic";
-               buildInputs = [
-                       alsaLib
-                       freetype
-                       libjpeg
-                       libpng
-                       mesa
-                       xorg.libX11
-                       xorg.libXext
-                       xorg.libXpm
-                       xorg.libXxf86vm
-                       zlib
-               ];
-       };
-}
+# nix-build
+with import <nixpkgs> {}; { xonoticEnv =
+stdenv.mkDerivation rec {
+
+  version = "0.8.1";
+
+  name = "xonotic-${version}";
+
+  src = lib.sourceFilesBySuffices ./. [
+    ".txt" ".cmake" ".in"
+    ".c" ".cpp" ".h"
+    ".inc" ".def"
+    ".qc" ".qh"
+    ".sh"
+  ];
+
+  enableParallelBuilding = true;
+
+  cmakeFlags = [
+    "-DCMAKE_BUILD_TYPE=Release"
+    "-DDOWNLOAD_MAPS=0"
+  ];
+
+  postPatch = ''
+    NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE ${lib.concatStringsSep " " [
+      "-I${SDL2}/include/SDL2"  # for darkplaces
+    ]}"
+  '';
+
+  buildInputs = [
+    cmake  # for building
+    git  # for versioning
+    openssl  # for d0_blind_id
+    SDL2  # for darkplaces
+    # unzip  # for downloading maps
+  ];
+
+  runtimeInputs = [
+    zlib
+    curl
+
+    libjpeg
+    libpng
+
+    freetype
+
+    libogg
+    libtheora
+    libvorbis
+  ];
+
+  installPhase = ''
+    mkdir $out
+    exe=darkplaces/darkplaces
+    rpath=$(patchelf --print-rpath $exe)
+    rpath_firstparty=$out/d0_blind_id
+    rpath_thirdparty=${lib.makeLibraryPath runtimeInputs}
+    rpath=$rpath:$rpath_firstparty:$rpath_thirdparty
+    patchelf --set-rpath $rpath $exe
+    cp -r . $out
+  '';
+  dontPatchELF = true;
+};}