From 899c40e6f8ed0baee363a7a5d3be39241a40a1b7 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Mon, 11 Aug 2025 20:25:57 +0200 Subject: [PATCH] stdenv: remove .attrs.sh fallback for structuredAttrs This was eventually fixed in Nix 2.16+. More discussion in #357053. --- pkgs/build-support/testers/expect-failure.sh | 2 +- pkgs/stdenv/generic/make-derivation.nix | 2 +- pkgs/stdenv/generic/setup.sh | 12 +----------- pkgs/stdenv/generic/source-stdenv.sh | 2 +- 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/pkgs/build-support/testers/expect-failure.sh b/pkgs/build-support/testers/expect-failure.sh index 08199191be7d9..113fe46857cda 100644 --- a/pkgs/build-support/testers/expect-failure.sh +++ b/pkgs/build-support/testers/expect-failure.sh @@ -41,7 +41,7 @@ echo "testBuildFailure: Original builder produced exit code: $r" # # NOTE: This MUST be done after the original builder has finished! # Otherwise we could pollute its environment. -if [ -e "${NIX_ATTRS_SH_FILE:-}" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi +if [ -e "${NIX_ATTRS_SH_FILE:-}" ]; then . "$NIX_ATTRS_SH_FILE"; fi # Variables injected by replaceVars # diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index aed866aa454b9..d092543672cc3 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -847,7 +847,7 @@ let "-c" '' out="${placeholder "out"}" - if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi + if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; fi declare -p > $out for var in $passAsFile; do pathVar="''${var}Path" diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 5aebafc157491..f051ae6c7d44e 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -25,7 +25,7 @@ if [[ ${NIX_DEBUG:-0} -ge 6 ]]; then set -x fi -if [ -f .attrs.sh ] || [[ -n "${NIX_ATTRS_JSON_FILE:-}" ]]; then +if [[ -n "${NIX_ATTRS_JSON_FILE:-}" ]]; then __structuredAttrs=1 echo "structuredAttrs is enabled" @@ -33,16 +33,6 @@ if [ -f .attrs.sh ] || [[ -n "${NIX_ATTRS_JSON_FILE:-}" ]]; then # ex: out=/nix/store/... export "$outputName=${outputs[$outputName]}" done - - # $NIX_ATTRS_JSON_FILE pointed to the wrong location in sandbox - # https://github.com/NixOS/nix/issues/6736; please keep around until the - # fix reaches *every patch version* that's >= lib/minver.nix - if ! [[ -e "${NIX_ATTRS_JSON_FILE:-}" ]]; then - export NIX_ATTRS_JSON_FILE="$NIX_BUILD_TOP/.attrs.json" - fi - if ! [[ -e "${NIX_ATTRS_SH_FILE:-}" ]]; then - export NIX_ATTRS_SH_FILE="$NIX_BUILD_TOP/.attrs.sh" - fi else __structuredAttrs= : "${outputs:=out}" diff --git a/pkgs/stdenv/generic/source-stdenv.sh b/pkgs/stdenv/generic/source-stdenv.sh index 44318cd236912..1e8cbe68e9dfd 100644 --- a/pkgs/stdenv/generic/source-stdenv.sh +++ b/pkgs/stdenv/generic/source-stdenv.sh @@ -1,3 +1,3 @@ -if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi +if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; fi source "$stdenv/setup" source "$1"