freshBootstrapTools.bootstrapTools: extract as a sort of package

This commit is contained in:
Philip Taron
2024-08-04 17:36:45 +02:00
committed by gador
parent 921c21f4a9
commit 1be059d60a
3 changed files with 45 additions and 28 deletions
@@ -0,0 +1,35 @@
{
lib,
libc,
config,
system,
bootstrapFiles,
isFromBootstrapFiles ? false,
}:
let
maybeDenoteProvenance = lib.optionalAttrs isFromBootstrapFiles {
passthru = {
inherit isFromBootstrapFiles;
};
};
maybeContentAddressed = lib.optionalAttrs config.contentAddressedByDefault {
__contentAddressed = true;
outputHashAlgo = "sha256";
outputHashMode = "recursive";
};
args = {
inherit system bootstrapFiles;
extraAttrs = maybeContentAddressed;
};
result =
if libc == "glibc" then
import ./glibc.nix args
else if libc == "musl" then
import ./musl.nix args
else
throw "unsupported libc";
in
result // maybeDenoteProvenance
+5 -8
View File
@@ -139,14 +139,11 @@ let
# Download and unpack the bootstrap tools (coreutils, GCC, Glibc, ...).
bootstrapTools = (import (if localSystem.libc == "musl" then ./bootstrap-tools/musl.nix else ./bootstrap-tools/glibc.nix) {
inherit system bootstrapFiles;
extraAttrs = lib.optionalAttrs config.contentAddressedByDefault {
__contentAddressed = true;
outputHashAlgo = "sha256";
outputHashMode = "recursive";
};
}) // { passthru.isFromBootstrapFiles = true; };
bootstrapTools = import ./bootstrap-tools {
inherit (localSystem) libc system;
inherit lib bootstrapFiles config;
isFromBootstrapFiles = true;
};
getLibc = stage: stage.${localSystem.libc};
+5 -20
View File
@@ -49,26 +49,11 @@ rec {
inherit (build) bootstrapFiles;
bootstrapTools =
let extraAttrs = lib.optionalAttrs
config.contentAddressedByDefault
{
__contentAddressed = true;
outputHashAlgo = "sha256";
outputHashMode = "recursive";
};
in
if (stdenv.hostPlatform.libc == "glibc") then
import ./bootstrap-tools/glibc.nix {
inherit (stdenv.buildPlatform) system; # Used to determine where to build
inherit bootstrapFiles extraAttrs;
}
else if (stdenv.hostPlatform.libc == "musl") then
import ./bootstrap-tools/musl.nix {
inherit (stdenv.buildPlatform) system; # Used to determine where to build
inherit bootstrapFiles extraAttrs;
}
else throw "unsupported libc";
bootstrapTools = import ./bootstrap-tools {
inherit (stdenv.buildPlatform) system; # Used to determine where to build
inherit (stdenv.hostPlatform) libc;
inherit lib bootstrapFiles config;
};
test = pkgs.callPackage ./test-bootstrap-tools.nix {
inherit bootstrapTools;