Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 localSystem,
4 crossSystem,
5 config,
6 overlays,
7 crossOverlays ? [ ],
8}:
9
10let
11 bootStages = import ../. {
12 inherit lib localSystem overlays;
13
14 crossSystem = localSystem;
15 crossOverlays = [ ];
16
17 # Ignore custom stdenvs when cross compiling for compatibility
18 # Use replaceCrossStdenv instead.
19 config = builtins.removeAttrs config [ "replaceStdenv" ];
20 };
21
22in
23lib.init bootStages
24++ [
25
26 # Regular native packages
27 (
28 somePrevStage:
29 lib.last bootStages somePrevStage
30 // {
31 # It's OK to change the built-time dependencies
32 allowCustomOverrides = true;
33 }
34 )
35
36 # Build tool Packages
37 (vanillaPackages: {
38 inherit config overlays;
39 selfBuild = false;
40 stdenv =
41 assert vanillaPackages.stdenv.buildPlatform == localSystem;
42 assert vanillaPackages.stdenv.hostPlatform == localSystem;
43 assert vanillaPackages.stdenv.targetPlatform == localSystem;
44 vanillaPackages.stdenv.override { targetPlatform = crossSystem; };
45 # It's OK to change the built-time dependencies
46 allowCustomOverrides = true;
47 })
48
49 # Run Packages
50 (
51 buildPackages:
52 let
53 adaptStdenv = if crossSystem.isStatic then buildPackages.stdenvAdapters.makeStatic else lib.id;
54 stdenvNoCC = adaptStdenv (
55 buildPackages.stdenv.override (old: rec {
56 buildPlatform = localSystem;
57 hostPlatform = crossSystem;
58 targetPlatform = crossSystem;
59
60 # Prior overrides are surely not valid as packages built with this run on
61 # a different platform, and so are disabled.
62 overrides = _: _: { };
63 extraBuildInputs = [ ]; # Old ones run on wrong platform
64 allowedRequisites = null;
65
66 cc = null;
67 hasCC = false;
68
69 extraNativeBuildInputs =
70 old.extraNativeBuildInputs
71 ++ lib.optionals (hostPlatform.isLinux && !buildPlatform.isLinux) [ buildPackages.patchelf ]
72 ++ lib.optional (
73 let
74 f =
75 p:
76 !p.isx86
77 || builtins.elem p.libc [
78 "musl"
79 "wasilibc"
80 "relibc"
81 ]
82 || p.isiOS
83 || p.isGenode;
84 in
85 f hostPlatform && !(f buildPlatform)
86 ) buildPackages.updateAutotoolsGnuConfigScriptsHook;
87 })
88 );
89 in
90 {
91 inherit config;
92 overlays = overlays ++ crossOverlays;
93 selfBuild = false;
94 inherit stdenvNoCC;
95 stdenv =
96 let
97 inherit (stdenvNoCC) hostPlatform targetPlatform;
98 baseStdenv = stdenvNoCC.override {
99 # Old ones run on wrong platform
100 extraBuildInputs = lib.optionals hostPlatform.isDarwin [
101 buildPackages.targetPackages.apple-sdk
102 ];
103
104 hasCC = !stdenvNoCC.targetPlatform.isGhcjs;
105
106 cc =
107 if crossSystem.useiOSPrebuilt or false then
108 buildPackages.darwin.iosSdkPkgs.clang
109 else if crossSystem.useAndroidPrebuilt or false then
110 buildPackages."androidndkPkgs_${crossSystem.androidNdkVersion}".clang
111 else if
112 targetPlatform.isGhcjs
113 # Need to use `throw` so tryEval for splicing works, ugh. Using
114 # `null` or skipping the attribute would cause an eval failure
115 # `tryEval` wouldn't catch, wrecking accessing previous stages
116 # when there is a C compiler and everything should be fine.
117 then
118 throw "no C compiler provided for this platform"
119 else if crossSystem.isDarwin then
120 buildPackages.llvmPackages.libcxxClang
121 else if crossSystem.useLLVM or false then
122 buildPackages.llvmPackages.clang
123 else if crossSystem.useZig or false then
124 buildPackages.zig.cc
125 else if crossSystem.useArocc or false then
126 buildPackages.arocc
127 else
128 buildPackages.gcc;
129
130 };
131 in
132 if config ? replaceCrossStdenv then
133 config.replaceCrossStdenv { inherit buildPackages baseStdenv; }
134 else
135 baseStdenv;
136 }
137 )
138
139]