From 27ce722638eeabb987bc9b4a1234c2818c5bf401 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Tue, 22 Jun 2021 19:45:08 +0200 Subject: [PATCH] Prefix env vars for attrs.* files with NIX_ --- src/libstore/build/local-derivation-goal.cc | 4 ++-- src/nix-build/nix-build.cc | 4 ++-- tests/shell.nix | 2 +- tests/structured-attrs.nix | 2 +- tests/structured-attrs.sh | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc index 60495ae3e..de64737f4 100644 --- a/src/libstore/build/local-derivation-goal.cc +++ b/src/libstore/build/local-derivation-goal.cc @@ -1092,10 +1092,10 @@ void LocalDerivationGoal::writeStructuredAttrs() writeFile(tmpDir + "/.attrs.sh", rewriteStrings(jsonSh, inputRewrites)); chownToBuilder(tmpDir + "/.attrs.sh"); - env["ATTRS_SH_FILE"] = tmpDir + "/.attrs.sh"; + env["NIX_ATTRS_SH_FILE"] = tmpDir + "/.attrs.sh"; writeFile(tmpDir + "/.attrs.json", rewriteStrings(json.dump(), inputRewrites)); chownToBuilder(tmpDir + "/.attrs.json"); - env["ATTRS_JSON_FILE"] = tmpDir + "/.attrs.json"; + env["NIX_ATTRS_JSON_FILE"] = tmpDir + "/.attrs.json"; } } diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc index 4e4f27458..f67776083 100755 --- a/src/nix-build/nix-build.cc +++ b/src/nix-build/nix-build.cc @@ -454,8 +454,8 @@ static void main_nix_build(int argc, char * * argv) auto attrsSH = (Path) tmpDir + "/.attrs.sh"; writeFile(attrsSH, structuredAttrsRC); - env["ATTRS_SH_FILE"] = attrsSH; - env["ATTRS_JSON_FILE"] = attrsJSON; + env["NIX_ATTRS_SH_FILE"] = attrsSH; + env["NIX_ATTRS_JSON_FILE"] = attrsJSON; keepTmp = true; } } diff --git a/tests/shell.nix b/tests/shell.nix index 53a32059b..4581fa40a 100644 --- a/tests/shell.nix +++ b/tests/shell.nix @@ -10,7 +10,7 @@ let pkgs = rec { done # mimic behavior of stdenv for `$out` etc. for structured attrs. - if [ -n "''${ATTRS_SH_FILE}" ]; then + if [ -n "''${NIX_ATTRS_SH_FILE}" ]; then for o in "''${!outputs[@]}"; do eval "''${o}=''${outputs[$o]}" export "''${o}" diff --git a/tests/structured-attrs.nix b/tests/structured-attrs.nix index f69ee45e9..e93139a44 100644 --- a/tests/structured-attrs.nix +++ b/tests/structured-attrs.nix @@ -36,7 +36,7 @@ mkDerivation { echo bar > $dest echo foo > $dest2 - json=$(cat $ATTRS_JSON_FILE) + json=$(cat $NIX_ATTRS_JSON_FILE) [[ $json =~ '"narHash":"sha256:1r7yc43zqnzl5b0als5vnyp649gk17i37s7mj00xr8kc47rjcybk"' ]] [[ $json =~ '"narSize":288' ]] [[ $json =~ '"closureSize":288' ]] diff --git a/tests/structured-attrs.sh b/tests/structured-attrs.sh index f851b3cbb..9612020b8 100644 --- a/tests/structured-attrs.sh +++ b/tests/structured-attrs.sh @@ -11,7 +11,7 @@ nix-build structured-attrs.nix -A all -o $TEST_ROOT/result export NIX_BUILD_SHELL=$SHELL env NIX_PATH=nixpkgs=shell.nix nix-shell structured-attrs-shell.nix \ - --run 'test -e .attrs.json; test "3" = "$(jq ".my.list|length" < $ATTRS_JSON_FILE)"' + --run 'test -e .attrs.json; test "3" = "$(jq ".my.list|length" < $NIX_ATTRS_JSON_FILE)"' # `nix develop` is a slightly special way of dealing with environment vars, it parses # these from a shell-file exported from a derivation. This is to test especially `outputs`