summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pkgs/build-support/gcc-wrapper/default.nix5
-rw-r--r--pkgs/stdenv/cygwin/default.nix25
-rw-r--r--pkgs/stdenv/cygwin/prehook.sh7
-rw-r--r--pkgs/stdenv/default.nix49
-rw-r--r--pkgs/stdenv/freebsd/default.nix25
-rw-r--r--pkgs/stdenv/freebsd/prehook.sh7
-rw-r--r--pkgs/stdenv/generic/default.nix6
-rw-r--r--pkgs/stdenv/linux/default.nix3
-rw-r--r--pkgs/stdenv/native/default.nix111
-rw-r--r--pkgs/stdenv/native/prehook.sh1
-rw-r--r--pkgs/stdenv/nix/default.nix6
-rw-r--r--pkgs/stdenv/powerpc-darwin/default.nix25
-rw-r--r--pkgs/stdenv/powerpc-darwin/prehook.sh6
-rw-r--r--pkgs/top-level/all-packages.nix17
14 files changed, 121 insertions, 172 deletions
diff --git a/pkgs/build-support/gcc-wrapper/default.nix b/pkgs/build-support/gcc-wrapper/default.nix
index 6e67bbf74e6b..1cd84d775472 100644
--- a/pkgs/build-support/gcc-wrapper/default.nix
+++ b/pkgs/build-support/gcc-wrapper/default.nix
@@ -21,7 +21,10 @@ stdenv.mkDerivation {
   utils = ./utils.sh;
   addFlags = ./add-flags;
   
-  inherit nativeTools nativeLibc nativePrefix gcc libc binutils;
+  inherit nativeTools nativeLibc nativePrefix gcc;
+  libc = if nativeLibc then null else libc;
+  binutils = if nativeTools then null else binutils;
+  
   name = if name == "" then gcc.name else name;
   langC = if nativeTools then true else gcc.langC;
   langCC = if nativeTools then true else gcc.langCC;
diff --git a/pkgs/stdenv/cygwin/default.nix b/pkgs/stdenv/cygwin/default.nix
deleted file mode 100644
index b1ca853c612b..000000000000
--- a/pkgs/stdenv/cygwin/default.nix
+++ /dev/null
@@ -1,25 +0,0 @@
-{stdenv, genericStdenv, gccWrapper}:
-
-genericStdenv {
-  name = "stdenv-native";
-  preHook = ./prehook.sh;
-  initialPath = "/usr/local /usr /";
-
-  inherit stdenv;
-
-  gcc = gccWrapper {
-    name = "gcc-native";
-    nativeTools = true;
-    nativeLibc = true;
-    nativePrefix = "/usr";
-    inherit stdenv;
-  };
-
-  shell = "/bin/bash";
-
-  fetchurlBoot = import ../../build-support/fetchurl {
-    inherit stdenv;
-    # Curl should be in /usr/bin or so.
-    curl = null;
-  };
-}
diff --git a/pkgs/stdenv/cygwin/prehook.sh b/pkgs/stdenv/cygwin/prehook.sh
deleted file mode 100644
index b2ada869b290..000000000000
--- a/pkgs/stdenv/cygwin/prehook.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-export NIX_ENFORCE_PURITY=
-
-if test -z "$cygwinConfigureEnableShared"; then
-  export configureFlags="$configureFlags --disable-shared"
-fi
-
-PATH_DELIMITER=';'
diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix
index f5f47427f659..d8bab3c42068 100644
--- a/pkgs/stdenv/default.nix
+++ b/pkgs/stdenv/default.nix
@@ -17,12 +17,9 @@ assert system != "i686-cygwin" -> system == stdenvType;
 
 rec {
 
-  gccWrapper = import ../build-support/gcc-wrapper;
-  genericStdenv = import ./generic;
-
 
   # Trivial environment used for building other environments.
-  stdenvInitial = (import ./initial) {
+  stdenvInitial = import ./initial {
     name = "stdenv-initial";
     inherit system;
   };
@@ -33,9 +30,8 @@ rec {
   # i.e., the stuff in /bin, /usr/bin, etc.  This environment should
   # be used with care, since many Nix packages will not build properly
   # with it (e.g., because they require GNU Make).
-  stdenvNative = (import ./native) {
-    stdenv = stdenvInitial;
-    inherit genericStdenv gccWrapper;
+  stdenvNative = import ./native {
+    inherit stdenvInitial;
   };
 
   stdenvNativePkgs = allPackages {
@@ -45,13 +41,9 @@ rec {
 
 
   # The Nix build environment.
-  stdenvNix = (import ./nix) (rec {
-    stdenv = if system == "i686-darwin" then stdenvPowerpcDarwin else stdenvNative; # !!! hack
-    pkgs = allPackages {
-      inherit system;
-      bootStdenv = removeAttrs stdenv ["gcc"]; # Hack
-      noSysDirs = false;
-    };
+  stdenvNix = import ./nix (rec {
+    stdenv = stdenvNative;
+    pkgs = stdenvNativePkgs;
   });
 
 
@@ -59,32 +51,8 @@ rec {
   stdenvLinux = (import ./linux {inherit system allPackages;}).stdenvLinux;
 
     
-  # powerpc-darwin (Mac OS X) standard environment.  Very simple for now
-  # (essentially it's just the native environment).
-  stdenvPowerpcDarwin = (import ./powerpc-darwin) {
-    stdenv = stdenvInitial;
-    inherit genericStdenv gccWrapper;
-  };
-
-
-  # FreeBSD standard environment.  Right now this is more or less the
-  # same as the native environemnt.  Eventually we'll want a pure
-  # environment similar to stdenvLinux.
-  stdenvFreeBSD = (import ./freebsd) {
-    stdenv = stdenvInitial;
-    inherit genericStdenv gccWrapper;
-  };
-
-
-  # Cygwin standard environment.
-  stdenvCygwin = (import ./cygwin) {
-    stdenv = stdenvInitial;
-    inherit genericStdenv gccWrapper;
-  };
-
-  
   # MinGW/MSYS standard environment.
-  stdenvMinGW = (import ./mingw) {
+  stdenvMinGW = import ./mingw {
     inherit system;
   };
 
@@ -94,10 +62,7 @@ rec {
     if stdenvType == "i686-linux" then stdenvLinux else
     if stdenvType == "x86_64-linux" then stdenvLinux else
     if stdenvType == "powerpc-linux" then stdenvLinux else
-    if stdenvType == "i686-freebsd" then stdenvFreeBSD else
-    if stdenvType == "i686-cygwin" then stdenvCygwin else
     if stdenvType == "i686-mingw" then stdenvMinGW else
-    if stdenvType == "powerpc-darwin" then stdenvPowerpcDarwin else
     if stdenvType == "i686-darwin" then stdenvNix else
     stdenvNative;
 }
diff --git a/pkgs/stdenv/freebsd/default.nix b/pkgs/stdenv/freebsd/default.nix
deleted file mode 100644
index b1ca853c612b..000000000000
--- a/pkgs/stdenv/freebsd/default.nix
+++ /dev/null
@@ -1,25 +0,0 @@
-{stdenv, genericStdenv, gccWrapper}:
-
-genericStdenv {
-  name = "stdenv-native";
-  preHook = ./prehook.sh;
-  initialPath = "/usr/local /usr /";
-
-  inherit stdenv;
-
-  gcc = gccWrapper {
-    name = "gcc-native";
-    nativeTools = true;
-    nativeLibc = true;
-    nativePrefix = "/usr";
-    inherit stdenv;
-  };
-
-  shell = "/bin/bash";
-
-  fetchurlBoot = import ../../build-support/fetchurl {
-    inherit stdenv;
-    # Curl should be in /usr/bin or so.
-    curl = null;
-  };
-}
diff --git a/pkgs/stdenv/freebsd/prehook.sh b/pkgs/stdenv/freebsd/prehook.sh
deleted file mode 100644
index a82f5d21dfce..000000000000
--- a/pkgs/stdenv/freebsd/prehook.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-export NIX_ENFORCE_PURITY=
-alias make=gmake
-export MAKE=gmake
-shopt -s expand_aliases
-
-# Filter out stupid GCC warnings (in gcc-wrapper).
-export NIX_GCC_NEEDS_GREP=1
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index 048bc179e2d2..029e4b95482e 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -1,7 +1,7 @@
 { stdenv, name, preHook ? null, postHook ? null, initialPath, gcc, shell
 , param1 ? "", param2 ? "", param3 ? "", param4 ? "", param5 ? ""
 , extraAttrs ? {}
-, fetchurlBoot
+, fetchurlBoot, forceFetchurlBoot
 }:
 
 let {
@@ -80,7 +80,9 @@ let {
       # "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;
+      // extraAttrs
+
+      // (if forceFetchurlBoot then {fetchurl = fetchurlBoot;} else {});
 
   }.result;
 
diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix
index fdb7326958ea..eea8cf04e584 100644
--- a/pkgs/stdenv/linux/default.nix
+++ b/pkgs/stdenv/linux/default.nix
@@ -114,7 +114,7 @@ rec {
       shell = bootstrapTools.bash;
       initialPath = [staticTools] ++ extraPath;
       inherit fetchurlBoot;
-      extraAttrs = extraAttrs // {fetchurl = fetchurlBoot;};
+      forceFetchurlBoot = true;
       inherit gcc;
     };
 
@@ -211,6 +211,7 @@ rec {
     shell = stdenvLinuxBoot3Pkgs.bash + "/bin/sh";
     
     fetchurlBoot = stdenvLinuxBoot3.fetchurlBoot;
+    forceFetchurlBoot = false;
     
     extraAttrs = {
       inherit (stdenvLinuxBoot2Pkgs) binutils /* gcc */ glibc;
diff --git a/pkgs/stdenv/native/default.nix b/pkgs/stdenv/native/default.nix
index 22e223ca6cc1..ee2f9e9eb9f1 100644
--- a/pkgs/stdenv/native/default.nix
+++ b/pkgs/stdenv/native/default.nix
@@ -1,24 +1,101 @@
-{stdenv, genericStdenv, gccWrapper}:
+{stdenvInitial}:
 
-genericStdenv {
-  name = "stdenv-native";
-  preHook = ./prehook.sh;
-  initialPath = "/usr/local /usr /";
+let
 
-  inherit stdenv;
+  system = stdenvInitial.system;
 
-  gcc = gccWrapper {
-    name = "gcc-native";
-    nativeTools = true;
-    nativeLibc = true;
-    nativePrefix = "/usr";
-    inherit stdenv;
+  shell = "/bin/bash";
+
+
+  prehookBase = builtins.toFile "prehook-base.sh" ''
+    # Disable purity tests; it's allowed (even needed) to link to
+    # libraries outside the Nix store (like the C library).
+    export NIX_ENFORCE_PURITY=
+  '';
+
+  prehookDarwin = builtins.toFile "prehook-darwin.sh" ''
+    source ${prehookBase}
+    export NIX_DONT_SET_RPATH=1
+    export NIX_NO_SELF_RPATH=1
+    dontFixLibtool=1
+    NIX_STRIP_DEBUG=0
+    stripAllFlags=" " # the Darwin "strip" command doesn't know "-s" 
+  '';
+
+  prehookFreeBSD = builtins.toFile "prehook-freebsd.sh" ''
+    source ${prehookBase}
+    
+    alias make=gmake
+    export MAKE=gmake
+    shopt -s expand_aliases
+
+    # Filter out stupid GCC warnings (in gcc-wrapper).
+    export NIX_GCC_NEEDS_GREP=1
+  '';
+
+  prehookCygwin = builtins.toFile "prehook-cygwin.sh" ''
+    source ${prehookBase}
+    
+    if test -z "$cygwinConfigureEnableShared"; then
+      export configureFlags="$configureFlags --disable-shared"
+    fi
+
+    PATH_DELIMITER=';'
+  '';
+
+
+  # A function that builds a "native" stdenv (one that uses tools in
+  # /usr etc.).  
+  makeStdenv = {stdenvBoot, extraPath, forceFetchurlBoot}: import ../generic {
+    name = "stdenv-native";
+
+    preHook =
+      if system == "i686-darwin" || system == "powerpc-darwin" then prehookDarwin else
+      if system == "i686-freebsd" then prehookFreeBSD else
+      prehookBase;
+
+    initialPath = extraPath ++ ["/" "/usr" "/usr/local"];
+
+    stdenv = stdenvBoot;
+
+    gcc = import ../../build-support/gcc-wrapper {
+      name = "gcc-native";
+      nativeTools = true;
+      nativeLibc = true;
+      nativePrefix = "/usr";
+      stdenv = stdenvBoot;
+    };
+
+    inherit shell forceFetchurlBoot;
+
+    fetchurlBoot = import ../../build-support/fetchurl {
+      stdenv = stdenvBoot;
+      # Curl should be in /usr/bin or so.
+      curl = null;
+    };
   };
 
-  shell = "/bin/bash";
 
-  extraAttrs = {
-    # Curl should be in /usr/bin or so.
-    curl = null;
+  # First build a stdenv based only on tools outside the store.
+  stdenvBoot1 = makeStdenv {
+    stdenvBoot = stdenvInitial;
+    extraPath = [];
+    forceFetchurlBoot = true;
   };
-}
+
+  stdenvBoot1Pkgs = import ../../.. {
+    inherit system;
+    bootStdenv = stdenvBoot1;
+  };
+
+
+  # Using that, build a stdenv that adds the `replace' command (which
+  # most systems don't have, so we mustn't rely on the native
+  # environment providing it).
+  stdenvBoot2 = makeStdenv {
+    stdenvBoot = stdenvBoot1;
+    extraPath = [stdenvBoot1Pkgs.replace];
+    forceFetchurlBoot = false;
+  };
+
+in stdenvBoot2
diff --git a/pkgs/stdenv/native/prehook.sh b/pkgs/stdenv/native/prehook.sh
deleted file mode 100644
index 1714586999e1..000000000000
--- a/pkgs/stdenv/native/prehook.sh
+++ /dev/null
@@ -1 +0,0 @@
-export NIX_ENFORCE_PURITY=
diff --git a/pkgs/stdenv/nix/default.nix b/pkgs/stdenv/nix/default.nix
index fb7d29323ee3..23471267302d 100644
--- a/pkgs/stdenv/nix/default.nix
+++ b/pkgs/stdenv/nix/default.nix
@@ -22,8 +22,6 @@ import ../generic {
 
   shell = pkgs.bash + "/bin/sh";
 
-  fetchurlBoot = import ../../build-support/fetchurl {
-    inherit stdenv;
-    curl = pkgs.curl;
-  };
+  fetchurlBoot = stdenv.fetchurlBoot;
+  forceFetchurlBoot = false;
 }
diff --git a/pkgs/stdenv/powerpc-darwin/default.nix b/pkgs/stdenv/powerpc-darwin/default.nix
deleted file mode 100644
index 2c94234c0c2a..000000000000
--- a/pkgs/stdenv/powerpc-darwin/default.nix
+++ /dev/null
@@ -1,25 +0,0 @@
-{stdenv, genericStdenv, gccWrapper}:
-
-genericStdenv {
-  name = "stdenv-darwin";
-  preHook = ./prehook.sh;
-  initialPath = "/usr/local /usr /";
-
-  inherit stdenv;
-
-  gcc = gccWrapper {
-    name = "gcc-darwin";
-    nativeTools = true;
-    nativeLibc = true;
-    nativePrefix = "/usr";
-    inherit stdenv;
-  };
-
-  shell = "/bin/sh";
-
-  fetchurlBoot = import ../../build-support/fetchurl {
-    inherit stdenv;
-    # Curl should be in /usr/bin or so.
-    curl = null;
-  };
-}
diff --git a/pkgs/stdenv/powerpc-darwin/prehook.sh b/pkgs/stdenv/powerpc-darwin/prehook.sh
deleted file mode 100644
index 0232ee2bb6f3..000000000000
--- a/pkgs/stdenv/powerpc-darwin/prehook.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-export NIX_ENFORCE_PURITY=
-export NIX_DONT_SET_RPATH=1
-export NIX_NO_SELF_RPATH=1
-dontFixLibtool=1
-NIX_STRIP_DEBUG=0
-stripAllFlags=" " # the Darwin "strip" command doesn't know "-s" 
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index cdf2fa1c3836..04ff11d861a9 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -247,11 +247,12 @@ let pkgs = rec {
   ### STANDARD ENVIRONMENT
 
 
-  defaultStdenv =
-    (import ../stdenv {
-      inherit system stdenvType;
-      allPackages = import ./all-packages.nix;
-    }).stdenv;
+  allStdenvs = import ../stdenv {
+    inherit system stdenvType;
+    allPackages = import ./all-packages.nix;
+  };
+
+  defaultStdenv = allStdenvs.stdenv;
 
   stdenv =
     if bootStdenv != null then bootStdenv else
@@ -1713,17 +1714,15 @@ let pkgs = rec {
     inherit fetchurl stdenv visualcpp windowssdk;
   };
 
-  wrapGCC = baseGCC: wrapGCCWithGlibc baseGCC glibc;
-
-  wrapGCCWithGlibc = baseGCC: glibc: import ../build-support/gcc-wrapper {
+  wrapGCC = baseGCC: import ../build-support/gcc-wrapper {
     nativeTools = stdenv ? gcc && stdenv.gcc.nativeTools;
     nativeLibc = stdenv ? gcc && stdenv.gcc.nativeLibc;
+    nativePrefix = if stdenv ? gcc then stdenv.gcc.nativePrefix else "";
     gcc = baseGCC;
     libc = glibc;
     inherit stdenv binutils;
   };
 
-
   # FIXME: This is a specific hack for GCC-UPC.  Eventually, we may
   # want to merge `gcc-upc-wrapper' and `gcc-wrapper'.
   wrapGCCUPC = baseGCC: import ../build-support/gcc-upc-wrapper {