···30<itemizedlist>
31 <listitem>
32 <para>
0000000033 <literal>gnome</literal> alias has been removed along with
34 <literal>gtk</literal>, <literal>gtkmm</literal> and several others.
35 Now you need to use versioned attributes, like <literal>gnome3</literal>.
···30<itemizedlist>
31 <listitem>
32 <para>
33+ <literal>stdenv.overrides</literal> is now expected to take <literal>self</literal>
34+ and <literal>super</literal> arguments. See <literal>lib.trivial.extends</literal>
35+ for what those parameters represent.
36+ </para>
37+ </listitem>
38+39+ <listitem>
40+ <para>
41 <literal>gnome</literal> alias has been removed along with
42 <literal>gtk</literal>, <literal>gtkmm</literal> and several others.
43 Now you need to use versioned attributes, like <literal>gnome3</literal>.
···1+# This file defines a single function for booting a package set from a list of
2+# stages. The exact mechanics of that function are defined below; here I
3+# (@Ericson2314) wish to describe the purpose of the abstraction.
4+#
5+# The first goal is consistency across stdenvs. Regardless of what this function
6+# does, by making every stdenv use it for bootstrapping we ensure that they all
7+# work in a similar way. [Before this abstraction, each stdenv was its own
8+# special snowflake due to different authors writing in different times.]
9+#
10+# The second goal is consistency across each stdenv's stage functions. By
11+# writing each stage it terms of the previous stage, commonalities between them
12+# are more easily observable. [Before, there usually was a big attribute set
13+# with each stage, and stages would access the previous stage by name.]
14+#
15+# The third goal is composition. Because each stage is written in terms of the
16+# previous, the list can be reordered or, more practically, extended with new
17+# stages. The latter is used for cross compiling and custom
18+# stdenvs. Additionally, certain options should by default apply only to the
19+# last stage, whatever it may be. By delaying the creation of stage package sets
20+# until the final fold, we prevent these options from inhibiting composition.
21+#
22+# The fourth and final goal is debugging. Normal packages should only source
23+# their dependencies from the current stage. But for the sake of debugging, it
24+# is nice that all packages still remain accessible. We make sure previous
25+# stages are kept around with a `stdenv.__bootPackges` attribute referring the
26+# previous stage. It is idiomatic that attributes prefixed with `__` come with
27+# special restrictions and should not be used under normal circumstances.
28+{ lib, allPackages }:
29+30+# Type:
31+# [ pkgset -> (args to stage/default.nix) or ({ __raw = true; } // pkgs) ]
32+# -> pkgset
33+#
34+# In english: This takes a list of function from the previous stage pkgset and
35+# returns the final pkgset. Each of those functions returns, if `__raw` is
36+# undefined or false, args for this stage's pkgset (the most complex and
37+# important arg is the stdenv), or, if `__raw = true`, simply this stage's
38+# pkgset itself.
39+#
40+# The list takes stages in order, so the final stage is last in the list. In
41+# other words, this does a foldr not foldl.
42+stageFuns: let
43+44+ # Take the list and disallow custom overrides in all but the final stage,
45+ # and allow it in the final flag. Only defaults this boolean field if it
46+ # isn't already set.
47+ withAllowCustomOverrides = lib.lists.imap
48+ (index: stageFun: prevStage:
49+ # So true by default for only the first element because one
50+ # 1-indexing. Since we reverse the list, this means this is true
51+ # for the final stage.
52+ { allowCustomOverrides = index == 1; }
53+ // (stageFun prevStage))
54+ (lib.lists.reverseList stageFuns);
55+56+ # Adds the stdenv to the arguments, and sticks in it the previous stage for
57+ # debugging purposes.
58+ folder = stageFun: finalSoFar: let
59+ args = stageFun finalSoFar;
60+ stdenv = args.stdenv // {
61+ # For debugging
62+ __bootPackages = finalSoFar;
63+ };
64+ args' = args // { inherit stdenv; };
65+ in
66+ (if args.__raw or false then lib.id else allPackages) args';
67+68+in lib.lists.fold folder {} withAllowCustomOverrides
+35-21
pkgs/stdenv/cross/default.nix
···1-{ lib, allPackages
2, system, platform, crossSystem, config
3}:
45-rec {
6- vanillaStdenv = (import ../. {
7- inherit lib allPackages system platform;
8 crossSystem = null;
9 # Ignore custom stdenvs when cross compiling for compatability
10 config = builtins.removeAttrs config [ "replaceStdenv" ];
11- }) // {
12- # Needed elsewhere as a hacky way to pass the target
13- cross = crossSystem;
14 };
1516- # For now, this is just used to build the native stdenv. Eventually, it should
17- # be used to build compilers and other such tools targeting the cross
000018 # platform. Then, `forceNativeDrv` can be removed.
19- buildPackages = allPackages {
20 inherit system platform crossSystem config;
21 # It's OK to change the built-time dependencies
22 allowCustomOverrides = true;
23- stdenv = vanillaStdenv;
24- };
00002526- stdenvCross = buildPackages.makeStdenvCross
27- buildPackages.stdenv crossSystem
28- buildPackages.binutilsCross buildPackages.gccCrossStageFinal;
000000000000002930- stdenvCrossiOS = let
31- inherit (buildPackages.darwin.ios-cross { prefix = crossSystem.config; inherit (crossSystem) arch; simulator = crossSystem.isiPhoneSimulator or false; }) cc binutils;
32- in buildPackages.makeStdenvCross
33- buildPackages.stdenv crossSystem
34- binutils cc;
35-}
···1+{ lib
2, system, platform, crossSystem, config
3}:
45+let
6+ bootStages = import ../. {
7+ inherit lib system platform;
8 crossSystem = null;
9 # Ignore custom stdenvs when cross compiling for compatability
10 config = builtins.removeAttrs config [ "replaceStdenv" ];
00011 };
1213+in bootStages ++ [
14+15+ # Build Packages.
16+ #
17+ # For now, this is just used to build the native stdenv. Eventually, it
18+ # should be used to build compilers and other such tools targeting the cross
19 # platform. Then, `forceNativeDrv` can be removed.
20+ (vanillaPackages: {
21 inherit system platform crossSystem config;
22 # It's OK to change the built-time dependencies
23 allowCustomOverrides = true;
24+ stdenv = vanillaPackages.stdenv // {
25+ # Needed elsewhere as a hacky way to pass the target
26+ cross = crossSystem;
27+ overrides = _: _: {};
28+ };
29+ })
3031+ # Run packages
32+ (buildPackages: {
33+ inherit system platform crossSystem config;
34+ stdenv = if crossSystem.useiOSCross or false
35+ then let
36+ inherit (buildPackages.darwin.ios-cross {
37+ prefix = crossSystem.config;
38+ inherit (crossSystem) arch;
39+ simulator = crossSystem.isiPhoneSimulator or false; })
40+ cc binutils;
41+ in buildPackages.makeStdenvCross
42+ buildPackages.stdenv crossSystem
43+ binutils cc
44+ else buildPackages.makeStdenvCross
45+ buildPackages.stdenv crossSystem
46+ buildPackages.binutilsCross buildPackages.gccCrossStageFinal;
47+ })
4849+]
00000
···334 # The ultimate test: bootstrap a whole stdenv from the tools specified above and get a package set out of it
335 test-pkgs = import test-pkgspath {
336 inherit system;
337- stdenvFunc = args: let
338 args' = args // { inherit bootstrapFiles; };
339- in (import (test-pkgspath + "/pkgs/stdenv/darwin") args').stdenvDarwin;
340 };
341}
···334 # The ultimate test: bootstrap a whole stdenv from the tools specified above and get a package set out of it
335 test-pkgs = import test-pkgspath {
336 inherit system;
337+ stdenvStages = args: let
338 args' = args // { inherit bootstrapFiles; };
339+ in (import (test-pkgspath + "/pkgs/stdenv/darwin") args').stagesDarwin;
340 };
341}
+33-45
pkgs/stdenv/default.nix
···1-# This file defines the various standard build environments.
2#
3-# On Linux systems, the standard build environment consists of
4-# Nix-built instances glibc and the `standard' Unix tools, i.e., the
5-# Posix utilities, the GNU C compiler, and so on. On other systems,
6-# we use the native C library.
78{ # Args just for stdenvs' usage
9- lib, allPackages
10- # Args to pass on to `allPacakges` too
11, system, platform, crossSystem, config
12} @ args:
13···17 # i.e., the stuff in /bin, /usr/bin, etc. This environment should
18 # be used with care, since many Nix packages will not build properly
19 # with it (e.g., because they require GNU Make).
20- inherit (import ./native args) stdenvNative;
21-22- stdenvNativePkgs = allPackages {
23- inherit system platform crossSystem config;
24- allowCustomOverrides = false;
25- stdenv = stdenvNative;
26- noSysDirs = false;
27- };
28-2930 # The Nix build environment.
31- stdenvNix = assert crossSystem == null; import ./nix {
32- inherit config lib;
33- stdenv = stdenvNative;
34- pkgs = stdenvNativePkgs;
35- };
3637- inherit (import ./freebsd args) stdenvFreeBSD;
3839- # Linux standard environment.
40- inherit (import ./linux args) stdenvLinux;
004142- inherit (import ./darwin args) stdenvDarwin;
4344- inherit (import ./cross args) stdenvCross stdenvCrossiOS;
4546- inherit (import ./custom args) stdenvCustom;
4748- # Select the appropriate stdenv for the platform `system'.
49in
50- if crossSystem != null then
51- if crossSystem.useiOSCross or false then stdenvCrossiOS
52- else stdenvCross else
53- if config ? replaceStdenv then stdenvCustom else
54- if system == "i686-linux" then stdenvLinux else
55- if system == "x86_64-linux" then stdenvLinux else
56- if system == "armv5tel-linux" then stdenvLinux else
57- if system == "armv6l-linux" then stdenvLinux else
58- if system == "armv7l-linux" then stdenvLinux else
59- if system == "mips64el-linux" then stdenvLinux else
60- if system == "powerpc-linux" then /* stdenvLinux */ stdenvNative else
61- if system == "x86_64-darwin" then stdenvDarwin else
62- if system == "x86_64-solaris" then stdenvNix else
63- if system == "i686-cygwin" then stdenvNative else
64- if system == "x86_64-cygwin" then stdenvNative else
65- if system == "x86_64-freebsd" then stdenvFreeBSD else
66- stdenvNative
···1+# This file chooses a sane default stdenv given the system, platform, etc.
2#
3+# Rather than returning a stdenv, this returns a list of functions---one per
4+# each bootstrapping stage. See `./booter.nix` for exactly what this list should
5+# contain.
067{ # Args just for stdenvs' usage
8+ lib
9+ # Args to pass on to the pkgset builder, too
10, system, platform, crossSystem, config
11} @ args:
12···16 # i.e., the stuff in /bin, /usr/bin, etc. This environment should
17 # be used with care, since many Nix packages will not build properly
18 # with it (e.g., because they require GNU Make).
19+ stagesNative = import ./native args;
000000002021 # The Nix build environment.
22+ stagesNix = import ./nix (args // { bootStages = stagesNative; });
00002324+ stagesFreeBSD = import ./freebsd args;
2526+ # On Linux systems, the standard build environment consists of Nix-built
27+ # instances glibc and the `standard' Unix tools, i.e., the Posix utilities,
28+ # the GNU C compiler, and so on.
29+ stagesLinux = import ./linux args;
3031+ inherit (import ./darwin args) stagesDarwin;
3233+ stagesCross = import ./cross args;
3435+ stagesCustom = import ./custom args;
3637+ # Select the appropriate stages for the platform `system'.
38in
39+ if crossSystem != null then stagesCross
40+ else if config ? replaceStdenv then stagesCustom
41+ else { # switch
42+ "i686-linux" = stagesLinux;
43+ "x86_64-linux" = stagesLinux;
44+ "armv5tel-linux" = stagesLinux;
45+ "armv6l-linux" = stagesLinux;
46+ "armv7l-linux" = stagesLinux;
47+ "mips64el-linux" = stagesLinux;
48+ "powerpc-linux" = /* stagesLinux */ stagesNative;
49+ "x86_64-darwin" = stagesDarwin;
50+ "x86_64-solaris" = stagesNix;
51+ "i686-cygwin" = stagesNative;
52+ "x86_64-cygwin" = stagesNative;
53+ "x86_64-freebsd" = stagesFreeBSD;
54+ }.${system} or stagesNative
0
···1let lib = import ../../../lib; in lib.makeOverridable (
23{ system, name ? "stdenv", preHook ? "", initialPath, cc, shell
4-, allowedRequisites ? null, extraAttrs ? {}, overrides ? (pkgs: {}), config
56, # The `fetchurl' to use for downloading curl and its dependencies
7 # (see all-packages.nix).
···1let lib = import ../../../lib; in lib.makeOverridable (
23{ system, name ? "stdenv", preHook ? "", initialPath, cc, shell
4+, allowedRequisites ? null, extraAttrs ? {}, overrides ? (self: super: {}), config
56, # The `fetchurl' to use for downloading curl and its dependencies
7 # (see all-packages.nix).
+107-102
pkgs/stdenv/linux/default.nix
···3# external (non-Nix) tools, such as /usr/bin/gcc, and it contains a C
4# compiler and linker that do not search in default locations,
5# ensuring purity of components produced by it.
6-{ lib, allPackages
7, system, platform, crossSystem, config
89, bootstrapFiles ?
···1819assert crossSystem == null;
2021-rec {
2223 commonPreHook =
24 ''
···43 # This function builds the various standard environments used during
44 # the bootstrap. In all stages, we build an stdenv and the package
45 # set that can be built with that stdenv.
46- stageFun =
47- {gccPlain, glibc, binutils, coreutils, gnugrep, name, overrides ? (pkgs: {}), extraBuildInputs ? []}:
4849 let
50···65 inherit system;
66 };
6768- cc = if isNull gccPlain
69 then null
70 else lib.makeOverridable (import ../../build-support/cc-wrapper) {
71 nativeTools = false;
72 nativeLibc = false;
73- cc = gccPlain;
74 isGNU = true;
75- libc = glibc;
76- inherit binutils coreutils gnugrep;
77 name = name;
78- stdenv = stage0.stdenv;
79 };
8081 extraAttrs = {
···8586 # stdenv.glibc is used by GCC build to figure out the system-level
87 # /usr/include directory.
88- inherit glibc;
89 };
90- overrides = pkgs: (overrides pkgs) // { fetchurl = thisStdenv.fetchurlBoot; };
91 };
9293- thisPkgs = allPackages {
94- inherit system platform crossSystem config;
95- allowCustomOverrides = false;
96- stdenv = thisStdenv;
97- };
09899- in { stdenv = thisStdenv; pkgs = thisPkgs; };
10000101102- # Build a dummy stdenv with no GCC or working fetchurl. This is
103- # because we need a stdenv to build the GCC wrapper and fetchurl.
104- stage0 = stageFun {
105- gccPlain = null;
106 glibc = null;
107 binutils = null;
108 coreutils = null;
109 gnugrep = null;
00000110 name = null;
111112- overrides = pkgs: {
00000113 # The Glibc include directory cannot have the same prefix as the
114 # GCC include directory, since GCC gets confused otherwise (it
115 # will search the Glibc headers before the GCC headers). So
116 # create a dummy Glibc here, which will be used in the stdenv of
117 # stage1.
118- glibc = stage0.stdenv.mkDerivation {
119 name = "bootstrap-glibc";
120 buildCommand = ''
121 mkdir -p $out
···123 ln -s ${bootstrapTools}/include-glibc $out/include
124 '';
125 };
0000126 };
127- };
128129130 # Create the first "real" standard environment. This one consists
···137 # If we ever need to use a package from more than one stage back, we
138 # simply re-export those packages in the middle stage(s) using the
139 # overrides attribute and the inherit syntax.
140- stage1 = stageFun {
141- gccPlain = bootstrapTools;
142- inherit (stage0.pkgs) glibc;
143- binutils = bootstrapTools;
144- coreutils = bootstrapTools;
145- gnugrep = bootstrapTools;
146 name = "bootstrap-gcc-wrapper";
147148 # Rebuild binutils to use from stage2 onwards.
149- overrides = pkgs: {
150- binutils = pkgs.binutils.override { gold = false; };
151- inherit (stage0.pkgs) glibc;
00152153 # A threaded perl build needs glibc/libpthread_nonshared.a,
154 # which is not included in bootstrapTools, so disable threading.
155 # This is not an issue for the final stdenv, because this perl
156 # won't be included in the final stdenv and won't be exported to
157 # top-level pkgs as an override either.
158- perl = pkgs.perl.override { enableThreading = false; };
159 };
160- };
161162163 # 2nd stdenv that contains our own rebuilt binutils and is used for
164 # compiling our own Glibc.
165- stage2 = stageFun {
166- gccPlain = bootstrapTools;
167- inherit (stage1.pkgs) glibc;
168- binutils = stage1.pkgs.binutils;
169- coreutils = bootstrapTools;
170- gnugrep = bootstrapTools;
171 name = "bootstrap-gcc-wrapper";
172173- overrides = pkgs: {
174- inherit (stage1.pkgs) perl binutils paxctl gnum4 bison;
000175 # This also contains the full, dynamically linked, final Glibc.
176 };
177- };
178179180 # Construct a third stdenv identical to the 2nd, except that this
181 # one uses the rebuilt Glibc from stage2. It still uses the recent
182 # binutils and rest of the bootstrap tools, including GCC.
183- stage3 = stageFun {
184- gccPlain = bootstrapTools;
185- inherit (stage2.pkgs) glibc binutils;
186- coreutils = bootstrapTools;
187- gnugrep = bootstrapTools;
188 name = "bootstrap-gcc-wrapper";
189190- overrides = pkgs: rec {
191- inherit (stage2.pkgs) binutils glibc perl patchelf linuxHeaders gnum4 bison;
000192 # Link GCC statically against GMP etc. This makes sense because
193 # these builds of the libraries are only used by GCC, so it
194 # reduces the size of the stdenv closure.
195- gmp = pkgs.gmp.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
196- mpfr = pkgs.mpfr.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
197- libmpc = pkgs.libmpc.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
198- isl_0_14 = pkgs.isl_0_14.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
199- gccPlain = pkgs.gcc.cc.override {
200 isl = isl_0_14;
201 };
202 };
203- extraBuildInputs = [ stage2.pkgs.patchelf stage2.pkgs.paxctl ];
204- };
205206207 # Construct a fourth stdenv that uses the new GCC. But coreutils is
208 # still from the bootstrap tools.
209- stage4 = stageFun {
210- inherit (stage3.pkgs) gccPlain glibc binutils;
211- gnugrep = bootstrapTools;
212- coreutils = bootstrapTools;
213 name = "";
214215- overrides = pkgs: {
216 # Zlib has to be inherited and not rebuilt in this stage,
217 # because gcc (since JAR support) already depends on zlib, and
218 # then if we already have a zlib we want to use that for the
219 # other purposes (binutils and top-level pkgs) too.
220- inherit (stage3.pkgs) gettext gnum4 bison gmp perl glibc zlib linuxHeaders;
221222 gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) {
223 nativeTools = false;
224 nativeLibc = false;
225 isGNU = true;
226- cc = stage4.stdenv.cc.cc;
227- libc = stage4.pkgs.glibc;
228- inherit (stage4.pkgs) binutils coreutils gnugrep;
229 name = "";
230- stdenv = stage4.stdenv;
231- shell = stage4.pkgs.bash + "/bin/bash";
232 };
233 };
234- extraBuildInputs = [ stage3.pkgs.patchelf stage3.pkgs.xz ];
235- };
236-237238 # Construct the final stdenv. It uses the Glibc and GCC, and adds
239 # in a new binutils that doesn't depend on bootstrap-tools, as well
···242 # When updating stdenvLinux, make sure that the result has no
243 # dependency (`nix-store -qR') on bootstrapTools or the first
244 # binutils built.
245- stdenvLinux = import ../generic rec {
246- inherit system config;
00247248- preHook =
249- ''
250 # Make "strip" produce deterministic output, by setting
251 # timestamps etc. to a fixed value.
252 commonStripFlags="--enable-deterministic-archives"
253 ${commonPreHook}
254 '';
255256- initialPath =
257- ((import ../common-path.nix) {pkgs = stage4.pkgs;});
258259- extraBuildInputs = [ stage4.pkgs.patchelf stage4.pkgs.paxctl ];
260261- cc = stage4.pkgs.gcc;
262263- shell = cc.shell;
264265- inherit (stage4.stdenv) fetchurlBoot;
266267- extraAttrs = {
268- inherit (stage4.pkgs) glibc;
269- inherit platform bootstrapTools;
270- shellPackage = stage4.pkgs.bash;
271- };
272273- /* outputs TODO
274- allowedRequisites = with stage4.pkgs;
275- [ gzip bzip2 xz bash binutils coreutils diffutils findutils gawk
276- glibc gnumake gnused gnutar gnugrep gnupatch patchelf attr acl
277- paxctl zlib pcre linuxHeaders ed gcc gcc.cc libsigsegv
278- ];
279- */
280281- overrides = pkgs: {
282- gcc = cc;
283284- inherit (stage4.pkgs)
285- gzip bzip2 xz bash binutils coreutils diffutils findutils gawk
286- glibc gnumake gnused gnutar gnugrep gnupatch patchelf
287- attr acl paxctl zlib pcre;
0288 };
289- };
290291-}
···3# external (non-Nix) tools, such as /usr/bin/gcc, and it contains a C
4# compiler and linker that do not search in default locations,
5# ensuring purity of components produced by it.
6+{ lib
7, system, platform, crossSystem, config
89, bootstrapFiles ?
···1819assert crossSystem == null;
2021+let
2223 commonPreHook =
24 ''
···43 # This function builds the various standard environments used during
44 # the bootstrap. In all stages, we build an stdenv and the package
45 # set that can be built with that stdenv.
46+ stageFun = prevStage:
47+ { name, overrides ? (self: super: {}), extraBuildInputs ? [] }:
4849 let
50···65 inherit system;
66 };
6768+ cc = if isNull prevStage.gcc-unwrapped
69 then null
70 else lib.makeOverridable (import ../../build-support/cc-wrapper) {
71 nativeTools = false;
72 nativeLibc = false;
73+ cc = prevStage.gcc-unwrapped;
74 isGNU = true;
75+ libc = prevStage.glibc;
76+ inherit (prevStage) binutils coreutils gnugrep;
77 name = name;
78+ stdenv = prevStage.ccWrapperStdenv;
79 };
8081 extraAttrs = {
···8586 # stdenv.glibc is used by GCC build to figure out the system-level
87 # /usr/include directory.
88+ inherit (prevStage) glibc;
89 };
90+ overrides = self: super: (overrides self super) // { fetchurl = thisStdenv.fetchurlBoot; };
91 };
9293+ in {
94+ inherit system platform crossSystem config;
95+ stdenv = thisStdenv;
96+ };
97+98+in
99100+[
101102+ ({}: {
103+ __raw = true;
104105+ gcc-unwrapped = null;
000106 glibc = null;
107 binutils = null;
108 coreutils = null;
109 gnugrep = null;
110+ })
111+112+ # Build a dummy stdenv with no GCC or working fetchurl. This is
113+ # because we need a stdenv to build the GCC wrapper and fetchurl.
114+ (prevStage: stageFun prevStage {
115 name = null;
116117+ overrides = self: super: {
118+ # We thread stage0's stdenv through under this name so downstream stages
119+ # can use it for wrapping gcc too. This way, downstream stages don't need
120+ # to refer to this stage directly, which violates the principle that each
121+ # stage should only access the stage that came before it.
122+ ccWrapperStdenv = self.stdenv;
123 # The Glibc include directory cannot have the same prefix as the
124 # GCC include directory, since GCC gets confused otherwise (it
125 # will search the Glibc headers before the GCC headers). So
126 # create a dummy Glibc here, which will be used in the stdenv of
127 # stage1.
128+ glibc = self.stdenv.mkDerivation {
129 name = "bootstrap-glibc";
130 buildCommand = ''
131 mkdir -p $out
···133 ln -s ${bootstrapTools}/include-glibc $out/include
134 '';
135 };
136+ gcc-unwrapped = bootstrapTools;
137+ binutils = bootstrapTools;
138+ coreutils = bootstrapTools;
139+ gnugrep = bootstrapTools;
140 };
141+ })
142143144 # Create the first "real" standard environment. This one consists
···151 # If we ever need to use a package from more than one stage back, we
152 # simply re-export those packages in the middle stage(s) using the
153 # overrides attribute and the inherit syntax.
154+ (prevStage: stageFun prevStage {
00000155 name = "bootstrap-gcc-wrapper";
156157 # Rebuild binutils to use from stage2 onwards.
158+ overrides = self: super: {
159+ binutils = super.binutils.override { gold = false; };
160+ inherit (prevStage)
161+ ccWrapperStdenv
162+ glibc gcc-unwrapped coreutils gnugrep;
163164 # A threaded perl build needs glibc/libpthread_nonshared.a,
165 # which is not included in bootstrapTools, so disable threading.
166 # This is not an issue for the final stdenv, because this perl
167 # won't be included in the final stdenv and won't be exported to
168 # top-level pkgs as an override either.
169+ perl = super.perl.override { enableThreading = false; };
170 };
171+ })
172173174 # 2nd stdenv that contains our own rebuilt binutils and is used for
175 # compiling our own Glibc.
176+ (prevStage: stageFun prevStage {
00000177 name = "bootstrap-gcc-wrapper";
178179+ overrides = self: super: {
180+ inherit (prevStage)
181+ ccWrapperStdenv
182+ binutils gcc-unwrapped coreutils gnugrep
183+ perl paxctl gnum4 bison;
184 # This also contains the full, dynamically linked, final Glibc.
185 };
186+ })
187188189 # Construct a third stdenv identical to the 2nd, except that this
190 # one uses the rebuilt Glibc from stage2. It still uses the recent
191 # binutils and rest of the bootstrap tools, including GCC.
192+ (prevStage: stageFun prevStage {
0000193 name = "bootstrap-gcc-wrapper";
194195+ overrides = self: super: rec {
196+ inherit (prevStage)
197+ ccWrapperStdenv
198+ binutils glibc coreutils gnugrep
199+ perl patchelf linuxHeaders gnum4 bison;
200 # Link GCC statically against GMP etc. This makes sense because
201 # these builds of the libraries are only used by GCC, so it
202 # reduces the size of the stdenv closure.
203+ gmp = super.gmp.override { stdenv = self.makeStaticLibraries self.stdenv; };
204+ mpfr = super.mpfr.override { stdenv = self.makeStaticLibraries self.stdenv; };
205+ libmpc = super.libmpc.override { stdenv = self.makeStaticLibraries self.stdenv; };
206+ isl_0_14 = super.isl_0_14.override { stdenv = self.makeStaticLibraries self.stdenv; };
207+ gcc-unwrapped = super.gcc-unwrapped.override {
208 isl = isl_0_14;
209 };
210 };
211+ extraBuildInputs = [ prevStage.patchelf prevStage.paxctl ];
212+ })
213214215 # Construct a fourth stdenv that uses the new GCC. But coreutils is
216 # still from the bootstrap tools.
217+ (prevStage: stageFun prevStage {
000218 name = "";
219220+ overrides = self: super: {
221 # Zlib has to be inherited and not rebuilt in this stage,
222 # because gcc (since JAR support) already depends on zlib, and
223 # then if we already have a zlib we want to use that for the
224 # other purposes (binutils and top-level pkgs) too.
225+ inherit (prevStage) gettext gnum4 bison gmp perl glibc zlib linuxHeaders;
226227 gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) {
228 nativeTools = false;
229 nativeLibc = false;
230 isGNU = true;
231+ cc = prevStage.gcc-unwrapped;
232+ libc = self.glibc;
233+ inherit (self) stdenv binutils coreutils gnugrep;
234 name = "";
235+ shell = self.bash + "/bin/bash";
0236 };
237 };
238+ extraBuildInputs = [ prevStage.patchelf prevStage.xz ];
239+ })
0240241 # Construct the final stdenv. It uses the Glibc and GCC, and adds
242 # in a new binutils that doesn't depend on bootstrap-tools, as well
···245 # When updating stdenvLinux, make sure that the result has no
246 # dependency (`nix-store -qR') on bootstrapTools or the first
247 # binutils built.
248+ (prevStage: {
249+ inherit system crossSystem platform config;
250+ stdenv = import ../generic rec {
251+ inherit system config;
252253+ preHook = ''
0254 # Make "strip" produce deterministic output, by setting
255 # timestamps etc. to a fixed value.
256 commonStripFlags="--enable-deterministic-archives"
257 ${commonPreHook}
258 '';
259260+ initialPath =
261+ ((import ../common-path.nix) {pkgs = prevStage;});
262263+ extraBuildInputs = [ prevStage.patchelf prevStage.paxctl ];
264265+ cc = prevStage.gcc;
266267+ shell = cc.shell;
268269+ inherit (prevStage.stdenv) fetchurlBoot;
270271+ extraAttrs = {
272+ inherit (prevStage) glibc;
273+ inherit platform bootstrapTools;
274+ shellPackage = prevStage.bash;
275+ };
276277+ /* outputs TODO
278+ allowedRequisites = with prevStage;
279+ [ gzip bzip2 xz bash binutils coreutils diffutils findutils gawk
280+ glibc gnumake gnused gnutar gnugrep gnupatch patchelf attr acl
281+ paxctl zlib pcre linuxHeaders ed gcc gcc.cc libsigsegv
282+ ];
283+ */
284285+ overrides = self: super: {
286+ gcc = cc;
287288+ inherit (prevStage)
289+ gzip bzip2 xz bash binutils coreutils diffutils findutils gawk
290+ glibc gnumake gnused gnutar gnugrep gnupatch patchelf
291+ attr acl paxctl zlib pcre;
292+ };
293 };
294+ })
295296+]
+44-40
pkgs/stdenv/native/default.nix
···1-{ lib, allPackages
2, system, platform, crossSystem, config
3}:
45assert crossSystem == null;
67-rec {
89 shell =
10 if system == "i686-freebsd" || system == "x86_64-freebsd" then "/usr/local/bin/bash"
···77 # A function that builds a "native" stdenv (one that uses tools in
78 # /usr etc.).
79 makeStdenv =
80- { cc, fetchurl, extraPath ? [], overrides ? (pkgs: { }) }:
8182 import ../generic {
83 preHook =
···101 inherit system shell cc overrides config;
102 };
1030104105- stdenvBoot0 = makeStdenv {
106- cc = null;
107- fetchurl = null;
108- };
10900110111- cc = import ../../build-support/cc-wrapper {
112- name = "cc-native";
113- nativeTools = true;
114- nativeLibc = true;
115- nativePrefix = if system == "i686-solaris" then "/usr/gnu" else if system == "x86_64-solaris" then "/opt/local/gcc47" else "/usr";
116- stdenv = stdenvBoot0;
117- };
1180000000000119120- fetchurl = import ../../build-support/fetchurl {
121- stdenv = stdenvBoot0;
122- # Curl should be in /usr/bin or so.
123- curl = null;
124- };
1250126127 # First build a stdenv based only on tools outside the store.
128- stdenvBoot1 = makeStdenv {
129- inherit cc fetchurl;
130- } // {inherit fetchurl;};
131-132- stdenvBoot1Pkgs = allPackages {
133- inherit system platform crossSystem config;
134- allowCustomOverrides = false;
135- stdenv = stdenvBoot1;
136- };
137-138-139- # Using that, build a stdenv that adds the ‘xz’ command (which most
140- # systems don't have, so we mustn't rely on the native environment
141- # providing it).
142- stdenvBoot2 = makeStdenv {
143- inherit cc fetchurl;
144- extraPath = [ stdenvBoot1Pkgs.xz ];
145- overrides = pkgs: { inherit (stdenvBoot1Pkgs) xz; };
146- };
1470000000000148149- stdenvNative = stdenvBoot2;
150-}
···1+{ lib
2, system, platform, crossSystem, config
3}:
45assert crossSystem == null;
67+let
89 shell =
10 if system == "i686-freebsd" || system == "x86_64-freebsd" then "/usr/local/bin/bash"
···77 # A function that builds a "native" stdenv (one that uses tools in
78 # /usr etc.).
79 makeStdenv =
80+ { cc, fetchurl, extraPath ? [], overrides ? (self: super: { }) }:
8182 import ../generic {
83 preHook =
···101 inherit system shell cc overrides config;
102 };
103104+in
105106+[
000107108+ ({}: rec {
109+ __raw = true;
110111+ stdenv = makeStdenv {
112+ cc = null;
113+ fetchurl = null;
114+ };
000115116+ cc = import ../../build-support/cc-wrapper {
117+ name = "cc-native";
118+ nativeTools = true;
119+ nativeLibc = true;
120+ nativePrefix = { # switch
121+ "i686-solaris" = "/usr/gnu";
122+ "x86_64-solaris" = "/opt/local/gcc47";
123+ }.${system} or "/usr";
124+ inherit stdenv;
125+ };
126127+ fetchurl = import ../../build-support/fetchurl {
128+ inherit stdenv;
129+ # Curl should be in /usr/bin or so.
130+ curl = null;
131+ };
132133+ })
134135 # First build a stdenv based only on tools outside the store.
136+ (prevStage: {
137+ inherit system crossSystem platform config;
138+ stdenv = makeStdenv {
139+ inherit (prevStage) cc fetchurl;
140+ } // { inherit (prevStage) fetchurl; };
141+ })
0000000000000142143+ # Using that, build a stdenv that adds the ‘xz’ command (which most systems
144+ # don't have, so we mustn't rely on the native environment providing it).
145+ (prevStage: {
146+ inherit system crossSystem platform config;
147+ stdenv = makeStdenv {
148+ inherit (prevStage.stdenv) cc fetchurl;
149+ extraPath = [ prevStage.xz ];
150+ overrides = self: super: { inherit (prevStage) xz; };
151+ };
152+ })
153154+]
0
···5 * to merges. Please use the full-text search of your editor. ;)
6 * Hint: ### starts category names.
7 */
8-{ system, noSysDirs, config, crossSystem, platform, lib
9-, nixpkgsFun
10-}:
11self: pkgs:
1213with pkgs;
···17in
1819{
20-21- # Make some arguments passed to all-packages.nix available
22- inherit system platform;
2324 # Allow callPackage to fill in the pkgs argument
25 inherit pkgs;
···4728 gambit = callPackage ../development/compilers/gambit { };
47294730 gcc = gcc5;
047314732 wrapCCMulti = cc:
4733 if system == "x86_64-linux" then lowPrio (
···5 * to merges. Please use the full-text search of your editor. ;)
6 * Hint: ### starts category names.
7 */
8+{ lib, nixpkgsFun, noSysDirs, config}:
009self: pkgs:
1011with pkgs;
···15in
1617{
0001819 # Allow callPackage to fill in the pkgs argument
20 inherit pkgs;
···4723 gambit = callPackage ../development/compilers/gambit { };
47244725 gcc = gcc5;
4726+ gcc-unwrapped = gcc.cc;
47274728 wrapCCMulti = cc:
4729 if system == "x86_64-linux" then lowPrio (
+13-10
pkgs/top-level/default.nix
···78 3. Defaults to no non-standard config and no cross-compilation target
910- 4. Uses the above to infer the default standard environment (stdenv) if
11- none is provided
1213- 5. Builds the final stage --- a fully booted package set with the chosen
14- stdenv
1516 Use `impure.nix` to also infer the `system` based on the one on which
17 evaluation is taking place, and the configuration from environment variables
···23, # Allow a configuration attribute set to be passed in as an argument.
24 config ? {}
2526-, # The standard environment for building packages, or rather a function
27- # providing it. See below for the arguments given to that function.
28- stdenvFunc ? import ../stdenv
02930, crossSystem ? null
31, platform ? assert false; null
···76 inherit lib nixpkgsFun;
77 } // newArgs);
7879- stdenv = stdenvFunc {
80- inherit lib allPackages system platform crossSystem config;
0081 };
8283- pkgs = allPackages { inherit system stdenv config crossSystem platform; };
8485in pkgs
···78 3. Defaults to no non-standard config and no cross-compilation target
910+ 4. Uses the above to infer the default standard environment's (stdenv's)
11+ stages if no stdenv's are provided
1213+ 5. Folds the stages to yield the final fully booted package set for the
14+ chosen stdenv
1516 Use `impure.nix` to also infer the `system` based on the one on which
17 evaluation is taking place, and the configuration from environment variables
···23, # Allow a configuration attribute set to be passed in as an argument.
24 config ? {}
2526+, # A function booting the final package set for a specific standard
27+ # environment. See below for the arguments given to that function,
28+ # the type of list it returns.
29+ stdenvStages ? import ../stdenv
3031, crossSystem ? null
32, platform ? assert false; null
···77 inherit lib nixpkgsFun;
78 } // newArgs);
7980+ boot = import ../stdenv/booter.nix { inherit lib allPackages; };
81+82+ stages = stdenvStages {
83+ inherit lib system platform crossSystem config;
84 };
8586+ pkgs = boot stages;
8788in pkgs
+12-14
pkgs/top-level/stage.nix
···18, # This is used because stdenv replacement and the stdenvCross do benefit from
19 # the overridden configuration provided by the user, as opposed to the normal
20 # bootstrapping stdenvs.
21- allowCustomOverrides ? true
2223, # Non-GNU/Linux OSes are currently "impure" platforms, with their libc
24 # outside of the store. Thus, GCC, GFortran, & co. must always look for
···47 inherit lib; inherit (self) stdenv stdenvNoCC; inherit (self.xorg) lndir;
48 };
4950- stdenvDefault = self: super:
51- { stdenv = stdenv // { inherit platform; }; };
0005253 allPackages = self: super:
54 let res = import ./all-packages.nix
55- { inherit system noSysDirs config crossSystem platform lib nixpkgsFun; }
56 res self;
57 in res;
5859 aliases = self: super: import ./aliases.nix super;
6061- # stdenvOverrides is used to avoid circular dependencies for building
62- # the standard build environment. This mechanism uses the override
63- # mechanism to implement some staged compilation of the stdenv.
64- #
65- # We don't want stdenv overrides in the case of cross-building, or
66- # otherwise the basic overridden packages will not be built with the
67- # crossStdenv adapter.
68 stdenvOverrides = self: super:
69- lib.optionalAttrs (crossSystem == null && super.stdenv ? overrides)
70- (super.stdenv.overrides super);
7172 # Allow packages to be overridden globally via the `packageOverrides'
73 # configuration option, which must be a function that takes `pkgs'
···8283 # The complete chain of package set builders, applied from top to bottom
84 toFix = lib.foldl' (lib.flip lib.extends) (self: {}) [
85- stdenvDefault
86 stdenvAdapters
87 trivialBuilders
88 allPackages
···18, # This is used because stdenv replacement and the stdenvCross do benefit from
19 # the overridden configuration provided by the user, as opposed to the normal
20 # bootstrapping stdenvs.
21+ allowCustomOverrides
2223, # Non-GNU/Linux OSes are currently "impure" platforms, with their libc
24 # outside of the store. Thus, GCC, GFortran, & co. must always look for
···47 inherit lib; inherit (self) stdenv stdenvNoCC; inherit (self.xorg) lndir;
48 };
4950+ stdenvBootstappingAndPlatforms = self: super: {
51+ stdenv = stdenv // { inherit platform; };
52+ inherit
53+ system platform crossSystem;
54+ };
5556 allPackages = self: super:
57 let res = import ./all-packages.nix
58+ { inherit lib nixpkgsFun noSysDirs config; }
59 res self;
60 in res;
6162 aliases = self: super: import ./aliases.nix super;
6364+ # stdenvOverrides is used to avoid having multiple of versions
65+ # of certain dependencies that were used in bootstrapping the
66+ # standard environment.
000067 stdenvOverrides = self: super:
68+ (super.stdenv.overrides or (_: _: {})) self super;
06970 # Allow packages to be overridden globally via the `packageOverrides'
71 # configuration option, which must be a function that takes `pkgs'
···8081 # The complete chain of package set builders, applied from top to bottom
82 toFix = lib.foldl' (lib.flip lib.extends) (self: {}) [
83+ stdenvBootstappingAndPlatforms
84 stdenvAdapters
85 trivialBuilders
86 allPackages