2005-02-21 21:42:07 +01:00
|
|
|
# This file constructs the standard build environment for the
|
|
|
|
# Linux/i686 platform. It's completely pure; that is, it relies on no
|
|
|
|
# external (non-Nix) tools, such as /usr/bin/gcc, and it contains a C
|
|
|
|
# compiler and linker that do not search in default locations,
|
|
|
|
# ensuring purity of components produced by it.
|
|
|
|
|
|
|
|
{allPackages}:
|
|
|
|
|
2004-11-04 13:19:32 +01:00
|
|
|
rec {
|
2004-10-19 17:16:14 +02:00
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
# The bootstrap process proceeds in several steps.
|
|
|
|
|
|
|
|
# 1) Create a standard environment by downloading pre-built
|
|
|
|
# statically linked binaries of coreutils, gcc, etc.
|
|
|
|
|
|
|
|
# To fetch the pre-built binaries, we use a statically linked `curl'
|
|
|
|
# binary which is unpacked here.
|
2004-11-04 13:19:32 +01:00
|
|
|
curl = derivation {
|
|
|
|
name = "curl";
|
2005-02-22 08:59:15 +01:00
|
|
|
builder = ./tools/bash;
|
|
|
|
tar = ./tools/tar;
|
|
|
|
bunzip2 = ./tools/bunzip2;
|
2004-11-04 13:19:32 +01:00
|
|
|
cp = ./tools/cp;
|
2005-12-28 03:02:56 +01:00
|
|
|
curl = ./tools/curl-7.15.1-static.tar.bz2;
|
2004-11-04 13:19:32 +01:00
|
|
|
system = "i686-linux";
|
2005-02-22 10:55:03 +01:00
|
|
|
args = [ ./scripts/unpack-curl.sh ];
|
|
|
|
};
|
|
|
|
|
|
|
|
# This function downloads a file.
|
|
|
|
download = {url, md5, pkgname}: derivation {
|
|
|
|
name = baseNameOf (toString url);
|
|
|
|
system = "i686-linux";
|
|
|
|
builder = ./tools/bash;
|
|
|
|
inherit curl url;
|
|
|
|
args = [ ./scripts/download.sh ];
|
|
|
|
|
|
|
|
# Nix 0.8 fixed-output derivations.
|
|
|
|
outputHashAlgo = "md5";
|
|
|
|
outputHash = md5;
|
|
|
|
|
|
|
|
# Compatibility with Nix <= 0.7.
|
|
|
|
id = md5;
|
2004-11-04 13:19:32 +01:00
|
|
|
};
|
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
# This function downloads and unpacks a file.
|
2005-02-22 10:55:03 +01:00
|
|
|
downloadAndUnpack =
|
|
|
|
{ url, md5, pkgname, postProcess ? [], addToPath ? []
|
2005-02-21 17:03:34 +01:00
|
|
|
, extra ? null, extra2 ? null
|
|
|
|
, extra3 ? null, extra4? null, patchelf ? null}:
|
|
|
|
derivation {
|
2004-11-04 13:19:32 +01:00
|
|
|
name = pkgname;
|
2005-02-22 10:55:03 +01:00
|
|
|
system = "i686-linux";
|
2005-02-22 08:59:15 +01:00
|
|
|
builder = ./tools/bash;
|
|
|
|
tar = ./tools/tar;
|
|
|
|
bunzip2 = ./tools/bunzip2;
|
2004-11-04 13:19:32 +01:00
|
|
|
cp = ./tools/cp;
|
2005-02-22 10:55:03 +01:00
|
|
|
args = [ ./scripts/unpack.sh ];
|
|
|
|
tarball = download {inherit url md5 pkgname;};
|
2005-02-21 17:03:34 +01:00
|
|
|
inherit postProcess addToPath extra extra2 extra3 extra4 patchelf;
|
2004-11-04 13:19:32 +01:00
|
|
|
};
|
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
# The various statically linked components that make up the standard
|
|
|
|
# environment.
|
2005-02-22 10:55:03 +01:00
|
|
|
staticTools = downloadAndUnpack {
|
2005-08-22 10:39:27 +02:00
|
|
|
url = http://nix.cs.uu.nl/dist/tarballs/stdenv-linux/static-tools.tar.bz2;
|
2005-02-22 08:59:15 +01:00
|
|
|
pkgname = "static-tools";
|
2005-02-23 15:15:33 +01:00
|
|
|
md5 = "90578c603079313123e8c754a85e40d7";
|
2005-02-21 17:03:34 +01:00
|
|
|
};
|
2004-11-04 13:19:32 +01:00
|
|
|
|
2005-02-22 10:55:03 +01:00
|
|
|
binutils = downloadAndUnpack {
|
2005-08-22 10:39:27 +02:00
|
|
|
url = http://nix.cs.uu.nl/dist/tarballs/stdenv-linux/binutils-2.15-static.tar.bz2;
|
2005-02-21 17:03:34 +01:00
|
|
|
pkgname = "binutils";
|
2005-02-22 10:55:03 +01:00
|
|
|
md5 = "9c134038b7f1894a4b307d600207047c";
|
2005-02-21 17:03:34 +01:00
|
|
|
};
|
2004-11-04 13:19:32 +01:00
|
|
|
|
2006-07-10 17:42:19 +02:00
|
|
|
staticGCC = (downloadAndUnpack {
|
2005-08-22 10:39:27 +02:00
|
|
|
url = http://nix.cs.uu.nl/dist/tarballs/stdenv-linux/gcc-3.4.2-static.tar.bz2;
|
2005-02-21 17:03:34 +01:00
|
|
|
pkgname = "gcc";
|
2005-02-22 10:55:03 +01:00
|
|
|
md5 = "600452fac470a49a41ea81d39c209f35";
|
2005-02-21 17:03:34 +01:00
|
|
|
postProcess = [./scripts/fix-outpath.sh];
|
2005-02-22 08:59:15 +01:00
|
|
|
addToPath = [staticTools];
|
2005-02-21 17:03:34 +01:00
|
|
|
}) // { langC = true; langCC = false; langF77 = false; };
|
2004-10-19 17:16:14 +02:00
|
|
|
|
2005-02-22 10:55:03 +01:00
|
|
|
glibc = downloadAndUnpack {
|
2005-08-22 10:39:27 +02:00
|
|
|
url = http://nix.cs.uu.nl/dist/tarballs/stdenv-linux/glibc-2.3.3-static.tar.bz2;
|
2004-11-04 13:19:32 +01:00
|
|
|
pkgname = "glibc";
|
2005-02-22 10:55:03 +01:00
|
|
|
md5 = "36ff244e666c60784edfe1cc66f68e4c";
|
2005-02-22 08:59:15 +01:00
|
|
|
postProcess = [./scripts/fix-outpath.sh];
|
|
|
|
addToPath = [staticTools];
|
2004-11-04 13:19:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-07-10 17:42:19 +02:00
|
|
|
# A helper function to call gcc-wrapper.
|
|
|
|
wrapGCC =
|
|
|
|
{gcc ? staticGCC, glibc, binutils, shell ? ""}:
|
|
|
|
(import ../../build-support/gcc-wrapper) {
|
|
|
|
nativeTools = false;
|
|
|
|
nativeGlibc = false;
|
|
|
|
inherit gcc binutils glibc shell;
|
|
|
|
stdenv = stdenvInitial;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
# The "fake" standard environment used to build "real" standard
|
2005-02-22 08:59:15 +01:00
|
|
|
# environments. It consists of just the basic statically linked
|
|
|
|
# tools.
|
2005-02-21 21:42:07 +01:00
|
|
|
stdenvInitial = let {
|
2005-02-21 17:03:34 +01:00
|
|
|
body = derivation {
|
2005-02-22 08:59:15 +01:00
|
|
|
name = "stdenv-linux-initial";
|
2004-11-04 13:19:32 +01:00
|
|
|
system = "i686-linux";
|
2005-02-22 08:59:15 +01:00
|
|
|
builder = ./tools/bash;
|
2004-11-04 13:19:32 +01:00
|
|
|
args = ./scripts/builder-stdenv-initial.sh;
|
2005-02-22 08:59:15 +01:00
|
|
|
inherit staticTools;
|
2004-11-04 13:19:32 +01:00
|
|
|
} // {
|
2006-03-24 15:20:31 +01:00
|
|
|
mkDerivation = attrs: derivation ((removeAttrs attrs ["meta"]) // {
|
2005-02-22 08:59:15 +01:00
|
|
|
builder = ./tools/bash;
|
2004-11-04 13:19:32 +01:00
|
|
|
args = ["-e" attrs.builder];
|
|
|
|
stdenv = body;
|
|
|
|
system = body.system;
|
|
|
|
});
|
2005-02-22 08:59:15 +01:00
|
|
|
shell = ./tools/bash;
|
2004-11-04 13:19:32 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-02-21 21:42:07 +01:00
|
|
|
# This function builds the various standard environments used during
|
|
|
|
# the bootstrap.
|
2006-02-09 18:04:18 +01:00
|
|
|
stdenvBootFun =
|
2006-07-10 17:42:19 +02:00
|
|
|
{gcc, staticGlibc, extraAttrs ? {}}:
|
2006-02-09 18:04:18 +01:00
|
|
|
|
|
|
|
import ../generic {
|
|
|
|
name = "stdenv-linux-boot";
|
|
|
|
param1 = if staticGlibc then "static" else "dynamic";
|
|
|
|
preHook = ./prehook.sh;
|
2004-11-04 13:19:32 +01:00
|
|
|
stdenv = stdenvInitial;
|
2006-02-09 18:04:18 +01:00
|
|
|
shell = ./tools/bash;
|
|
|
|
initialPath = [
|
|
|
|
staticTools
|
|
|
|
];
|
2006-07-10 17:42:19 +02:00
|
|
|
inherit gcc extraAttrs;
|
2004-11-04 13:19:32 +01:00
|
|
|
};
|
2005-02-21 21:42:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Create the first "real" standard environment. This one consists
|
|
|
|
# of statically linked components only, and a minimal glibc to keep
|
|
|
|
# the gcc configure script happy.
|
|
|
|
stdenvLinuxBoot1 = stdenvBootFun {
|
|
|
|
# Use the statically linked, downloaded glibc/gcc/binutils.
|
2006-07-10 17:42:19 +02:00
|
|
|
gcc = wrapGCC {inherit glibc binutils;};
|
2005-02-21 21:42:07 +01:00
|
|
|
staticGlibc = true;
|
2006-02-09 18:04:18 +01:00
|
|
|
extraAttrs = {inherit curl;};
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
# 2) These are the packages that we can build with the first
|
|
|
|
# stdenv. We only need Glibc (in step 3).
|
|
|
|
stdenvLinuxBoot1Pkgs = allPackages {
|
2006-02-08 18:37:45 +01:00
|
|
|
bootStdenv = stdenvLinuxBoot1;
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
# 3) Build Glibc with the statically linked tools. The result is the
|
|
|
|
# full, dynamically linked, final Glibc.
|
|
|
|
stdenvLinuxGlibc = stdenvLinuxBoot1Pkgs.glibc;
|
|
|
|
|
|
|
|
# 4) Construct a second stdenv identical to the first, except that
|
|
|
|
# this one uses the Glibc built in step 3. It still uses
|
|
|
|
# statically linked tools.
|
2006-07-10 17:42:19 +02:00
|
|
|
stdenvLinuxBoot2 = removeAttrs (stdenvBootFun {
|
2005-02-21 21:42:07 +01:00
|
|
|
staticGlibc = false;
|
2006-07-10 17:42:19 +02:00
|
|
|
gcc = wrapGCC {inherit binutils; glibc = stdenvLinuxGlibc;};
|
|
|
|
extraAttrs = {inherit curl; glibc = stdenvLinuxGlibc;};
|
|
|
|
}) ["gcc" "binutils"];
|
2005-02-21 21:42:07 +01:00
|
|
|
|
|
|
|
# 5) The packages that can be built using the second stdenv.
|
|
|
|
stdenvLinuxBoot2Pkgs = allPackages {
|
2006-02-08 18:37:45 +01:00
|
|
|
bootStdenv = stdenvLinuxBoot2;
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
# 6) Construct a third stdenv identical to the second, except that
|
|
|
|
# this one uses the dynamically linked GCC and Binutils from step
|
|
|
|
# 5. The other tools (e.g. coreutils) are still static.
|
|
|
|
stdenvLinuxBoot3 = stdenvBootFun {
|
|
|
|
staticGlibc = false;
|
2006-07-10 17:42:19 +02:00
|
|
|
gcc = wrapGCC {
|
|
|
|
inherit (stdenvLinuxBoot2Pkgs) binutils;
|
|
|
|
glibc = stdenvLinuxGlibc;
|
|
|
|
gcc = stdenvLinuxBoot2Pkgs.gcc.gcc;
|
|
|
|
};
|
2006-02-09 18:04:18 +01:00
|
|
|
extraAttrs = {inherit curl;};
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
# 7) The packages that can be built using the third stdenv.
|
|
|
|
stdenvLinuxBoot3Pkgs = allPackages {
|
2006-02-08 18:37:45 +01:00
|
|
|
bootStdenv = stdenvLinuxBoot3;
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
# 8) Construct the final stdenv. It uses the Glibc, GCC and
|
|
|
|
# Binutils built above, and adds in dynamically linked versions
|
|
|
|
# of all other tools.
|
|
|
|
stdenvLinux = (import ../generic) {
|
2005-02-22 08:59:15 +01:00
|
|
|
name = "stdenv-linux";
|
2005-02-21 21:42:07 +01:00
|
|
|
preHook = ./prehook.sh;
|
|
|
|
initialPath = [
|
2006-07-14 10:35:59 +02:00
|
|
|
((import ../common-path.nix) {pkgs = stdenvLinuxBoot3Pkgs;})
|
2005-02-21 21:42:07 +01:00
|
|
|
stdenvLinuxBoot3Pkgs.patchelf
|
|
|
|
];
|
|
|
|
|
|
|
|
stdenv = stdenvInitial;
|
|
|
|
|
2006-07-10 17:42:19 +02:00
|
|
|
gcc = wrapGCC {
|
|
|
|
inherit (stdenvLinuxBoot2Pkgs) binutils;
|
2005-02-21 21:42:07 +01:00
|
|
|
glibc = stdenvLinuxGlibc;
|
2006-07-10 17:42:19 +02:00
|
|
|
gcc = stdenvLinuxBoot2Pkgs.gcc.gcc;
|
2006-08-09 17:05:30 +02:00
|
|
|
shell = stdenvLinuxBoot3Pkgs.bash + /bin/sh;
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
2006-08-09 17:05:30 +02:00
|
|
|
shell = stdenvLinuxBoot3Pkgs.bash + /bin/sh;
|
2006-02-09 18:04:18 +01:00
|
|
|
|
|
|
|
extraAttrs = {
|
|
|
|
curl = stdenvLinuxBoot3Pkgs.realCurl;
|
2006-07-10 17:42:19 +02:00
|
|
|
inherit (stdenvLinuxBoot2Pkgs) binutils /* gcc */ glibc;
|
2006-02-09 18:04:18 +01:00
|
|
|
inherit (stdenvLinuxBoot3Pkgs)
|
|
|
|
gzip bzip2 bash coreutils diffutils findutils gawk
|
|
|
|
gnumake gnused gnutar gnugrep patch patchelf;
|
|
|
|
};
|
2005-02-21 21:42:07 +01:00
|
|
|
};
|
|
|
|
|
2004-10-19 17:16:14 +02:00
|
|
|
}
|