Skip to content

Commit

Permalink
Allow specifying allowUnfreePredicate instead of allowUnfree. The pre…
Browse files Browse the repository at this point in the history
…dicate will have access to the arguments of mkDerivation call. Should be an improvement for #2188
  • Loading branch information
7c6f434c committed Jun 14, 2014
1 parent 18023bc commit a076a60
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkgs/stdenv/generic/default.nix
Expand Up @@ -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);
Expand Down Expand Up @@ -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; }
Expand Down

0 comments on commit a076a60

Please sign in to comment.