diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 3fb827a154b..6910e52c5f4 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -2584,6 +2584,7 @@ void DerivationGoal::writeStructuredAttrs() writeFile(tmpDir + "/.attrs.json", rewriteStrings(json.dump(), inputRewrites)); chownToBuilder(tmpDir + "/.attrs.json"); + env["NIX_ATTRS_JSON_FILE"] = tmpDirInSandbox + "/.attrs.json"; /* As a convenience to bash scripts, write a shell file that maps all attributes that are representable in bash - @@ -2653,6 +2654,7 @@ void DerivationGoal::writeStructuredAttrs() writeFile(tmpDir + "/.attrs.sh", rewriteStrings(jsonSh, inputRewrites)); chownToBuilder(tmpDir + "/.attrs.sh"); + env["NIX_ATTRS_SH_FILE"] = tmpDirInSandbox + "/.attrs.sh"; } diff --git a/tests/structured-attrs.nix b/tests/structured-attrs.nix index 6c77a43913a..7a9a83d603b 100644 --- a/tests/structured-attrs.nix +++ b/tests/structured-attrs.nix @@ -38,6 +38,12 @@ mkDerivation { [[ $json =~ '"narSize":288' ]] [[ $json =~ '"closureSize":288' ]] [[ $json =~ '"references":[]' ]] + + [[ -e "$NIX_ATTRS_SH_FILE" ]] + [[ -e "$NIX_ATTRS_JSON_FILE" ]] + + [[ "$(<"$NIX_ATTRS_SH_FILE")" = "$(<.attrs.sh)" ]] + [[ "$(<"$NIX_ATTRS_JSON_FILE")" = "$(<.attrs.json)" ]] ''; buildInputs = [ "a" "b" "c" 123 "'" "\"" null ];