mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-08-26 18:24:53 +00:00
Select local bootstrap stages once and pass them to custom and cross stage composition. Assisted-by: codex with gpt-5.6-sol-high
133 lines
3.4 KiB
Nix
133 lines
3.4 KiB
Nix
{ lib, pkgs, ... }:
|
|
let
|
|
nixpkgsFun = import ../../top-level;
|
|
in
|
|
lib.recurseIntoAttrs {
|
|
platformEquality =
|
|
let
|
|
configsLocal = [
|
|
# crossSystem is implicitly set to localSystem.
|
|
{
|
|
localSystem = {
|
|
system = "x86_64-linux";
|
|
};
|
|
}
|
|
{
|
|
localSystem = {
|
|
system = "aarch64-linux";
|
|
};
|
|
crossSystem = null;
|
|
}
|
|
# Both systems explicitly set to the same string.
|
|
{
|
|
localSystem = {
|
|
system = "x86_64-linux";
|
|
};
|
|
crossSystem = {
|
|
system = "x86_64-linux";
|
|
};
|
|
}
|
|
# Vendor and ABI inferred from system double.
|
|
{
|
|
localSystem = {
|
|
system = "aarch64-linux";
|
|
};
|
|
crossSystem = {
|
|
config = "aarch64-unknown-linux-gnu";
|
|
};
|
|
}
|
|
];
|
|
configsCross = [
|
|
# GNU is inferred from double, but config explicitly requests musl.
|
|
{
|
|
localSystem = {
|
|
system = "aarch64-linux";
|
|
};
|
|
crossSystem = {
|
|
config = "aarch64-unknown-linux-musl";
|
|
};
|
|
}
|
|
# Cross-compile from AArch64 to x86-64.
|
|
{
|
|
localSystem = {
|
|
system = "aarch64-linux";
|
|
};
|
|
crossSystem = {
|
|
system = "x86_64-unknown-linux-gnu";
|
|
};
|
|
}
|
|
];
|
|
|
|
pkgsLocal = map nixpkgsFun configsLocal;
|
|
pkgsCross = map nixpkgsFun configsCross;
|
|
in
|
|
assert lib.all (p: p.stdenv.buildPlatform == p.stdenv.hostPlatform) pkgsLocal;
|
|
assert lib.all (p: p.stdenv.buildPlatform != p.stdenv.hostPlatform) pkgsCross;
|
|
pkgs.emptyFile;
|
|
|
|
# appendOverlays must preserve splicing so that cross-compilation
|
|
# works in NixOS modules (which go through appendOverlays via nixpkgs.nix).
|
|
appendOverlaysPreservesSplicing =
|
|
let
|
|
cross = nixpkgsFun {
|
|
localSystem = {
|
|
system = "x86_64-linux";
|
|
};
|
|
crossSystem = {
|
|
system = "aarch64-linux";
|
|
};
|
|
};
|
|
appended = cross.appendOverlays [ ];
|
|
in
|
|
assert cross.makeWrapper ? __spliced;
|
|
assert appended.makeWrapper ? __spliced;
|
|
pkgs.emptyFile;
|
|
|
|
replaceStdenv =
|
|
let
|
|
replacedPkgs = nixpkgsFun {
|
|
localSystem = {
|
|
inherit (pkgs.stdenv.buildPlatform) system;
|
|
};
|
|
config.replaceStdenv =
|
|
{ pkgs }:
|
|
assert !(pkgs.config ? replaceStdenv);
|
|
pkgs.stdenv
|
|
// {
|
|
wasReplaced = true;
|
|
};
|
|
};
|
|
in
|
|
assert replacedPkgs.stdenv.wasReplaced;
|
|
pkgs.emptyFile;
|
|
|
|
replaceStdenvIgnoredForCross =
|
|
let
|
|
crossPkgs = nixpkgsFun {
|
|
localSystem = {
|
|
system = "x86_64-linux";
|
|
};
|
|
crossSystem = {
|
|
system = "aarch64-linux";
|
|
};
|
|
config.replaceStdenv = _: throw "replaceStdenv must be ignored when cross compiling";
|
|
};
|
|
in
|
|
assert crossPkgs.stdenv.buildPlatform != crossPkgs.stdenv.hostPlatform;
|
|
pkgs.emptyFile;
|
|
|
|
massRebuildVariantComposition =
|
|
let
|
|
variants = [
|
|
"pkgsChecked"
|
|
"pkgsParallel"
|
|
"pkgsStrict"
|
|
"pkgsStructured"
|
|
];
|
|
all = lib.getAttrFromPath variants pkgs;
|
|
all-reversed = lib.getAttrFromPath (lib.reverseList variants) pkgs;
|
|
in
|
|
assert pkgs.config.allowVariants -> (all.hello == all-reversed.hello);
|
|
pkgs.emptyFile;
|
|
}
|