From 5c20ed83ddf3e00269fad3e98bd1ab38264bdeb1 Mon Sep 17 00:00:00 2001 From: Aliaksandr Date: Thu, 14 May 2026 01:05:26 +0300 Subject: [PATCH 1/7] stdenv: linux: centralise updateAutotoolsGnuConfigScriptsHook in stageFun MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The hook was added six times — once in each of stages 1, xgcc, 2, 3, 4 (and again at the final stdenv) — to teach configure scripts about non-x86_64 architectures. Wire it once inside stageFun instead, guarded by `prevStage ? updateAutotoolsGnuConfigScriptsHook` so the dummy stage (whose prevStage is the raw stub) is unaffected. The final stdenv (built outside stageFun) keeps its explicit entry. Eval-verified: stdenv.drvPath is unchanged from master (q2xn5647kadsgpz40xcmjssa0pmdmiwi-stdenv-linux.drv). --- pkgs/stdenv/linux/default.nix | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index feb7f90a147f..c95675239cbe 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -181,7 +181,13 @@ let buildPlatform = localSystem; hostPlatform = localSystem; targetPlatform = localSystem; - inherit extraNativeBuildInputs; + # Every real (post-dummy) stage needs this hook so configure scripts + # can recognise architectures (LoongArch, RISC-V, etc.). + extraNativeBuildInputs = + extraNativeBuildInputs + ++ lib.optional ( + prevStage ? updateAutotoolsGnuConfigScriptsHook + ) prevStage.updateAutotoolsGnuConfigScriptsHook; inherit (stage0) initialPath; preHook = '' # Don't patch #!/interpreter because it leads to retained @@ -311,9 +317,6 @@ in }; }); }; - - # `gettext` comes with obsolete config.sub/config.guess that don't recognize LoongArch64. - extraNativeBuildInputs = [ prevStage.updateAutotoolsGnuConfigScriptsHook ]; } ) @@ -427,9 +430,6 @@ in ''; }); }; - - # `gettext` comes with obsolete config.sub/config.guess that don't recognize LoongArch64. - extraNativeBuildInputs = [ prevStage.updateAutotoolsGnuConfigScriptsHook ]; } ) @@ -531,10 +531,6 @@ in ); }; - - # `gettext` comes with obsolete config.sub/config.guess that don't recognize LoongArch64. - # `libtool` comes with obsolete config.sub/config.guess that don't recognize Risc-V. - extraNativeBuildInputs = [ prevStage.updateAutotoolsGnuConfigScriptsHook ]; } ) @@ -605,8 +601,6 @@ in }; extraNativeBuildInputs = [ prevStage.patchelf - # Many tarballs come with obsolete config.sub/config.guess that don't recognize aarch64. - prevStage.updateAutotoolsGnuConfigScriptsHook ]; } ) @@ -671,8 +665,6 @@ in extraNativeBuildInputs = [ prevStage.patchelf prevStage.xz - # Many tarballs come with obsolete config.sub/config.guess that don't recognize aarch64. - prevStage.updateAutotoolsGnuConfigScriptsHook ]; } ) From 0a27772068b2658b0dc7911375c1e42cc6bc301d Mon Sep 17 00:00:00 2001 From: Aliaksandr Date: Thu, 14 May 2026 01:38:17 +0300 Subject: [PATCH 2/7] stdenv: linux: drop dead enableGold=false override from stage1 The override at `super.binutils-unwrapped.override { enableGold = false; }` defined a stage1 `binutils-unwrapped` derivation that was never used: xgcc-stage and stage2 both build their own fresh `super.binutils-unwrapped` without inheriting from stage1, so the gold-disabled rebuild never appeared in the build graph (verified via `nix-store --query --requisites`). Verified by drv-hash equality: stdenv.drvPath is unchanged (q2xn5647kadsgpz40xcmjssa0pmdmiwi-stdenv-linux.drv). --- pkgs/stdenv/linux/default.nix | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index c95675239cbe..511248c81957 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -283,11 +283,7 @@ in stageFun prevStage { name = "bootstrap-stage1"; - # Rebuild binutils to use from stage2 onwards. overrides = self: super: { - binutils-unwrapped = super.binutils-unwrapped.override { - enableGold = false; - }; inherit (prevStage) ccWrapperStdenv gcc-unwrapped From 053f02f232a7ca7cb23ca75335a07808c2a95ff9 Mon Sep 17 00:00:00 2001 From: Aliaksandr Date: Thu, 14 May 2026 01:38:37 +0300 Subject: [PATCH 3/7] stdenv: linux: drop dead dejagnu.doCheck=false override from stage2 dejagnu is never demand-built in the bootstrap closure (verified via `nix-store --query --requisites | grep dejagnu` returning empty on master). The override existed but the resulting derivation was never referenced by anything stage2+ actually builds. Verified by drv-hash equality: stdenv.drvPath is unchanged (q2xn5647kadsgpz40xcmjssa0pmdmiwi-stdenv-linux.drv). --- pkgs/stdenv/linux/default.nix | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 511248c81957..d0b55753569d 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -458,9 +458,6 @@ in texinfo which ; - dejagnu = super.dejagnu.overrideAttrs (a: { - doCheck = false; - }); # Avoids infinite recursion, as this is in the build-time dependencies of libc. libiconv = self.libcIconv prevStage.libc; From 4df33765698ad9b6ff28e2eb958f3971e23d1065 Mon Sep 17 00:00:00 2001 From: Aliaksandr Date: Thu, 14 May 2026 06:59:50 +0300 Subject: [PATCH 4/7] stdenv: linux: inherit nukeReferences through xgcc/stage2/stage3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit nukeReferences was rebuilt at every stage where it appeared (xgcc, stage2, stage3 — 3 redundant builds beyond stage1's initial build). It is used only at build time (to scrub references from libidn2/libunistring at stage2), never appears in the final stdenv's runtime closure, and its outputs are not propagated into other final-closure derivations. Adding it to the inherit list at xgcc, stage2, and stage3 collapses the chain to a single stage1 build. Stage4 still produces its own nukeReferences through the regular package set; that one is unused by the final stdenv. Build-only dependency, so this is safe with respect to the `disallowedRequisites` check on the final stdenv-linux. --- pkgs/stdenv/linux/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index d0b55753569d..61b4a996b03e 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -343,6 +343,7 @@ in gnum4 perl patchelf + nukeReferences ; ${localSystem.libc} = prevStage.${localSystem.libc}; gmp = super.gmp.override { cxx = false; }; @@ -457,6 +458,7 @@ in bison texinfo which + nukeReferences ; # Avoids infinite recursion, as this is in the build-time dependencies of libc. @@ -565,6 +567,7 @@ in libidn2 libunistring libxcrypt + nukeReferences ; # We build a special copy of libgmp which doesn't use libstdc++, because # xgcc++'s libstdc++ references the bootstrap-files (which is what From f40b936a8643c4f9b7a178e2fc231c45579fd630 Mon Sep 17 00:00:00 2001 From: Aliaksandr Date: Thu, 14 May 2026 07:00:07 +0300 Subject: [PATCH 5/7] stdenv: linux: inherit autoconf269 at stage2/stage3 autoconf269 was being rebuilt at stages 2 and 3. It is used only as a native build input (to regenerate `configure` scripts in autotools-using packages); its outputs never appear in the final stdenv's runtime closure. Inheriting it from prevStage at stage2 and stage3 collapses 2 -> 1 build. Build-only dependency, safe with respect to the `disallowedRequisites` check on the final stdenv-linux. --- pkgs/stdenv/linux/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 61b4a996b03e..e9116d03be92 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -459,6 +459,7 @@ in texinfo which nukeReferences + autoconf269 ; # Avoids infinite recursion, as this is in the build-time dependencies of libc. @@ -568,6 +569,7 @@ in libunistring libxcrypt nukeReferences + autoconf269 ; # We build a special copy of libgmp which doesn't use libstdc++, because # xgcc++'s libstdc++ references the bootstrap-files (which is what From dcda21b1556f0b3618dc8f7bd196eaab1fd5089c Mon Sep 17 00:00:00 2001 From: Aliaksandr Date: Thu, 14 May 2026 07:00:22 +0300 Subject: [PATCH 6/7] stdenv: linux: inherit python3Minimal at stage3/stage4 python3Minimal was being rebuilt at stages 3 and 4. It is used only as a native build input (e.g. meson, glib build helpers); its outputs do not appear in the final stdenv's runtime closure. Inheriting from prevStage at stage3 and stage4 collapses 2 -> 1 build. Build-only dependency, safe with respect to the `disallowedRequisites` check on the final stdenv-linux. --- pkgs/stdenv/linux/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index e9116d03be92..80802992360d 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -570,6 +570,7 @@ in libxcrypt nukeReferences autoconf269 + python3Minimal ; # We build a special copy of libgmp which doesn't use libstdc++, because # xgcc++'s libstdc++ references the bootstrap-files (which is what @@ -634,6 +635,7 @@ in linuxHeaders libidn2 libunistring + python3Minimal ; ${localSystem.libc} = prevStage.${localSystem.libc}; # Since this is the first fresh build of binutils since stage2, our own runtimeShell will be used. From 1d37095ba040f5f6a0cad5b4f9356a55824d394a Mon Sep 17 00:00:00 2001 From: Aliaksandr Date: Thu, 14 May 2026 08:38:09 +0300 Subject: [PATCH 7/7] stdenv: linux: inherit libxcrypt at xgcc/stage2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libxcrypt was built twice (xgcc and stage2). Adding it to the inherit list at xgcc and stage2 chains it through: stage1 produces the single build, xgcc/stage2/stage3 inherit. Total bootstrap-stage builds: 2 -> 1. libxcrypt is build-time-only — it is needed at build time by tools that support libcrypt-style password hashing, but its `out` is not in the final stdenv runtime closure (glibc no longer depends on libxcrypt at runtime; applications that need it link directly). Safe with respect to the `disallowedRequisites` check on the final stdenv-linux. --- pkgs/stdenv/linux/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 80802992360d..34fdac07cff5 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -344,6 +344,7 @@ in perl patchelf nukeReferences + libxcrypt ; ${localSystem.libc} = prevStage.${localSystem.libc}; gmp = super.gmp.override { cxx = false; }; @@ -460,6 +461,7 @@ in which nukeReferences autoconf269 + libxcrypt ; # Avoids infinite recursion, as this is in the build-time dependencies of libc.