stdenv.mkDerivation: move attrNames out of happy path

This commit is contained in:
Eman Resu
2026-05-01 16:13:59 -04:00
parent 2113c381ea
commit dfa34d9376
+4 -3
View File
@@ -26,6 +26,7 @@ let
getDev
head
foldl'
intersectAttrs
isAttrs
isBool
isDerivation
@@ -909,13 +910,13 @@ let
checkedEnv =
let
overlappingNames = attrNames (builtins.intersectAttrs env' derivationArg);
overlappingArgs = intersectAttrs env' derivationArg;
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 == [ ])
(overlappingArgs == { })
|| throw (
let
errors = lib.concatMapStringsSep "\n" (
@@ -923,7 +924,7 @@ let
" - ${name}: in `env`: ${lib.generators.toPretty { } env'.${name}}; in derivation arguments: ${
lib.generators.toPretty { } derivationArg.${name}
}"
) overlappingNames;
) (attrNames overlappingArgs);
in
"The `env` attribute set cannot contain any attributes passed to derivation. The following attributes are overlapping:\n${errors}"