stdenv/generic: memoise passing config to mkDerivation unless overriden

This commit is contained in:
Eman Resu
2026-05-28 13:24:29 -04:00
parent 2c9c2fd429
commit 159a6daf6b
6 changed files with 37 additions and 23 deletions
+3 -6
View File
@@ -27,6 +27,7 @@ assert crossSystem == localSystem;
let
inherit (localSystem) system;
genericStdenv = import ../generic { defaultConfig = config; };
llvmVersion = "21"; # This needs to be updated when the default LLVM version is changed.
sdkMajorVersion = lib.versions.major localSystem.darwinSdkVersion;
@@ -104,15 +105,13 @@ let
bashNonInteractive = prevStage.bashNonInteractive or bootstrapTools;
thisStdenv = import ../generic {
thisStdenv = genericStdenv {
name = "${name}-stdenv-darwin";
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit config;
extraBuildInputs = [ prevStage.apple-sdk ];
inherit extraNativeBuildInputs;
@@ -975,15 +974,13 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
in
{
inherit config overlays;
stdenv = import ../generic {
stdenv = genericStdenv {
name = "stdenv-darwin";
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit config;
preHook = ''
${commonPreHook}
stripDebugFlags="-S" # llvm-strip does not support "-p" for Mach-O
+4 -4
View File
@@ -21,6 +21,8 @@
assert crossSystem == localSystem;
let
genericStdenv = import ../generic { defaultConfig = config; };
inherit (localSystem) system;
mkExtraBuildCommands0 = cc: ''
rsrc="$out/resource-root"
@@ -383,9 +385,8 @@ let
bsdcp
];
shell = "${prevStage.bashNonInteractive}/bin/bash";
stdenvNoCC = import ../generic {
stdenvNoCC = genericStdenv {
inherit
config
initialPath
shell
fetchurlBoot
@@ -401,9 +402,8 @@ let
inherit (prevStage) curl;
inherit (config) hashedMirrors rewriteURL;
};
stdenv = import ../generic {
stdenv = genericStdenv {
inherit
config
initialPath
shell
fetchurlBoot
+18 -3
View File
@@ -1,6 +1,20 @@
{
defaultConfig ? null,
}@args:
let
lib = import ../../../lib;
# By taking defaultConfig early, we can cache the result of calling
# make-derivation.nix with config, which leads to more memoisation between
# bootstrapping stages. We only have to re-call the file with another config
# if stdenv-overridable is actually called with config, otherwise we stick to
# defaultConfig. No stdenvs currently specify a non-default config, but we
# leave it open as a possibility.
makeDerivationFile = import ./make-derivation.nix lib;
makeDerivationFileWithConfig =
assert args ? defaultConfig;
makeDerivationFile args.defaultConfig;
defaultNativeBuildInputs0 = [
../../build-support/setup-hooks/no-broken-symlinks.sh
../../build-support/setup-hooks/audit-tmpdir.sh
@@ -39,7 +53,7 @@ let
allowedRequisites ? null,
extraAttrs ? { },
overrides ? (self: super: { }),
config,
config ? args.defaultConfig,
disallowedRequisites ? [ ],
# The `fetchurl' to use for downloading curl and its dependencies
@@ -83,9 +97,10 @@ let
# This is convenient to have as a parameter so the stdenv "adapters" work better
mkDerivationFromStdenv ?
let
makeDerivationWithConfig = makeDerivationFile config;
makeDerivationWithConfig' =
if argsStdenv ? config then makeDerivationFile config else makeDerivationFileWithConfig;
in
stdenv: (makeDerivationWithConfig stdenv).mkDerivation,
stdenv: (makeDerivationWithConfig' stdenv).mkDerivation,
}:
let
+5 -4
View File
@@ -121,6 +121,8 @@
assert crossSystem == localSystem;
let
genericStdenv = import ../generic { defaultConfig = config; };
inherit (localSystem) system;
isFromNixpkgs = pkg: !(isFromBootstrapFiles pkg);
@@ -174,12 +176,12 @@ let
}:
let
thisStdenv = import ../generic {
thisStdenv = genericStdenv {
name = "${name}-stdenv-linux";
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit config extraNativeBuildInputs;
inherit extraNativeBuildInputs;
inherit (stage0) initialPath;
preHook = ''
# Don't patch #!/interpreter because it leads to retained
@@ -696,13 +698,12 @@ in
assert isBuiltByNixpkgsCompiler prevStage.patchelf;
{
inherit config overlays;
stdenv = import ../generic rec {
stdenv = genericStdenv rec {
name = "stdenv-linux";
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit config;
preHook = commonPreHook;
+3 -2
View File
@@ -10,6 +10,8 @@
assert crossSystem == localSystem;
let
genericStdenv = import ../generic { defaultConfig = config; };
inherit (localSystem) system;
shell =
@@ -105,7 +107,7 @@ let
extraNativeBuildInputs ? [ ],
}:
import ../generic {
genericStdenv {
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
@@ -145,7 +147,6 @@ let
shell
cc
overrides
config
;
};
+4 -4
View File
@@ -9,15 +9,15 @@
}:
assert crossSystem == localSystem;
let
genericStdenv = import ../generic { defaultConfig = config; };
in
bootStages
++ [
(prevStage: {
inherit config overlays;
stdenv = import ../generic rec {
inherit config;
stdenv = genericStdenv rec {
inherit (prevStage.stdenv) buildPlatform hostPlatform targetPlatform;
preHook = ''