mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-16 06:45:16 +01:00
Merge pull request #332750 from K900/better-env-errors
make-derivation.nix: better error reporting for conflicting env attributes
This commit is contained in:
commit
3733d4b091
1 changed files with 6 additions and 3 deletions
|
@ -354,7 +354,7 @@ else let
|
||||||
then attrs.name + hostSuffix
|
then attrs.name + hostSuffix
|
||||||
else
|
else
|
||||||
# we cannot coerce null to a string below
|
# we cannot coerce null to a string below
|
||||||
assert assertMsg (attrs ? version && attrs.version != null) "The ‘version’ attribute cannot be null.";
|
assert assertMsg (attrs ? version && attrs.version != null) "The `version` attribute cannot be null.";
|
||||||
"${attrs.pname}${staticMarker}${hostSuffix}-${attrs.version}"
|
"${attrs.pname}${staticMarker}${hostSuffix}-${attrs.version}"
|
||||||
);
|
);
|
||||||
}) // {
|
}) // {
|
||||||
|
@ -570,14 +570,17 @@ let
|
||||||
checkedEnv =
|
checkedEnv =
|
||||||
let
|
let
|
||||||
overlappingNames = attrNames (builtins.intersectAttrs env derivationArg);
|
overlappingNames = attrNames (builtins.intersectAttrs env derivationArg);
|
||||||
|
prettyPrint = lib.generators.toPretty {};
|
||||||
|
makeError = name: " - ${name}: in `env`: ${prettyPrint env.${name}}; in derivation arguments: ${prettyPrint derivationArg.${name}}";
|
||||||
|
errors = lib.concatMapStringsSep "\n" makeError overlappingNames;
|
||||||
in
|
in
|
||||||
assert assertMsg envIsExportable
|
assert assertMsg envIsExportable
|
||||||
"When using structured attributes, `env` must be an attribute set of environment variables.";
|
"When using structured attributes, `env` must be an attribute set of environment variables.";
|
||||||
assert assertMsg (overlappingNames == [ ])
|
assert assertMsg (overlappingNames == [ ])
|
||||||
"The ‘env’ attribute set cannot contain any attributes passed to derivation. The following attributes are overlapping: ${concatStringsSep ", " overlappingNames}";
|
"The `env` attribute set cannot contain any attributes passed to derivation. The following attributes are overlapping:\n${errors}";
|
||||||
mapAttrs
|
mapAttrs
|
||||||
(n: v: assert assertMsg (isString v || isBool v || isInt v || isDerivation v)
|
(n: v: assert assertMsg (isString v || isBool v || isInt v || isDerivation v)
|
||||||
"The ‘env’ attribute set can only contain derivation, string, boolean or integer attributes. The ‘${n}’ attribute is of type ${builtins.typeOf v}."; v)
|
"The `env` attribute set can only contain derivation, string, boolean or integer attributes. The `${n}` attribute is of type ${builtins.typeOf v}."; v)
|
||||||
env;
|
env;
|
||||||
|
|
||||||
# Fixed-output derivations may not reference other paths, which means that
|
# Fixed-output derivations may not reference other paths, which means that
|
||||||
|
|
Loading…
Reference in a new issue