stdenv: refactor code for evaluation errors (no hash changes)
This commit is contained in:
parent
2f4dc089a9
commit
123a8bf9a5
@ -27,15 +27,6 @@ let
|
|||||||
|
|
||||||
allowBroken = config.allowBroken or false || builtins.getEnv "NIXPKGS_ALLOW_BROKEN" == "1";
|
allowBroken = config.allowBroken or false || builtins.getEnv "NIXPKGS_ALLOW_BROKEN" == "1";
|
||||||
|
|
||||||
forceEvalHelp = unfreeOrBroken:
|
|
||||||
assert (unfreeOrBroken == "Unfree" || unfreeOrBroken == "Broken");
|
|
||||||
''
|
|
||||||
You can set
|
|
||||||
{ nixpkgs.config.allow${unfreeOrBroken} = true; }
|
|
||||||
in configuration.nix to override this. If you use Nix standalone, you can add
|
|
||||||
{ allow${unfreeOrBroken} = true; }
|
|
||||||
to ~/.nixpkgs/config.nix.'';
|
|
||||||
|
|
||||||
unsafeGetAttrPos = builtins.unsafeGetAttrPos or (n: as: null);
|
unsafeGetAttrPos = builtins.unsafeGetAttrPos or (n: as: null);
|
||||||
|
|
||||||
isUnfree = licenses: lib.lists.any (l:
|
isUnfree = licenses: lib.lists.any (l:
|
||||||
@ -61,19 +52,24 @@ let
|
|||||||
else
|
else
|
||||||
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»";
|
||||||
|
|
||||||
|
throwEvalHelp = unfreeOrBroken: whatIsWrong:
|
||||||
|
assert (unfreeOrBroken == "Unfree" || unfreeOrBroken == "Broken");
|
||||||
|
throw ''
|
||||||
|
Package ‘${attrs.name}’ in ${pos'} ${whatIsWrong}, refusing to evaluate.
|
||||||
|
You can set
|
||||||
|
{ nixpkgs.config.allow${unfreeOrBroken} = true; }
|
||||||
|
in configuration.nix to override this. If you use Nix standalone, you can add
|
||||||
|
{ allow${unfreeOrBroken} = true; }
|
||||||
|
to ~/.nixpkgs/config.nix.
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
if !allowUnfree && isUnfree (lib.lists.toList attrs.meta.license or []) && !allowUnfreePredicate attrs then
|
if !allowUnfree && isUnfree (lib.lists.toList attrs.meta.license or []) && !allowUnfreePredicate attrs then
|
||||||
throw ''
|
throwEvalHelp "Unfree" "has an unfree license"
|
||||||
Package ‘${attrs.name}’ in ${pos'} has an unfree license, refusing to evaluate.
|
|
||||||
${forceEvalHelp "Unfree"}''
|
|
||||||
else if !allowBroken && attrs.meta.broken or false then
|
else if !allowBroken && attrs.meta.broken or false then
|
||||||
throw ''
|
throwEvalHelp "Broken" "is marked as broken"
|
||||||
Package ‘${attrs.name}’ in ${pos'} is marked as broken, refusing to evaluate.
|
|
||||||
${forceEvalHelp "Broken"}''
|
|
||||||
else if !allowBroken && attrs.meta.platforms or null != null && !lib.lists.elem result.system attrs.meta.platforms then
|
else if !allowBroken && attrs.meta.platforms or null != null && !lib.lists.elem result.system attrs.meta.platforms then
|
||||||
throw ''
|
throwEvalHelp "Broken" "is not supported on ‘${result.system}’"
|
||||||
Package ‘${attrs.name}’ in ${pos'} is not supported on ‘${result.system}’, refusing to evaluate.
|
|
||||||
${forceEvalHelp "Broken"}''
|
|
||||||
else
|
else
|
||||||
lib.addPassthru (derivation (
|
lib.addPassthru (derivation (
|
||||||
(removeAttrs attrs ["meta" "passthru" "crossAttrs"])
|
(removeAttrs attrs ["meta" "passthru" "crossAttrs"])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user