diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 952b8b66c10c..bd7410515f38 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -570,11 +570,14 @@ let checkedEnv = let 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 assert assertMsg envIsExportable "When using structured attributes, `env` must be an attribute set of environment variables."; 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 (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)