@@ -1,16 +1,26 @@
1−# This file evaluates to a function that, when supplied with a system
2−# identifier and a standard build environment, returns the set of all
3−# packages provided by the Nix Package Collection.
1+/* This file composes the Nix Packages collection. That is, it
2+ imports the functions that build the various packages, and calls
3+ them with appropriate arguments. The result is a set of all the
4+ packages in the Nix Packages collection for some particular
5+ platform. */
6+
7+
8+{ # The system for which to build the packages.
9+ system ? __currentSystem
410
5−{ stdenv, bootCurl, noSysDirs ? true
11+, # The standard environment to use. Only used for bootstrapping. If
12+ # null, the default standard environment is used.
13+ bootStdenv ? null
14+
15+ # More flags for the bootstrapping of stdenv.
16+, noSysDirs ? true
617, gccWithCC ? true
718, gccWithProfiling ? true
8−}:
919
10−rec {
20+}:
1121
12− inherit stdenv;
1322
23+rec {
1424
1525 ### Symbolic names.
1626
@@ -25,13 +35,31 @@ rec {
2535 # `xlibs.xlibs' is a wrapper packages that combines libX11 and a bunch
2636 # of other basic X client libraries.
2737 x11 = if useOldXLibs then xlibsOld.xlibs else xlibsWrapper;
28−
38+
39+
40+ ### Helper functions.
41+ useFromStdenv = hasIt: it: alternative: if hasIt then it else alternative;
42+
43+ # Applying this to an attribute set will cause nix-env to look
44+ # inside the set for derivations.
45+ recurseIntoAttrs = attrs: attrs // {recurseForDerivations = true;};
46+
47+
48+ ### STANDARD ENVIRONMENT
49+
50+ stdenv = if bootStdenv == null then defaultStdenv else bootStdenv;
51+
52+ defaultStdenv =
53+ (import ../stdenv {
54+ inherit system;
55+ allPackages = import ./all-packages.nix;
56+ }).stdenv;
57+
2958
3059 ### BUILD SUPPORT
3160
3261 fetchurl = (import ../build-support/fetchurl) {
33− inherit stdenv;
34− curl = bootCurl;
62+ inherit stdenv curl;
3563 };
3664
3765 fetchsvn = (import ../build-support/fetchsvn) {
@@ -53,17 +81,19 @@ rec {
5381 inherit fetchurl stdenv flex;
5482 };
5583
56− coreutils = (import ../tools/misc/coreutils) {
57− inherit fetchurl stdenv;
58− };
84+ coreutils = useFromStdenv (stdenv ? coreutils) stdenv.coreutils
85+ (import ../tools/misc/coreutils {
86+ inherit fetchurl stdenv;
87+ });
5988
6089 coreutilsDiet = (import ../tools/misc/coreutils-diet) {
6190 inherit fetchurl stdenv dietgcc perl;
6291 };
6392
64− findutils = (import ../tools/misc/findutils) {
65− inherit fetchurl stdenv coreutils;
66− };
93+ findutils = useFromStdenv (stdenv ? findutils) stdenv.findutils
94+ (import ../tools/misc/findutils {
95+ inherit fetchurl stdenv coreutils;
96+ });
6797
6898 findutilsWrapper = (import ../tools/misc/findutils-wrapper) {
6999 inherit stdenv findutils;
@@ -98,27 +128,32 @@ rec {
98128 inherit fetchurl stdenv unzip jdk;
99129 };
100130
101− diffutils = (import ../tools/text/diffutils) {
102− inherit fetchurl stdenv coreutils;
103− };
131+ diffutils = useFromStdenv (stdenv ? diffutils) stdenv.diffutils
132+ (import ../tools/text/diffutils {
133+ inherit fetchurl stdenv coreutils;
134+ });
104135
105136 gnupatch = (import ../tools/text/gnupatch) {
106137 inherit fetchurl stdenv;
107138 };
108139
109− patch = if stdenv.system == "powerpc-darwin" then null else gnupatch;
140+ patch = useFromStdenv (stdenv ? patch) stdenv.patch
141+ (if stdenv.system == "powerpc-darwin" then null else gnupatch);
110142
111− gnused = (import ../tools/text/gnused) {
112− inherit fetchurl stdenv;
113− };
143+ gnused = useFromStdenv (stdenv ? gnused) stdenv.gnused
144+ (import ../tools/text/gnused {
145+ inherit fetchurl stdenv;
146+ });
114147
115− gnugrep = (import ../tools/text/gnugrep) {
116− inherit fetchurl stdenv pcre;
117− };
148+ gnugrep = useFromStdenv (stdenv ? gnugrep) stdenv.gnugrep
149+ (import ../tools/text/gnugrep {
150+ inherit fetchurl stdenv pcre;
151+ });
118152
119− gawk = (import ../tools/text/gawk) {
120− inherit fetchurl stdenv;
121− };
153+ gawk = useFromStdenv (stdenv ? gawk) stdenv.gawk
154+ (import ../tools/text/gawk {
155+ inherit fetchurl stdenv;
156+ });
122157
123158 groff = (import ../tools/text/groff) {
124159 inherit fetchurl stdenv;
@@ -158,9 +193,10 @@ rec {
158193 inherit fetchurl stdenv;
159194 };
160195
161− gnutar = (import ../tools/archivers/gnutar) {
162− inherit fetchurl stdenv;
163− };
196+ gnutar = useFromStdenv (stdenv ? gnutar) stdenv.gnutar
197+ (import ../tools/archivers/gnutar {
198+ inherit fetchurl stdenv;
199+ });
164200
165201 gnutarDiet = (import ../tools/archivers/gnutar-diet) {
166202 inherit fetchurl stdenv dietgcc;
@@ -174,13 +210,15 @@ rec {
174210 inherit fetchurl stdenv;
175211 };
176212
177− gzip = (import ../tools/compression/gzip) {
178− inherit fetchurl stdenv;
179− };
213+ gzip = useFromStdenv (stdenv ? gzip) stdenv.gzip
214+ (import ../tools/compression/gzip {
215+ inherit fetchurl stdenv;
216+ });
180217
181− bzip2 = (import ../tools/compression/bzip2) {
182− inherit fetchurl stdenv;
183− };
218+ bzip2 = useFromStdenv (stdenv ? bzip2) stdenv.bzip2
219+ (import ../tools/compression/bzip2 {
220+ inherit fetchurl stdenv;
221+ });
184222
185223 zdelta = (import ../tools/compression/zdelta) {
186224 inherit fetchurl stdenv;
@@ -198,7 +236,9 @@ rec {
198236 inherit fetchurl stdenv;
199237 };
200238
201− curl = (import ../tools/networking/curl) {
239+ curl = if stdenv ? curl then stdenv.curl else (assert false; null);
240+
241+ realCurl = (import ../tools/networking/curl) {
202242 inherit fetchurl stdenv zlib;
203243 };
204244
@@ -308,9 +348,10 @@ rec {
308348
309349 ### SHELLS
310350
311− bash = (import ../shells/bash) {
312− inherit fetchurl stdenv;
313− };
351+ bash = useFromStdenv (stdenv ? bash) stdenv.bash
352+ (import ../shells/bash {
353+ inherit fetchurl stdenv;
354+ });
314355
315356 tcsh = (import ../shells/tcsh) {
316357 inherit fetchurl stdenv ncurses;
@@ -323,9 +364,10 @@ rec {
323364
324365 ### DEVELOPMENT
325366
326− binutils = (import ../development/tools/misc/binutils) {
327− inherit fetchurl stdenv noSysDirs;
328− };
367+ binutils = useFromStdenv (stdenv ? binutils) stdenv.binutils
368+ (import ../development/tools/misc/binutils {
369+ inherit fetchurl stdenv noSysDirs;
370+ });
329371
330372 binutilsMips = (import ../development/tools/misc/binutils-cross) {
331373 inherit fetchurl stdenv noSysDirs;
@@ -342,9 +384,10 @@ rec {
342384 cross = "sparc-linux";
343385 };
344386
345− patchelf = (import ../development/tools/misc/patchelf) {
346− inherit fetchurl stdenv;
347− };
387+ patchelf = useFromStdenv (stdenv ? patchelf) stdenv.patchelf
388+ (import ../development/tools/misc/patchelf {
389+ inherit fetchurl stdenv;
390+ });
348391
349392 patchelfNew = (import ../development/tools/misc/patchelf/new.nix) {
350393 inherit fetchurl stdenv;
@@ -439,9 +482,10 @@ rec {
439482 inherit fetchurl stdenv readline ncurses g77 perl flex;
440483 };
441484
442− gnumake = (import ../development/tools/build-managers/gnumake) {
443− inherit fetchurl stdenv;
444− };
485+ gnumake = useFromStdenv (stdenv ? gnumake) stdenv.gnumake
486+ (import ../development/tools/build-managers/gnumake {
487+ inherit fetchurl stdenv;
488+ });
445489
446490 mk = (import ../development/tools/build-managers/mk) {
447491 inherit fetchurl stdenv;
@@ -1023,7 +1067,7 @@ rec {
10231067 inherit fetchurl stdenv pkgconfig x11 fontconfig freetype zlib libpng;
10241068 };
10251069
1026− gtkLibs = gtkLibs28;
1070+ gtkLibs = recurseIntoAttrs gtkLibs28;
10271071
10281072 gtkLibs28 = import ../development/libraries/gtk-libs-2.8 {
10291073 inherit fetchurl stdenv pkgconfig gettext perl x11
@@ -1114,13 +1158,13 @@ rec {
11141158 inherit fetchurl stdenv;
11151159 };
11161160
1117− gnome = import ../development/libraries/gnome {
1161+ gnome = recurseIntoAttrs (import ../development/libraries/gnome {
11181162 inherit fetchurl stdenv pkgconfig audiofile
11191163 flex bison popt zlib libxml2 libxslt
11201164 perl perlXMLParser docbook_xml_dtd_42 gettext x11
11211165 libtiff libjpeg libpng gtkLibs;
11221166 inherit (xlibs) libXmu;
1123− };
1167+ });
11241168
11251169 wxGTK = wxGTK26;
11261170
@@ -1570,10 +1614,10 @@ rec {
15701614 inherit fetchurl stdenv apacheHttpd python;
15711615 };
15721616
1573− xorg = import ../servers/x11/xorg {
1617+ xorg = recurseIntoAttrs (import ../servers/x11/xorg {
15741618 inherit fetchurl stdenv pkgconfig freetype fontconfig
15751619 expat libdrm libpng zlib perl mesa;
1576− };
1620+ });
15771621
15781622 postgresql = (import ../servers/sql/postgresql) {
15791623 inherit fetchurl stdenv readline ncurses zlib;
@@ -1911,9 +1955,8 @@ rec {
19111955 plugins = [
19121956 MPlayerPlugin
19131957 flashplayer
1914− blackdown
19151958# RealPlayer # disabled by default for legal reasons
1916− ];
1959+ ] ++ (if blackdown != null then [blackdown] else []);
19171960 };
19181961
19191962 firefoxWrapper = wrapFirefox firefox;
@@ -2289,14 +2332,12 @@ rec {
22892332 };
22902333
22912334 #nixStatic = (import ../misc/nix-static) {
2292− # inherit fetchurl stdenv aterm perl;
2293− # curl = bootCurl; /* !!! ugly */
2335+ # inherit fetchurl stdenv aterm perl curl;
22942336 # bdb = db4;
22952337 #};
22962338
22972339 nix = (import ../misc/nix) {
2298− inherit fetchurl stdenv aterm perl;
2299− curl = bootCurl; /* !!! ugly */
2340+ inherit fetchurl stdenv aterm perl curl;
23002341 bdb = db4;
23012342 };
23022343