* Push packages from the final stdenv bootstrapping phase to

all-packages.  That is, an attribute like "bash" in all-packages.nix
  should evaluate to the "bash" used to build stdenv, it shouldn't
  build a new one.

  Hm, this would be a lot cleaner if we had lazy_rec ;-)

svn path=/nixpkgs/branches/usability/; revision=4775
This commit is contained in:
Eelco Dolstra 2006-02-09 17:04:18 +00:00
parent 29c64c6c67
commit 07bc3fbf00
3 changed files with 83 additions and 67 deletions

View File

@ -1,5 +1,6 @@
{ stdenv, name, preHook ? null, postHook ? null, initialPath, gcc, shell { stdenv, name, preHook ? null, postHook ? null, initialPath, gcc, shell
, param1 ? "", param2 ? "", param3 ? "", param4 ? "", param5 ? "" , param1 ? "", param2 ? "", param3 ? "", param4 ? "", param5 ? ""
, extraAttrs ? {}
}: }:
let { let {
@ -24,6 +25,7 @@ let {
# Add a utility function to produce derivations that use this # Add a utility function to produce derivations that use this
# stdenv and its shell. # stdenv and its shell.
// { // {
mkDerivation = attrs: derivation (attrs // { mkDerivation = attrs: derivation (attrs // {
builder = if attrs ? realBuilder then attrs.realBuilder else shell; builder = if attrs ? realBuilder then attrs.realBuilder else shell;
args = if attrs ? args then attrs.args else args = if attrs ? args then attrs.args else
@ -31,6 +33,13 @@ let {
stdenv = body; stdenv = body;
system = body.system; system = body.system;
}); });
};
}
# Propagate any extra attributes. For instance, we use this to
# "lift" packages like curl from the final stdenv for Linux to
# all-packages.nix for that platform (meaning that it has a line
# like curl = if stdenv ? curl then stdenv.curl else ...).
// extraAttrs;
} }

View File

@ -114,22 +114,26 @@ rec {
# This function builds the various standard environments used during # This function builds the various standard environments used during
# the bootstrap. # the bootstrap.
stdenvBootFun = {glibc, gcc, binutils, staticGlibc}: (import ../generic) { stdenvBootFun =
name = "stdenv-linux-boot"; {glibc, gcc, binutils, staticGlibc, extraAttrs ? {}}:
param1 = if staticGlibc then "static" else "dynamic";
preHook = ./prehook.sh; import ../generic {
stdenv = stdenvInitial; name = "stdenv-linux-boot";
shell = ./tools/bash; param1 = if staticGlibc then "static" else "dynamic";
gcc = (import ../../build-support/gcc-wrapper) { preHook = ./prehook.sh;
stdenv = stdenvInitial; stdenv = stdenvInitial;
nativeTools = false; shell = ./tools/bash;
nativeGlibc = false; gcc = (import ../../build-support/gcc-wrapper) {
inherit gcc glibc binutils; stdenv = stdenvInitial;
nativeTools = false;
nativeGlibc = false;
inherit gcc glibc binutils;
};
initialPath = [
staticTools
];
inherit extraAttrs;
}; };
initialPath = [
staticTools
];
};
# Create the first "real" standard environment. This one consists # Create the first "real" standard environment. This one consists
@ -139,13 +143,13 @@ rec {
# Use the statically linked, downloaded glibc/gcc/binutils. # Use the statically linked, downloaded glibc/gcc/binutils.
inherit glibc gcc binutils; inherit glibc gcc binutils;
staticGlibc = true; staticGlibc = true;
extraAttrs = {inherit curl;};
}; };
# 2) These are the packages that we can build with the first # 2) These are the packages that we can build with the first
# stdenv. We only need Glibc (in step 3). # stdenv. We only need Glibc (in step 3).
stdenvLinuxBoot1Pkgs = allPackages { stdenvLinuxBoot1Pkgs = allPackages {
bootStdenv = stdenvLinuxBoot1; bootStdenv = stdenvLinuxBoot1;
# bootCurl = curl;
}; };
# 3) Build Glibc with the statically linked tools. The result is the # 3) Build Glibc with the statically linked tools. The result is the
@ -159,12 +163,12 @@ rec {
glibc = stdenvLinuxGlibc; glibc = stdenvLinuxGlibc;
staticGlibc = false; staticGlibc = false;
inherit gcc binutils; inherit gcc binutils;
extraAttrs = {inherit curl;};
}; };
# 5) The packages that can be built using the second stdenv. # 5) The packages that can be built using the second stdenv.
stdenvLinuxBoot2Pkgs = allPackages { stdenvLinuxBoot2Pkgs = allPackages {
bootStdenv = stdenvLinuxBoot2; bootStdenv = stdenvLinuxBoot2;
# bootCurl = curl;
}; };
# 6) Construct a third stdenv identical to the second, except that # 6) Construct a third stdenv identical to the second, except that
@ -174,12 +178,12 @@ rec {
glibc = stdenvLinuxGlibc; glibc = stdenvLinuxGlibc;
staticGlibc = false; staticGlibc = false;
inherit (stdenvLinuxBoot2Pkgs) gcc binutils; inherit (stdenvLinuxBoot2Pkgs) gcc binutils;
extraAttrs = {inherit curl;};
}; };
# 7) The packages that can be built using the third stdenv. # 7) The packages that can be built using the third stdenv.
stdenvLinuxBoot3Pkgs = allPackages { stdenvLinuxBoot3Pkgs = allPackages {
bootStdenv = stdenvLinuxBoot3; bootStdenv = stdenvLinuxBoot3;
# bootCurl = curl;
}; };
# 8) Construct the final stdenv. It uses the Glibc, GCC and # 8) Construct the final stdenv. It uses the Glibc, GCC and
@ -205,20 +209,14 @@ rec {
}; };
shell = stdenvLinuxBoot3Pkgs.bash ~ /bin/sh; shell = stdenvLinuxBoot3Pkgs.bash ~ /bin/sh;
extraAttrs = {
curl = stdenvLinuxBoot3Pkgs.realCurl;
inherit (stdenvLinuxBoot2Pkgs) binutils /* gcc */;
inherit (stdenvLinuxBoot3Pkgs)
gzip bzip2 bash coreutils diffutils findutils gawk
gnumake gnused gnutar gnugrep patch patchelf;
};
}; };
# 8) Finally, the set of components built using the Linux stdenv.
# Reuse the tools built in the previous steps.
stdenvLinuxPkgs =
allPackages {
bootStdenv = stdenvLinux;
# bootCurl = stdenvLinuxBoot3Pkgs.curl;
} //
{inherit (stdenvLinuxBoot2Pkgs) binutils gcc;} //
{inherit (stdenvLinuxBoot3Pkgs)
gzip bzip2 bash coreutils diffutils findutils gawk
gnumake gnused gnutar gnugrep curl patch patchelf;
} //
{glibc = stdenvLinuxGlibc;};
} }

View File

@ -37,6 +37,10 @@ rec {
x11 = if useOldXLibs then xlibsOld.xlibs else xlibsWrapper; x11 = if useOldXLibs then xlibsOld.xlibs else xlibsWrapper;
### Helper functions.
useFromStdenv = hasIt: it: alternative: if hasIt then it else alternative;
### STANDARD ENVIRONMENT ### STANDARD ENVIRONMENT
stdenv = if bootStdenv == null then defaultStdenv else bootStdenv; stdenv = if bootStdenv == null then defaultStdenv else bootStdenv;
@ -47,14 +51,11 @@ rec {
allPackages = import ./all-packages.nix; allPackages = import ./all-packages.nix;
}).stdenv; }).stdenv;
bootCurl = null;
### BUILD SUPPORT ### BUILD SUPPORT
fetchurl = (import ../build-support/fetchurl) { fetchurl = (import ../build-support/fetchurl) {
inherit stdenv; inherit stdenv curl;
curl = bootCurl;
}; };
fetchsvn = (import ../build-support/fetchsvn) { fetchsvn = (import ../build-support/fetchsvn) {
@ -76,17 +77,19 @@ rec {
inherit fetchurl stdenv flex; inherit fetchurl stdenv flex;
}; };
coreutils = (import ../tools/misc/coreutils) { coreutils = useFromStdenv (stdenv ? coreutils) stdenv.coreutils
(import ../tools/misc/coreutils {
inherit fetchurl stdenv; inherit fetchurl stdenv;
}; });
coreutilsDiet = (import ../tools/misc/coreutils-diet) { coreutilsDiet = (import ../tools/misc/coreutils-diet) {
inherit fetchurl stdenv dietgcc perl; inherit fetchurl stdenv dietgcc perl;
}; };
findutils = (import ../tools/misc/findutils) { findutils = useFromStdenv (stdenv ? findutils) stdenv.findutils
(import ../tools/misc/findutils {
inherit fetchurl stdenv coreutils; inherit fetchurl stdenv coreutils;
}; });
findutilsWrapper = (import ../tools/misc/findutils-wrapper) { findutilsWrapper = (import ../tools/misc/findutils-wrapper) {
inherit stdenv findutils; inherit stdenv findutils;
@ -121,27 +124,29 @@ rec {
inherit fetchurl stdenv unzip jdk; inherit fetchurl stdenv unzip jdk;
}; };
diffutils = (import ../tools/text/diffutils) { diffutils = useFromStdenv (stdenv ? diffutils) stdenv.diffutils
(import ../tools/text/diffutils {
inherit fetchurl stdenv coreutils; inherit fetchurl stdenv coreutils;
}; });
gnupatch = (import ../tools/text/gnupatch) { gnupatch = (import ../tools/text/gnupatch) {
inherit fetchurl stdenv; inherit fetchurl stdenv;
}; };
patch = if stdenv.system == "powerpc-darwin" then null else gnupatch; patch = useFromStdenv (stdenv ? patch) stdenv.patch
(if stdenv.system == "powerpc-darwin" then null else gnupatch);
gnused = (import ../tools/text/gnused) { gnused = useFromStdenv (stdenv ? gnused) stdenv.gnused (import ../tools/text/gnused {
inherit fetchurl stdenv; inherit fetchurl stdenv;
}; });
gnugrep = (import ../tools/text/gnugrep) { gnugrep = useFromStdenv (stdenv ? gnugrep) stdenv.gnugrep (import ../tools/text/gnugrep {
inherit fetchurl stdenv pcre; inherit fetchurl stdenv pcre;
}; });
gawk = (import ../tools/text/gawk) { gawk = useFromStdenv (stdenv ? gawk) stdenv.gawk (import ../tools/text/gawk {
inherit fetchurl stdenv; inherit fetchurl stdenv;
}; });
groff = (import ../tools/text/groff) { groff = (import ../tools/text/groff) {
inherit fetchurl stdenv; inherit fetchurl stdenv;
@ -181,9 +186,9 @@ rec {
inherit fetchurl stdenv; inherit fetchurl stdenv;
}; };
gnutar = (import ../tools/archivers/gnutar) { gnutar = useFromStdenv (stdenv ? gnutar) stdenv.gnutar (import ../tools/archivers/gnutar {
inherit fetchurl stdenv; inherit fetchurl stdenv;
}; });
gnutarDiet = (import ../tools/archivers/gnutar-diet) { gnutarDiet = (import ../tools/archivers/gnutar-diet) {
inherit fetchurl stdenv dietgcc; inherit fetchurl stdenv dietgcc;
@ -197,13 +202,13 @@ rec {
inherit fetchurl stdenv; inherit fetchurl stdenv;
}; };
gzip = (import ../tools/compression/gzip) { gzip = useFromStdenv (stdenv ? gzip) stdenv.gzip (import ../tools/compression/gzip {
inherit fetchurl stdenv; inherit fetchurl stdenv;
}; });
bzip2 = (import ../tools/compression/bzip2) { bzip2 = useFromStdenv (stdenv ? bzip2) stdenv.bzip2 (import ../tools/compression/bzip2 {
inherit fetchurl stdenv; inherit fetchurl stdenv;
}; });
zdelta = (import ../tools/compression/zdelta) { zdelta = (import ../tools/compression/zdelta) {
inherit fetchurl stdenv; inherit fetchurl stdenv;
@ -221,7 +226,9 @@ rec {
inherit fetchurl stdenv; inherit fetchurl stdenv;
}; };
curl = (import ../tools/networking/curl) { curl = useFromStdenv (stdenv ? curl) stdenv.curl realCurl;
realCurl = (import ../tools/networking/curl) {
inherit fetchurl stdenv zlib; inherit fetchurl stdenv zlib;
}; };
@ -331,9 +338,9 @@ rec {
### SHELLS ### SHELLS
bash = (import ../shells/bash) { bash = useFromStdenv (stdenv ? bash) stdenv.bash (import ../shells/bash {
inherit fetchurl stdenv; inherit fetchurl stdenv;
}; });
tcsh = (import ../shells/tcsh) { tcsh = (import ../shells/tcsh) {
inherit fetchurl stdenv ncurses; inherit fetchurl stdenv ncurses;
@ -346,9 +353,10 @@ rec {
### DEVELOPMENT ### DEVELOPMENT
binutils = (import ../development/tools/misc/binutils) { binutils = useFromStdenv (stdenv ? binutils) stdenv.binutils
(import ../development/tools/misc/binutils {
inherit fetchurl stdenv noSysDirs; inherit fetchurl stdenv noSysDirs;
}; });
binutilsMips = (import ../development/tools/misc/binutils-cross) { binutilsMips = (import ../development/tools/misc/binutils-cross) {
inherit fetchurl stdenv noSysDirs; inherit fetchurl stdenv noSysDirs;
@ -365,7 +373,8 @@ rec {
cross = "sparc-linux"; cross = "sparc-linux";
}; };
patchelf = (import ../development/tools/misc/patchelf) { patchelf = useFromStdenv (stdenv ? patchelf) stdenv.patchelf
(import ../development/tools/misc/patchelf) {
inherit fetchurl stdenv; inherit fetchurl stdenv;
}; };
@ -458,9 +467,10 @@ rec {
inherit fetchurl stdenv readline ncurses g77 perl flex; inherit fetchurl stdenv readline ncurses g77 perl flex;
}; };
gnumake = (import ../development/tools/build-managers/gnumake) { gnumake = useFromStdenv (stdenv ? gnumake) stdenv.gnumake
(import ../development/tools/build-managers/gnumake {
inherit fetchurl stdenv; inherit fetchurl stdenv;
}; });
mk = (import ../development/tools/build-managers/mk) { mk = (import ../development/tools/build-managers/mk) {
inherit fetchurl stdenv; inherit fetchurl stdenv;
@ -2233,14 +2243,12 @@ rec {
}; };
#nixStatic = (import ../misc/nix-static) { #nixStatic = (import ../misc/nix-static) {
# inherit fetchurl stdenv aterm perl; # inherit fetchurl stdenv aterm perl curl;
# curl = bootCurl; /* !!! ugly */
# bdb = db4; # bdb = db4;
#}; #};
nix = (import ../misc/nix) { nix = (import ../misc/nix) {
inherit fetchurl stdenv aterm perl; inherit fetchurl stdenv aterm perl curl;
curl = bootCurl; /* !!! ugly */
bdb = db4; bdb = db4;
}; };
@ -2272,4 +2280,5 @@ rec {
joe = (import ../applications/editors/joe) { joe = (import ../applications/editors/joe) {
inherit stdenv fetchurl; inherit stdenv fetchurl;
}; };
} }