From: TimePath Date: Thu, 29 Dec 2016 13:10:23 +0000 (+1100) Subject: Support nix-build X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fxonotic.git;a=commitdiff_plain;h=da0b615950c1eaaaad25d1512aab927e0b939b6b Support nix-build --- diff --git a/default.nix b/default.nix index 945547f3..7209f729 100644 --- a/default.nix +++ b/default.nix @@ -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 {}; { - xonoticEnv = stdenv.mkDerivation { - name = "xonotic"; - buildInputs = [ - alsaLib - freetype - libjpeg - libpng - mesa - xorg.libX11 - xorg.libXext - xorg.libXpm - xorg.libXxf86vm - zlib - ]; - }; -} +# nix-build +with import {}; { 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; +};}