stdenv.mkDerivation: move errors variable out of happy path

This commit is contained in:
Eman Resu
2026-05-09 20:26:44 -04:00
parent 95a031c363
commit 2113c381ea
+12 -7
View File
@@ -910,19 +910,24 @@ let
checkedEnv =
let
overlappingNames = attrNames (builtins.intersectAttrs env' derivationArg);
errors = lib.concatMapStringsSep "\n" (
name:
" - ${name}: in `env`: ${lib.generators.toPretty { } env'.${name}}; in derivation arguments: ${
lib.generators.toPretty { } derivationArg.${name}
}"
) overlappingNames;
in
assert
(isAttrs env && !isDerivation env)
|| throw "`env` must be an attribute set of environment variables. Set `env.env` or pick a more specific name.";
assert
(overlappingNames == [ ])
|| throw "The `env` attribute set cannot contain any attributes passed to derivation. The following attributes are overlapping:\n${errors}";
|| throw (
let
errors = lib.concatMapStringsSep "\n" (
name:
" - ${name}: in `env`: ${lib.generators.toPretty { } env'.${name}}; in derivation arguments: ${
lib.generators.toPretty { } derivationArg.${name}
}"
) overlappingNames;
in
"The `env` attribute set cannot contain any attributes passed to derivation. The following attributes are overlapping:\n${errors}"
);
mapAttrs (
n: v:
assert