about summary refs log tree commit diff
path: root/pkgs/stdenv
diff options
context:
space:
mode:
authorEric Seidel <gridaphobe@gmail.com>2015-02-03 14:04:19 -0800
committerEric Seidel <gridaphobe@gmail.com>2015-02-03 14:05:22 -0800
commit92188d9d1751892ddbf8913da73dfc150d18fadb (patch)
tree81c2a35bcb32c6e91e0502aededf492160b2f861 /pkgs/stdenv
parent6f7632a7bddf32d6888780f254827cb52a3e6a90 (diff)
downloadnixlib-92188d9d1751892ddbf8913da73dfc150d18fadb.tar
nixlib-92188d9d1751892ddbf8913da73dfc150d18fadb.tar.gz
nixlib-92188d9d1751892ddbf8913da73dfc150d18fadb.tar.bz2
nixlib-92188d9d1751892ddbf8913da73dfc150d18fadb.tar.lz
nixlib-92188d9d1751892ddbf8913da73dfc150d18fadb.tar.xz
nixlib-92188d9d1751892ddbf8913da73dfc150d18fadb.tar.zst
nixlib-92188d9d1751892ddbf8913da73dfc150d18fadb.zip
new darwin stdenv
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r--pkgs/stdenv/darwin/default.nix166
-rw-r--r--pkgs/stdenv/darwin/trivialBootstrap.sh66
-rw-r--r--pkgs/stdenv/default.nix23
3 files changed, 200 insertions, 55 deletions
diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix
index 15895956fd0f..7283f35f75a5 100644
--- a/pkgs/stdenv/darwin/default.nix
+++ b/pkgs/stdenv/darwin/default.nix
@@ -1,43 +1,141 @@
-{ stdenv, pkgs, config
-, haveLibCxx ? true
-, useClang33 ? true }:
-
-import ../generic rec {
-  inherit config;
-
-  preHook =
-    ''
-      export NIX_ENFORCE_PURITY=
-      export NIX_IGNORE_LD_THROUGH_GCC=1
-      export NIX_DONT_SET_RPATH=1
-      export NIX_NO_SELF_RPATH=1
-      ${import ./prehook.nix}
-    '';
+{ system      ? builtins.currentSystem
+, allPackages ? import ../../top-level/all-packages.nix
+, platform    ? null
+, config      ? {}
+}:
+
+rec {
+  allPackages = import ../../top-level/all-packages.nix;
+
+  bootstrapTools = derivation {
+    inherit system;
+
+    name    = "trivial-bootstrap-tools";
+    builder = "/bin/sh";
+    args    = [ ./trivialBootstrap.sh ];
+
+    mkdir   = "/bin/mkdir";
+    ln      = "/bin/ln";
+  };
+
+  # The simplest stdenv possible to run fetchadc and get the Apple command-line tools
+  stage0 = rec {
+    fetchurl = import ../../build-support/fetchurl {
+      inherit stdenv;
+      curl = bootstrapTools;
+    };
+
+    stdenv = import ../generic {
+      inherit system config;
+      name         = "stdenv-darwin-boot-0";
+      shell        = "/bin/bash";
+      initialPath  = [ bootstrapTools ];
+      fetchurlBoot = fetchurl;
+      cc           = "/no-such-path";
+    };
+  };
+
+  buildTools = import ../../os-specific/darwin/command-line-tools {
+    inherit (stage0) stdenv fetchurl;
+    xar  = bootstrapTools;
+    gzip = bootstrapTools;
+    cpio = bootstrapTools;
+  };
+
+  preHook = ''
+    export NIX_IGNORE_LD_THROUGH_GCC=1
+    export NIX_DONT_SET_RPATH=1
+    export NIX_NO_SELF_RPATH=1
+    dontFixLibtool=1
+    stripAllFlags=" " # the Darwin "strip" command doesn't know "-s"
+    xargsFlags=" "
+    export MACOSX_DEPLOYMENT_TARGET=10.7
+    export SDKROOT=
+    export SDKROOT_X=/ # FIXME: impure!
+    export NIX_CFLAGS_COMPILE+=" --sysroot=/var/empty -idirafter $SDKROOT_X/usr/include -F$SDKROOT_X/System/Library/Frameworks -Wno-multichar -Wno-deprecated-declarations"
+    export NIX_LDFLAGS_AFTER+=" -L$SDKROOT_X/usr/lib"
+    export CMAKE_OSX_ARCHITECTURES=x86_64
+  '';
 
-  initialPath = (import ../common-path.nix) {pkgs = pkgs;};
+  # A stdenv that wraps the Apple command-line tools and our other trivial symlinked bootstrap tools
+  stage1 = rec {
+    nativePrefix = "${buildTools.tools}/Library/Developer/CommandLineTools/usr";
 
-  system = stdenv.system;
+    stdenv = import ../generic {
+      name = "stdenv-darwin-boot-1";
 
-  cc = import ../../build-support/cc-wrapper {
-    nativeTools = false;
-    nativeLibc = true;
-    inherit stdenv;
-    extraPackages = stdenv.lib.optional haveLibCxx pkgs.libcxx;
-    binutils = import ../../build-support/native-darwin-cctools-wrapper {inherit stdenv;};
-    cc = if useClang33 then pkgs.clang_33.cc else pkgs.clang.cc;
-    coreutils = pkgs.coreutils;
-    shell = pkgs.bash + "/bin/sh";
+      inherit system config;
+      inherit (stage0.stdenv) shell initialPath fetchurlBoot;
+
+      preHook = preHook + "\n" + ''
+        export NIX_LDFLAGS_AFTER+=" -L/usr/lib"
+        export NIX_ENFORCE_PURITY=
+        export NIX_CFLAGS_COMPILE+=" -isystem ${nativePrefix}/include/c++/v1 -stdlib=libc++"
+        export NIX_CFLAGS_LINK+=" -stdlib=libc++ -Wl,-rpath,${nativePrefix}/lib"
+      '';
+
+      cc = import ../../build-support/cc-wrapper {
+        nativeTools  = true;
+        nativePrefix = nativePrefix;
+        nativeLibc   = true;
+        stdenv       = stage0.stdenv;
+        shell        = "/bin/bash";
+        cc           = {
+          name    = "clang-9.9.9";
+          cc      = "/usr";
+          outPath = "${buildTools.tools}/Library/Developer/CommandLineTools/usr";
+        };
+      };
+    };
+    pkgs = allPackages {
+      inherit system platform;
+      bootStdenv = stdenv;
+    };
+  };
+
+  stage2 = rec {
+    stdenv = import ../generic {
+      name = "stdenv-darwin-boot-2";
+
+      inherit system config;
+      inherit (stage1.stdenv) shell fetchurlBoot preHook cc;
+
+      initialPath = [ stage1.pkgs.xz ] ++ stage1.stdenv.initialPath;
+    };
+    pkgs = allPackages {
+      inherit system platform;
+      bootStdenv = stdenv;
+    };
   };
 
-  shell = pkgs.bash + "/bin/sh";
+  # Use stage1 to build a whole set of actual tools so we don't have to rely on the Apple prebuilt ones or
+  # the ugly symlinked bootstrap tools anymore.
+  stage3 = with stage2; import ../generic {
+    name = "stdenv-darwin-boot-3";
 
-  fetchurlBoot = stdenv.fetchurlBoot;
+    inherit system config;
+    inherit (stdenv) fetchurlBoot;
 
-  overrides = pkgs_: {
-    inherit cc;
-    inherit (cc) binutils;
-    inherit (pkgs)
-      gzip bzip2 xz bash coreutils diffutils findutils gawk
-      gnumake gnused gnutar gnugrep gnupatch perl libcxx libcxxabi;
+    initialPath = (import ../common-path.nix) { inherit pkgs; };
+
+    preHook = preHook + "\n" + ''
+      export NIX_ENFORCE_PURITY=1
+    '';
+
+    cc = import ../../build-support/cc-wrapper {
+      inherit stdenv;
+      nativeTools  = false;
+      nativeLibc   = true;
+      binutils  = pkgs.darwin.cctools_native;
+      cc        = pkgs.llvmPackages.clang;
+      coreutils = pkgs.coreutils;
+      shell     = "${pkgs.bash}/bin/bash";
+    };
+
+    extraBuildInputs = [ pkgs.libcxx ];
+
+    shell = "${pkgs.bash}/bin/bash";
   };
+
+  stdenvDarwin = stage3;
 }
diff --git a/pkgs/stdenv/darwin/trivialBootstrap.sh b/pkgs/stdenv/darwin/trivialBootstrap.sh
new file mode 100644
index 000000000000..0915b378d4f0
--- /dev/null
+++ b/pkgs/stdenv/darwin/trivialBootstrap.sh
@@ -0,0 +1,66 @@
+
+# Building bootstrap tools
+echo Building the trivial bootstrap environment...
+$mkdir -p $out/bin
+
+$ln -s $ln $out/bin/ln
+
+PATH=$out/bin/
+
+cd $out/bin
+
+ln -s $mkdir
+ln -s /bin/sh
+ln -s /bin/cp
+ln -s /bin/mv
+ln -s /bin/rm
+ln -s /bin/ls
+ln -s /bin/ps
+ln -s /bin/cat
+ln -s /bin/bash
+ln -s /bin/echo
+ln -s /bin/expr
+ln -s /bin/test
+ln -s /bin/date
+ln -s /bin/chmod
+ln -s /bin/rmdir
+ln -s /bin/sleep
+ln -s /bin/hostname
+
+ln -s /usr/bin/id
+ln -s /usr/bin/od
+ln -s /usr/bin/tr
+ln -s /usr/bin/wc
+ln -s /usr/bin/cut
+ln -s /usr/bin/cmp
+ln -s /usr/bin/sed
+ln -s /usr/bin/tar
+ln -s /usr/bin/xar
+ln -s /usr/bin/awk
+ln -s /usr/bin/env
+ln -s /usr/bin/tee
+ln -s /usr/bin/comm
+ln -s /usr/bin/cpio
+ln -s /usr/bin/curl
+ln -s /usr/bin/find
+ln -s /usr/bin/grep
+ln -s /usr/bin/gzip
+ln -s /usr/bin/head
+ln -s /usr/bin/tail
+ln -s /usr/bin/sort
+ln -s /usr/bin/uniq
+ln -s /usr/bin/less
+ln -s /usr/bin/true
+ln -s /usr/bin/diff
+ln -s /usr/bin/egrep
+ln -s /usr/bin/fgrep
+ln -s /usr/bin/patch
+ln -s /usr/bin/uname
+ln -s /usr/bin/touch
+ln -s /usr/bin/split
+ln -s /usr/bin/xargs
+ln -s /usr/bin/which
+ln -s /usr/bin/install
+ln -s /usr/bin/basename
+ln -s /usr/bin/dirname
+ln -s /usr/bin/readlink
\ No newline at end of file
diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix
index de0042a9adb6..ba87a7aaafbf 100644
--- a/pkgs/stdenv/default.nix
+++ b/pkgs/stdenv/default.nix
@@ -33,30 +33,11 @@ rec {
     pkgs = stdenvNativePkgs;
   };
 
-  stdenvDarwin = import ./darwin {
-    inherit config;
-    stdenv = stdenvNative;
-    pkgs = stdenvNativePkgs;
-  };
-
-  stdenvDarwinNaked = import ./darwin {
-    inherit config;
-    stdenv = stdenvNative;
-    pkgs = stdenvNativePkgs;
-    haveLibCxx = false;
-  };
-
-  stdenvDarwin33 = import ./darwin {
-    inherit config;
-    stdenv = stdenvNative;
-    pkgs = stdenvNativePkgs;
-    useClang33 = true;
-  };
-
-
   # Linux standard environment.
   stdenvLinux = (import ./linux { inherit system allPackages platform config lib; }).stdenvLinux;
 
+  # Darwin standard environment.
+  stdenvDarwin = (import ./darwin { inherit system allPackages platform config;}).stdenvDarwin;
 
   # Select the appropriate stdenv for the platform `system'.
   stdenv =