1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
{
localSystem,
config,
lib,
bootstrapFiles,
}:
let
minbootSupportedSystems = [
"i686-linux"
"x86_64-linux"
];
minbootSupported = builtins.elem localSystem.system minbootSupportedSystems;
checkVersion =
topPackage: bootPackage:
let
versionOk = lib.versionAtLeast topPackage.version bootPackage.version;
in
lib.warnIfNot versionOk
"stdenv stage0: minimal-bootstrap.${bootPackage.pname} ${bootPackage.version} is newer than pkgs.${topPackage.pname} ${topPackage.version}"
versionOk;
in
if minbootSupported then
let
callPackage = lib.callPackageWith { inherit lib config; };
minimal-bootstrap = lib.recurseIntoAttrs (
import ../../os-specific/linux/minimal-bootstrap {
buildPlatform = localSystem;
hostPlatform = localSystem;
inherit lib config;
fetchurl = import ../../build-support/fetchurl/boot.nix {
system = localSystem;
inherit (config) rewriteURL;
};
checkMeta = callPackage ../generic/check-meta.nix { };
}
);
compilerPackage =
if localSystem.libc == "glibc" then
minimal-bootstrap.gcc-glibc
else if localSystem.libc == "musl" then
minimal-bootstrap.gcc-latest
else
throw "Can't bootstrap on ${localSystem.config}";
libcPackage =
if localSystem.libc == "glibc" then
minimal-bootstrap.glibc
else if localSystem.libc == "musl" then
minimal-bootstrap.musl-static
else
throw "Can't bootstrap on ${localSystem.config}";
in
assert minimal-bootstrap.bash-static.passthru.isFromMinBootstrap or false; # sanity check
{
inherit minimal-bootstrap;
isMinimalBootstrap = true;
dummyStdenv = {
name = "bootstrap-stage0";
overrides = self: super: {
# We thread stage0's stdenv through under this name so downstream stages
# can use it for wrapping gcc too. This way, downstream stages don't need
# to refer to this stage directly, which violates the principle that each
# stage should only access the stage that came before it.
ccWrapperStdenv = self.stdenv;
# The Glibc include directory cannot have the same prefix as the
# GCC include directory, since GCC gets confused otherwise (it
# will search the Glibc headers before the GCC headers). So
# create a dummy Glibc here, which will be used in the stdenv of
# stage1.
${localSystem.libc} = self.stdenv.mkDerivation {
pname = "bootstrap-stage0-${localSystem.libc}";
strictDeps = true;
version = "minimal-bootstrap";
enableParallelBuilding = true;
buildCommand = ''
mkdir -p $out
ln -s ${libcPackage}/lib $out/lib
ln -s ${libcPackage}/include $out/include
'';
__structuredAttrs = true;
passthru.isFromBootstrapFiles = true;
};
gcc-unwrapped = compilerPackage;
binutils = import ../../build-support/bintools-wrapper {
name = "bootstrap-stage0-binutils-wrapper";
nativeTools = false;
nativeLibc = false;
expand-response-params = "";
inherit lib;
inherit (self)
stdenvNoCC
coreutils
gnugrep
libc
;
bintools = minimal-bootstrap.binutils-static;
runtimeShell = "${minimal-bootstrap.bash}/bin/bash";
};
coreutils = minimal-bootstrap.coreutils-static;
gnugrep = minimal-bootstrap.gnugrep-static;
};
};
bash = minimal-bootstrap.bash-static;
checkBootstrapPackages =
toplevelPkgs:
with minimal-bootstrap;
(localSystem.libc == "glibc" -> checkVersion toplevelPkgs.glibc glibc)
&& checkVersion toplevelPkgs.musl musl-static
&& checkVersion toplevelPkgs.bash bash-static
&& checkVersion toplevelPkgs.binutils binutils-static
&& checkVersion toplevelPkgs.bzip2 bzip2-static
&& checkVersion toplevelPkgs.gcc compilerPackage
&& checkVersion toplevelPkgs.coreutils coreutils-static
&& checkVersion toplevelPkgs.diffutils diffutils-static
&& checkVersion toplevelPkgs.findutils findutils-static
&& checkVersion toplevelPkgs.gawk gawk-static
&& checkVersion toplevelPkgs.gnugrep gnugrep-static
&& checkVersion toplevelPkgs.gnumake gnumake-static
&& checkVersion toplevelPkgs.gnupatch gnupatch-static
&& checkVersion toplevelPkgs.gnused gnused-static
&& checkVersion toplevelPkgs.gnutar gnutar-static
&& checkVersion toplevelPkgs.gzip gzip-static
&& checkVersion toplevelPkgs.patchelf patchelf-static
&& checkVersion toplevelPkgs.xz xz-static;
initialPath = with minimal-bootstrap; [
bash-static
binutils-static
bzip2-static
compilerPackage
coreutils-static
diffutils-static
findutils-static
gawk-static
gnugrep-static
gnumake-static
gnupatch-static
gnused-static
gnutar-static
gzip-static
patchelf-static
xz-static
];
disallowedInFinalStdenv = lib.attrsets.catAttrs "out" (
builtins.filter (drv: lib.attrsets.isDerivation drv) (builtins.attrValues minimal-bootstrap)
);
}
else
let
# Download and unpack the bootstrap tools (coreutils, GCC, Glibc, ...).
bootstrapTools = import ./bootstrap-tools {
inherit (localSystem) libc system;
inherit lib bootstrapFiles config;
isFromBootstrapFiles = true;
};
in
assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
{
inherit bootstrapTools;
isMinimalBootstrap = false;
dummyStdenv = {
name = "bootstrap-stage0";
overrides = self: super: {
# We thread stage0's stdenv through under this name so downstream stages
# can use it for wrapping gcc too. This way, downstream stages don't need
# to refer to this stage directly, which violates the principle that each
# stage should only access the stage that came before it.
ccWrapperStdenv = self.stdenv;
# The Glibc include directory cannot have the same prefix as the
# GCC include directory, since GCC gets confused otherwise (it
# will search the Glibc headers before the GCC headers). So
# create a dummy Glibc here, which will be used in the stdenv of
# stage1.
${localSystem.libc} = self.stdenv.mkDerivation {
pname = "bootstrap-stage0-${localSystem.libc}";
strictDeps = true;
version = "bootstrap-tools";
enableParallelBuilding = true;
buildCommand = ''
mkdir -p $out
ln -s ${bootstrapTools}/lib $out/lib
''
+ lib.optionalString (localSystem.libc == "glibc") ''
ln -s ${bootstrapTools}/include-glibc $out/include
''
+ lib.optionalString (localSystem.libc == "musl") ''
ln -s ${bootstrapTools}/include-libc $out/include
'';
__structuredAttrs = true;
passthru.isFromBootstrapFiles = true;
};
gcc-unwrapped = bootstrapTools;
binutils = import ../../build-support/bintools-wrapper {
name = "bootstrap-stage0-binutils-wrapper";
nativeTools = false;
nativeLibc = false;
expand-response-params = "";
inherit lib;
inherit (self)
stdenvNoCC
coreutils
gnugrep
libc
;
bintools = bootstrapTools;
runtimeShell = "${bootstrapTools}/bin/bash";
};
coreutils = bootstrapTools;
gnugrep = bootstrapTools;
};
};
bash = bootstrapTools;
initialPath = [ bootstrapTools ];
disallowedInFinalStdenv = [ bootstrapTools ];
# no-op. We don't have eval-time version information on bootstrap packages here.
checkBootstrapPackages = _: true;
}
|