Skip to content

Commit

Permalink
devShellTools.unstructuredDerivationInputEnv: Skip args
Browse files Browse the repository at this point in the history
  • Loading branch information
roberth committed Jul 28, 2024
1 parent 33aaac1 commit bde2e05
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pkgs/build-support/dev-shell-tools/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ rec {
then lib.nameValuePair "${name}Path" "${writeText "pass-as-text-${name}" str}"
else lib.nameValuePair name str
)
drvAttrs;
(removeAttrs drvAttrs [
"args"
]);

derivationOutputEnv = { outputList, outputMap }:
# A mapping from output name to the nix store path where they should end up
Expand Down
13 changes: 11 additions & 2 deletions pkgs/build-support/dev-shell-tools/tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ in
aPackageAttrSet = hello;
anOutPath = hello.outPath;
anAnAlternateOutput = zlib.dev;
args = [ "args must not be added to the environment" "Nix doesn't do it." ];

passAsFile = [ "bar" ];
bar = ''
Expand Down Expand Up @@ -107,6 +108,10 @@ in
installPhase = "touch $out";

checkPhase = ''
fail() {
echo "$@" >&2
exit 1
}
checkAttr() {
echo checking attribute $1...
if [[ "$2" != "$3" ]]; then
Expand All @@ -124,6 +129,8 @@ in
(removeAttrs
result
[
"args"
# Nix puts it in workdir, which is not a concept for
# unstructuredDerivationInputEnv, so we have to put it in the
# store instead. This means the full path won't match.
Expand All @@ -141,7 +148,9 @@ in
# [[ "$(basename $exampleBarPathString)" = "$(basename $barPath)" ]]
)
touch $out
''${args:+fail "args should not be set by Nix. We don't expect it to and unstructuredDerivationInputEnv removes it."}
'';
} // drvAttrs);
} // removeAttrs drvAttrs [
"args"
]);
}

0 comments on commit bde2e05

Please sign in to comment.