2024-07-27 16:57:03 +00:00
|
|
|
{
|
|
|
|
pkgspath ? ../../..,
|
|
|
|
test-pkgspath ? pkgspath,
|
|
|
|
localSystem ? {
|
|
|
|
system = builtins.currentSystem;
|
|
|
|
},
|
|
|
|
crossSystem ? null,
|
|
|
|
bootstrapFiles ? null,
|
2021-04-19 18:44:10 +00:00
|
|
|
}:
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2024-07-27 16:57:03 +00:00
|
|
|
let
|
2024-07-27 17:45:45 +00:00
|
|
|
cross = if crossSystem != null then { inherit crossSystem; } else { };
|
|
|
|
|
|
|
|
custom-bootstrap =
|
|
|
|
if bootstrapFiles != null then
|
|
|
|
{
|
|
|
|
stdenvStages =
|
|
|
|
args:
|
|
|
|
let
|
|
|
|
args' = args // {
|
|
|
|
bootstrapFiles = bootstrapFiles;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
(import "${pkgspath}/pkgs/stdenv/darwin" args');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ };
|
2024-07-27 16:57:03 +00:00
|
|
|
|
|
|
|
pkgs = import pkgspath ({ inherit localSystem; } // cross // custom-bootstrap);
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2024-07-27 17:28:17 +00:00
|
|
|
build = pkgs.callPackage ./stdenv-bootstrap-tools.nix { };
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2024-07-27 17:11:42 +00:00
|
|
|
bootstrapTools = pkgs.callPackage ./bootstrap-tools.nix {
|
2024-07-27 17:48:42 +00:00
|
|
|
inherit (build.bootstrapFiles) bootstrapTools unpack;
|
2023-01-01 19:24:02 +00:00
|
|
|
};
|
2015-02-18 05:24:16 +00:00
|
|
|
|
2024-07-27 17:17:11 +00:00
|
|
|
test = pkgs.callPackage ./test-bootstrap-tools.nix { inherit bootstrapTools; };
|
2016-01-04 02:47:09 +00:00
|
|
|
|
|
|
|
# The ultimate test: bootstrap a whole stdenv from the tools specified above and get a package set out of it
|
2024-03-20 16:28:21 +00:00
|
|
|
# eg: nix-build -A freshBootstrapTools.test-pkgs.stdenv
|
2016-12-04 01:21:07 +00:00
|
|
|
test-pkgs = import test-pkgspath {
|
2020-11-19 08:28:00 +00:00
|
|
|
# if the bootstrap tools are for another platform, we should be testing
|
|
|
|
# that platform.
|
stdenvBootstrapTools: inherit {cross,local}System
It's expected that attributes in the top-level package set will all use
that package set, but this wasn't the case for the bootstrap tools.
This led some very confusing behaviour:
- pkgsMusl.stdenvBootstrapTools would build glibc bootstrap tools
- stdenvBootstrapTools was _always_ cross compiled, even if
Nixpkgs wasn't, because it always set crossSystem. This also didn't
match the behaviour of using make-bootstrap-tools.nix as an
entrypoint, where crossSystem would default to null.
For the Linux stdenv, I've made the ideal fix, which is to make pkgs an
argument rather than taking the arguments for pkgs, and then
re-importing it. This means it'll always use exactly the same package
set that's calling it, and should also mean faster eval due to not
importing Nixpkgs twice.
The Darwin stdenv is more complicated, and I'm not able to easily test
it, so I wasn't confident in making the same fix there. Instead, I've
just made sure crossSystem and localSystem are set to the correct values
so they're not always cross compiled and match the parent package set's.
It would still be preferable if somebody could make Darwin's
make-bootstrap-tools.nix take pkgs as an argument, rather than all the
arguments for pkgs.
2022-05-30 14:16:22 +00:00
|
|
|
localSystem = if crossSystem != null then crossSystem else localSystem;
|
2020-11-19 08:28:00 +00:00
|
|
|
|
2024-07-27 17:45:45 +00:00
|
|
|
stdenvStages =
|
|
|
|
args:
|
|
|
|
let
|
|
|
|
args' = args // {
|
2024-07-27 17:48:42 +00:00
|
|
|
inherit (build) bootstrapFiles;
|
2024-07-27 17:45:45 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
(import (test-pkgspath + "/pkgs/stdenv/darwin") args');
|
2016-01-04 02:47:09 +00:00
|
|
|
};
|
2024-07-27 17:48:42 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
inherit
|
|
|
|
build
|
|
|
|
bootstrapTools
|
|
|
|
test
|
|
|
|
test-pkgs
|
|
|
|
;
|
|
|
|
|
|
|
|
inherit (build) bootstrapFiles;
|
2015-02-18 05:24:16 +00:00
|
|
|
}
|