From dab8e47b1073970fbd06011c42d86ce123b4ef1f Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 21 Apr 2018 17:15:02 +1000 Subject: [PATCH] nix: invert isCode condition --- derivation.nix | 119 ++++++++++++++++++++++++++++--------------------- 1 file changed, 67 insertions(+), 52 deletions(-) diff --git a/derivation.nix b/derivation.nix index 945f39ac..f6378ba6 100644 --- a/derivation.nix +++ b/derivation.nix @@ -9,58 +9,6 @@ let VERSION = "0.8.2"; - stdenv = if (cc == null) then pkgs.stdenv - else pkgs.overrideCC pkgs.stdenv pkgs."${cc}"; - - cleanSourceFilter = name: type: let - baseName = baseNameOf (toString name); - result = (lib.cleanSourceFilter name type) - && !(lib.hasSuffix ".nix" baseName) - && !(type == "directory" && baseName == ".git") - && !(type == "directory" && baseName == ".idea") - && !(type == "directory" && (lib.hasPrefix "cmake-build-" baseName)) - ; - in result; - - localFilesCustom = src: filter: - builtins.filterSource (name: type: (cleanSourceFilter name type) && (filter name type)) src - ; - localFiles = src: localFilesCustom src (name: type: true); - - localFilesMain = src: let - project = toString ./.; - cleanSourceFilterMain = name: type: let - baseName = baseNameOf (toString name); - result = (cleanSourceFilter name type) - && !(name == "${project}/release") - && !(name == "${project}/d0_blind_id") - && !(name == "${project}/daemon") - && !(name == "${project}/darkplaces") - && !(name == "${project}/data") - && !(name == "${project}/gmqcc") - && !(name == "${project}/netradiant") - && !(name == "${project}/wiki" || name == "${project}/wiki.yes") - && !(name == "${project}/xonstat" || name == "${project}/xonstat.yes") - ; - in result; - in builtins.filterSource cleanSourceFilterMain src; - - isCode = name: let - baseName = baseNameOf (toString name); - result = false - || (lib.hasSuffix ".txt" baseName) - || (lib.hasSuffix ".cmake" baseName) - || (lib.hasSuffix ".in" baseName) - || (lib.hasSuffix ".sh" baseName) - - || (lib.hasSuffix ".qc" baseName) - || (lib.hasSuffix ".qh" baseName) - || (lib.hasSuffix ".inc" baseName) - - || (lib.hasSuffix ".cfg" baseName) - ; - in result; - srcs = { # https://gitlab.com/xonotic/xonotic "xonotic" = localFilesMain ./.; @@ -95,6 +43,53 @@ let "data/xonotic-nexcompat" = localFiles ./data/xonotic-nexcompat.pk3dir; }; + localFilesMain = src: let + project = toString ./.; + cleanSourceFilterMain = name: type: let + baseName = baseNameOf (toString name); + result = (cleanSourceFilter name type) + && !(name == "${project}/release") + && !(name == "${project}/d0_blind_id") + && !(name == "${project}/daemon") + && !(name == "${project}/darkplaces") + && !(name == "${project}/data") + && !(name == "${project}/gmqcc") + && !(name == "${project}/netradiant") + && !(name == "${project}/wiki" || name == "${project}/wiki.yes") + && !(name == "${project}/xonstat" || name == "${project}/xonstat.yes") + ; + in result; + in builtins.filterSource cleanSourceFilterMain src; + + isCode = name: let + baseName = baseNameOf (toString name); + result = !(false + || (lib.hasSuffix ".ase" baseName) + || (lib.hasSuffix ".dem" baseName) + || (lib.hasSuffix ".dpm" baseName) + || (lib.hasSuffix ".framegroups" baseName) + || (lib.hasSuffix ".iqm" baseName) + || (lib.hasSuffix ".jpg" baseName) + || (lib.hasSuffix ".lmp" baseName) + || (lib.hasSuffix ".md3" baseName) + || (lib.hasSuffix ".mdl" baseName) + || (lib.hasSuffix ".obj" baseName) + || (lib.hasSuffix ".ogg" baseName) + || (lib.hasSuffix ".png" baseName) + || (lib.hasSuffix ".shader" baseName) + || (lib.hasSuffix ".skin" baseName) + || (lib.hasSuffix ".sounds" baseName) + || (lib.hasSuffix ".sp2" baseName) + || (lib.hasSuffix ".spr" baseName) + || (lib.hasSuffix ".spr32" baseName) + || (lib.hasSuffix ".svg" baseName) + || (lib.hasSuffix ".tga" baseName) + || (lib.hasSuffix ".wav" baseName) + || (lib.hasSuffix ".width" baseName) + || (lib.hasSuffix ".zym" baseName) + ); + in result; + targets = rec { font-dejavu = mkDerivation rec { name = "font-dejavu-${version}"; @@ -360,6 +355,25 @@ let }; }; + cleanSourceFilter = name: type: let + baseName = baseNameOf (toString name); + result = (lib.cleanSourceFilter name type) + && !(lib.hasSuffix ".nix" baseName) + && !(type == "directory" && baseName == ".git") + && !(type == "directory" && baseName == ".idea") + && !(type == "directory" && (lib.hasPrefix "cmake-build-" baseName)) + ; + in result; + + localFilesCustom = src: filter: + builtins.filterSource (name: type: (cleanSourceFilter name type) && (filter name type)) src + ; + + localFiles = src: localFilesCustom src (name: type: true); + + stdenv = if (cc == null) then pkgs.stdenv + else pkgs.overrideCC pkgs.stdenv pkgs."${cc}"; + mkDerivation = {env ? {}, shellHook ? "", runtimeInputs ? [], ...}@args: stdenv.mkDerivation ({} // { enableParallelBuilding = true; } // (removeAttrs args ["env" "shellHook" "runtimeInputs"]) @@ -372,6 +386,7 @@ let ''; } ); + shell = let inputs = (lib.mapAttrsToList (n: v: v) targets); in stdenv.mkDerivation (rec { name = "xonotic-shell"; nativeBuildInputs = builtins.map (it: it.nativeBuildInputs) inputs; -- 2.39.2