Allow specifying allowUnfreePredicate instead of allowUnfree. The predicate will have access to the arguments of mkDerivation call. Should be an improvement for #2188
This commit is contained in:
parent
18023bc0e8
commit
a076a60735
|
@ -16,6 +16,15 @@ let
|
||||||
|
|
||||||
allowUnfree = config.allowUnfree or false || builtins.getEnv "NIXPKGS_ALLOW_UNFREE" == "1";
|
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";
|
allowBroken = config.allowBroken or false || builtins.getEnv "NIXPKGS_ALLOW_BROKEN" == "1";
|
||||||
|
|
||||||
unsafeGetAttrPos = builtins.unsafeGetAttrPos or (n: as: null);
|
unsafeGetAttrPos = builtins.unsafeGetAttrPos or (n: as: null);
|
||||||
|
@ -57,7 +66,7 @@ let
|
||||||
unsafeGetAttrPos "name" attrs;
|
unsafeGetAttrPos "name" attrs;
|
||||||
pos' = if pos != null then "‘" + pos.file + ":" + toString pos.line + "’" else "«unknown-file»";
|
pos' = if pos != null then "‘" + pos.file + ":" + toString pos.line + "’" else "«unknown-file»";
|
||||||
in
|
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 ''
|
throw ''
|
||||||
Package ‘${attrs.name}’ in ${pos'} has an unfree license, refusing to evaluate. You can set
|
Package ‘${attrs.name}’ in ${pos'} has an unfree license, refusing to evaluate. You can set
|
||||||
{ nixpkgs.config.allowUnfree = true; }
|
{ nixpkgs.config.allowUnfree = true; }
|
||||||
|
|
Loading…
Reference in a new issue