about summary refs log tree commit diff
path: root/pkgs/stdenv
diff options
context:
space:
mode:
authorMichael Raskin <7c6f434c@mail.ru>2014-06-14 13:01:12 +0400
committerMichael Raskin <7c6f434c@mail.ru>2014-06-14 13:01:12 +0400
commita076a60735bb8598571978a40aab4d65be265c2f (patch)
treee4a1bf4de3c713fd91be9f84bc2db4cf7fcb7070 /pkgs/stdenv
parent18023bc0e843db6aaaebb2cea2b157de265b8046 (diff)
Allow specifying allowUnfreePredicate instead of allowUnfree. The predicate will have access to the arguments of mkDerivation call. Should be an improvement for #2188
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r--pkgs/stdenv/generic/default.nix11
1 files changed, 10 insertions, 1 deletions
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index 14da127b9e052..49f95779ce12e 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -16,6 +16,15 @@ let
 
   allowUnfree = config.allowUnfree or false || builtins.getEnv "NIXPKGS_ALLOW_UNFREE" == "1";
 
+  # Alow granular checks to allow only some unfree packages
+  # Example:
+  # {pkgs, ...}:
+  # {
+  #   allowUnfree = false;
+  #   allowUnfreePredicate = (x: pkgs.lib.hasPrefix "flashplayero-" x.name);
+  # }
+  allowUnfreePredicate = config.allowUnfreePredicate or (x: false);
+
   allowBroken = config.allowBroken or false || builtins.getEnv "NIXPKGS_ALLOW_BROKEN" == "1";
 
   unsafeGetAttrPos = builtins.unsafeGetAttrPos or (n: as: null);
@@ -57,7 +66,7 @@ let
               unsafeGetAttrPos "name" attrs;
           pos' = if pos != null then "‘" + pos.file + ":" + toString pos.line + "’" else "«unknown-file»";
         in
-        if !allowUnfree && (let l = lib.lists.toList attrs.meta.license or []; in lib.lists.elem "unfree" l || lib.lists.elem "unfree-redistributable" l) then
+        if !allowUnfree && (let l = lib.lists.toList attrs.meta.license or []; in lib.lists.elem "unfree" l || lib.lists.elem "unfree-redistributable" l) && !(allowUnfreePredicate attrs) then
           throw ''
             Package ‘${attrs.name}’ in ${pos'} has an unfree license, refusing to evaluate. You can set
               { nixpkgs.config.allowUnfree = true; }