X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fxonotic.git;a=blobdiff_plain;f=default.nix;h=c523b5693d39f57b4d90b7bba9a917618befd2f2;hp=6e954f4c013053d57d885f359309c6155effc678;hb=883e2b54db7e05149fcd5d4cfcf40ebd7181b29e;hpb=591141a9ad63861c1bcd85bdd54bf726bef8e0d5 diff --git a/default.nix b/default.nix index 6e954f4c..c523b569 100644 --- a/default.nix +++ b/default.nix @@ -1,155 +1,2 @@ -# nix-shell -A shell -# --argstr cc clang -{ - nixpkgs ? , - pkgs ? (import nixpkgs) {}, - cc ? null -}: -with pkgs; -let - VERSION = "0.8.2"; - cmake = pkgs.cmake_2_8; - targets = rec { - xonotic = mkDerivation { pki = true; dp = true; data = true; } rec { - name = "xonotic-${version}"; - version = VERSION; - - src = lib.sourceFilesBySuffices ./. [ - ".txt" ".cmake" ".in" - ".c" ".cpp" ".h" - ".inc" ".def" - ".qc" ".qh" - ".sh" - ]; - - env = { - QCC = "${gmqcc}/gmqcc"; - }; - - nativeBuildInputs = [ - cmake # for building - git # for versioning - # unzip # for downloading maps - ]; - - cmakeFlags = [ - "-DDOWNLOAD_MAPS=0" - ]; - - buildInputs = [ - openssl # for d0_blind_id - SDL2 # for darkplaces - ]; - - 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:}$rpath_firstparty:$rpath_thirdparty - patchelf --set-rpath $rpath $exe - - cp -r . $out - ''; - - dontPatchELF = true; - }; - - gmqcc = mkDerivation { qcc = true; } rec { - name = "gmqcc-${version}"; - version = "xonotic-${VERSION}"; - - src = ./gmqcc; - - installPhase = '' - mkdir $out - cp -r . $out - ''; - }; - - netradiant = mkDerivation { radiant = true; } rec { - name = "netradiant-${version}"; - version = VERSION; - - src = ./netradiant; - - nativeBuildInputs = [ - cmake # for building - git # for versioning - ]; - - cmakeFlags = [ - "-DDOWNLOAD_MAPS=0" - ]; - - buildInputs = [ - pkgconfig - glib - pcre - libxml2 - ncurses - libjpeg - libpng - minizip - - mesa - - xorg.libXt - xorg.libXmu - xorg.libSM - xorg.libICE - xorg.libpthreadstubs - xorg.libXdmcp - - gnome3.gtk - gnome2.gtk - gnome2.gtkglext - ]; - }; - }; - stdenv = if (cc != null) then overrideCC pkgs.stdenv pkgs."${cc}" else pkgs.stdenv; - mkEnableTargets = args: { - XON_NO_PKI = !args?pki; - XON_NO_DP = !args?dp; - XON_NO_DATA = !args?data; - XON_NO_QCC = !args?qcc; - XON_NO_RADIANT = !args?radiant; - }; - mkDerivation = targets: {env ? {}, shellHook ? "", runtimeInputs ? [], ...}@args: - stdenv.mkDerivation ( - (mkEnableTargets targets) - // { enableParallelBuilding = true; } - // (removeAttrs args ["env" "shellHook" "runtimeInputs"]) # passthru - // env - // { - shellHook = '' - ${shellHook} - ${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: "export ${n}=${v}") env)} - export LD_LIBRARY_PATH=''${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}${lib.makeLibraryPath runtimeInputs} - ''; - } - ); - shell = let inputs = (lib.mapAttrsToList (n: v: v) targets); in stdenv.mkDerivation (rec { - name = "xon-shell"; - XON_NO_DAEMON = true; - nativeBuildInputs = builtins.map (it: it.nativeBuildInputs) inputs; - buildInputs = builtins.map (it: it.buildInputs) inputs; - shellHook = builtins.map (it: it.shellHook) (builtins.filter (it: it?shellHook) inputs); - }); -in { inherit shell; } // targets +{ pkgs ? import {}, cc ? null }@args: +pkgs.callPackage ./derivation.nix args