From 0198f43efbe15e98a23cd9f3e7eb2978aa38f68f Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Sun, 14 Apr 2024 15:20:40 +0200 Subject: [PATCH] =?UTF-8?q?stdenv:=20consistently=20use=20`self:=20super:?= =?UTF-8?q?=20=E2=80=A6`=20for=20bootstrapping=20overlays?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- pkgs/stdenv/linux/default.nix | 8 ++++---- pkgs/stdenv/native/default.nix | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 9d13eb0b8e17..0e1852805cfd 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -328,12 +328,12 @@ in assert isBuiltByBootstrapFilesCompiler prevStage.patchelf; stageFun prevStage { name = "bootstrap-stage-xgcc"; - overrides = final: prev: { + overrides = self: super: { inherit (prevStage) ccWrapperStdenv coreutils gnugrep gettext bison texinfo zlib gnum4 perl patchelf; ${localSystem.libc} = getLibc prevStage; - gmp = prev.gmp.override { cxx = false; }; + gmp = super.gmp.override { cxx = false; }; gcc-unwrapped = - (prev.gcc-unwrapped.override (commonGccOverrides // { + (super.gcc-unwrapped.override (commonGccOverrides // { # The most logical name for this package would be something like # "gcc-stage1". Unfortunately "stage" is already reserved for the # layers of stdenv, so using "stage" in the name of this package @@ -376,7 +376,7 @@ in # configureFlags = (a.configureFlags or []) ++ [ "--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 diff --git a/pkgs/stdenv/native/default.nix b/pkgs/stdenv/native/default.nix index de447f4e7567..242bf9d1b3f9 100644 --- a/pkgs/stdenv/native/default.nix +++ b/pkgs/stdenv/native/default.nix @@ -152,7 +152,7 @@ in inherit config overlays; stdenv = makeStdenv { inherit (prevStage) cc fetchurl; - overrides = prev: final: { inherit (prevStage) fetchurl; }; + overrides = self: super: { inherit (prevStage) fetchurl; }; } // { inherit (prevStage) fetchurl; };