stdenv: consistently use self: super: … for bootstrapping overlays

As of late, `final: prev: …` for overlays has become more prevalent in
newer code. This is also exhibited in some code (presumably added
recently) in stdenv. This change is not about any merits or demerits of
any naming convention, but rather aims to make the nomenclature in
stdenv bootstrapping consistent to lessen confusion.

I've chosen to stick to `self: super: …` convention because:

1. It is more common in the code as it stands.

2. Using `final: prev: …` makes the code more confusing, als it causes
   `prev` to be in scope alongside `prevStage`. `prevStage` actually
   bears no relation to `prev` even though their naming suggests it,
   making it easy to confuse them (the former is the (final) package set
   of the previous stage while the latter is just the `prev`/`super` of
   the overlay “chaining” on a completely fresh package set, i.e. `prev`
   doesn't even relate to the previous stage's `overrides` argument).

This change also corrects a naming error in stdenv/native which had no
effect, as the variables were unused.
This commit is contained in:
sternenseemann 2024-04-14 15:20:40 +02:00
parent fde3861f21
commit 0198f43efb
2 changed files with 5 additions and 5 deletions

View file

@ -328,12 +328,12 @@ in
assert isBuiltByBootstrapFilesCompiler prevStage.patchelf; assert isBuiltByBootstrapFilesCompiler prevStage.patchelf;
stageFun prevStage { stageFun prevStage {
name = "bootstrap-stage-xgcc"; name = "bootstrap-stage-xgcc";
overrides = final: prev: { overrides = self: super: {
inherit (prevStage) ccWrapperStdenv coreutils gnugrep gettext bison texinfo zlib gnum4 perl patchelf; inherit (prevStage) ccWrapperStdenv coreutils gnugrep gettext bison texinfo zlib gnum4 perl patchelf;
${localSystem.libc} = getLibc prevStage; ${localSystem.libc} = getLibc prevStage;
gmp = prev.gmp.override { cxx = false; }; gmp = super.gmp.override { cxx = false; };
gcc-unwrapped = gcc-unwrapped =
(prev.gcc-unwrapped.override (commonGccOverrides // { (super.gcc-unwrapped.override (commonGccOverrides // {
# The most logical name for this package would be something like # The most logical name for this package would be something like
# "gcc-stage1". Unfortunately "stage" is already reserved for the # "gcc-stage1". Unfortunately "stage" is already reserved for the
# layers of stdenv, so using "stage" in the name of this package # layers of stdenv, so using "stage" in the name of this package
@ -376,7 +376,7 @@ in
# #
configureFlags = (a.configureFlags or []) ++ [ configureFlags = (a.configureFlags or []) ++ [
"--with-native-system-header-dir=/include" "--with-native-system-header-dir=/include"
"--with-build-sysroot=${lib.getDev final.stdenv.cc.libc}" "--with-build-sysroot=${lib.getDev self.stdenv.cc.libc}"
]; ];
# This is a separate phase because gcc assembles its phase scripts # This is a separate phase because gcc assembles its phase scripts

View file

@ -152,7 +152,7 @@ in
inherit config overlays; inherit config overlays;
stdenv = makeStdenv { stdenv = makeStdenv {
inherit (prevStage) cc fetchurl; inherit (prevStage) cc fetchurl;
overrides = prev: final: { inherit (prevStage) fetchurl; }; overrides = self: super: { inherit (prevStage) fetchurl; };
} // { } // {
inherit (prevStage) fetchurl; inherit (prevStage) fetchurl;
}; };