1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-12 21:46:01 +01:00

Merge pull request #12026 from Ma27/2.3-backport-structured-attrs-env

[2.3] build: backport NIX_ATTRS_*_FILE
This commit is contained in:
Eelco Dolstra 2024-12-09 13:03:10 +01:00 committed by GitHub
commit ff8cce1244
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View file

@ -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";
}

View file

@ -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 ];