2024-06-30 08:16:52 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
localSystem,
|
|
|
|
crossSystem,
|
|
|
|
config,
|
|
|
|
overlays,
|
|
|
|
crossOverlays ? [ ],
|
2024-05-02 00:46:19 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
bootStages = import ../. {
|
|
|
|
inherit lib localSystem overlays;
|
|
|
|
|
|
|
|
crossSystem = localSystem;
|
2024-06-30 08:16:52 +00:00
|
|
|
crossOverlays = [ ];
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
# Ignore custom stdenvs when cross compiling for compatibility
|
|
|
|
config = builtins.removeAttrs config [ "replaceStdenv" ];
|
|
|
|
};
|
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
in
|
|
|
|
lib.init bootStages
|
|
|
|
++ [
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
# Regular native packages
|
2024-06-30 08:16:52 +00:00
|
|
|
(
|
|
|
|
somePrevStage:
|
|
|
|
lib.last bootStages somePrevStage
|
|
|
|
// {
|
|
|
|
# It's OK to change the built-time dependencies
|
|
|
|
allowCustomOverrides = true;
|
|
|
|
}
|
|
|
|
)
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
# Build tool Packages
|
|
|
|
(vanillaPackages: {
|
|
|
|
inherit config overlays;
|
|
|
|
selfBuild = false;
|
|
|
|
stdenv =
|
|
|
|
assert vanillaPackages.stdenv.buildPlatform == localSystem;
|
|
|
|
assert vanillaPackages.stdenv.hostPlatform == localSystem;
|
|
|
|
assert vanillaPackages.stdenv.targetPlatform == localSystem;
|
|
|
|
vanillaPackages.stdenv.override { targetPlatform = crossSystem; };
|
|
|
|
# It's OK to change the built-time dependencies
|
|
|
|
allowCustomOverrides = true;
|
|
|
|
})
|
|
|
|
|
|
|
|
# Run Packages
|
2024-06-30 08:16:52 +00:00
|
|
|
(
|
|
|
|
buildPackages:
|
|
|
|
let
|
|
|
|
adaptStdenv = if crossSystem.isStatic then buildPackages.stdenvAdapters.makeStatic else lib.id;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
inherit config;
|
|
|
|
overlays = overlays ++ crossOverlays;
|
|
|
|
selfBuild = false;
|
|
|
|
stdenv = adaptStdenv (
|
|
|
|
buildPackages.stdenv.override (old: rec {
|
|
|
|
buildPlatform = localSystem;
|
|
|
|
hostPlatform = crossSystem;
|
|
|
|
targetPlatform = crossSystem;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
# Prior overrides are surely not valid as packages built with this run on
|
|
|
|
# a different platform, and so are disabled.
|
|
|
|
overrides = _: _: { };
|
|
|
|
extraBuildInputs =
|
|
|
|
[ ] # Old ones run on wrong platform
|
|
|
|
++ lib.optionals hostPlatform.isDarwin [
|
|
|
|
buildPackages.targetPackages.darwin.apple_sdk.frameworks.CoreFoundation
|
|
|
|
];
|
|
|
|
allowedRequisites = null;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
hasCC = !targetPlatform.isGhcjs;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
cc =
|
|
|
|
if crossSystem.useiOSPrebuilt or false then
|
|
|
|
buildPackages.darwin.iosSdkPkgs.clang
|
|
|
|
else if crossSystem.useAndroidPrebuilt or false then
|
|
|
|
buildPackages."androidndkPkgs_${crossSystem.ndkVer}".clang
|
|
|
|
else if
|
|
|
|
targetPlatform.isGhcjs
|
|
|
|
# Need to use `throw` so tryEval for splicing works, ugh. Using
|
|
|
|
# `null` or skipping the attribute would cause an eval failure
|
|
|
|
# `tryEval` wouldn't catch, wrecking accessing previous stages
|
|
|
|
# when there is a C compiler and everything should be fine.
|
|
|
|
then
|
|
|
|
throw "no C compiler provided for this platform"
|
|
|
|
else if crossSystem.isDarwin then
|
|
|
|
buildPackages.llvmPackages.libcxxClang
|
|
|
|
else if crossSystem.useLLVM or false then
|
|
|
|
buildPackages.llvmPackages.clang
|
|
|
|
else
|
|
|
|
buildPackages.gcc;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
extraNativeBuildInputs =
|
|
|
|
old.extraNativeBuildInputs
|
|
|
|
++ lib.optionals (hostPlatform.isLinux && !buildPlatform.isLinux) [ buildPackages.patchelf ]
|
|
|
|
++ lib.optional (
|
|
|
|
let
|
|
|
|
f =
|
|
|
|
p:
|
|
|
|
!p.isx86
|
|
|
|
|| builtins.elem p.libc [
|
|
|
|
"musl"
|
|
|
|
"wasilibc"
|
|
|
|
"relibc"
|
|
|
|
]
|
|
|
|
|| p.isiOS
|
|
|
|
|| p.isGenode;
|
|
|
|
in
|
|
|
|
f hostPlatform && !(f buildPlatform)
|
|
|
|
) buildPackages.updateAutotoolsGnuConfigScriptsHook;
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
)
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
]
|