summary refs log tree commit diff
path: root/pkgs/stdenv
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r--pkgs/stdenv/darwin/default.nix41
-rw-r--r--pkgs/stdenv/darwin/make-bootstrap-tools.nix30
-rw-r--r--pkgs/stdenv/default.nix2
3 files changed, 43 insertions, 30 deletions
diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix
index bc3b433e922..f2a482e3db2 100644
--- a/pkgs/stdenv/darwin/default.nix
+++ b/pkgs/stdenv/darwin/default.nix
@@ -1,27 +1,26 @@
-{ system      ? builtins.currentSystem
-, allPackages ? import ../../top-level/all-packages.nix
-, platform    ? null
-, config      ? {}
+{ system         ? builtins.currentSystem
+, allPackages    ? import ../../top-level/all-packages.nix
+, platform       ? null
+, config         ? {}
+
+# Allow passing in bootstrap files directly so we can test the stdenv bootstrap process when changing the bootstrap tools
+, bootstrapFiles ? let
+  fetch = { file, sha256, executable ? true }: import <nix/fetchurl.nix> {
+    url = "http://tarballs.nixos.org/stdenv-darwin/x86_64/4f07c88d467216d9692fefc951deb5cd3c4cc722/${file}";
+    inherit sha256 system executable;
+  }; in {
+    sh      = fetch { file = "sh";    sha256 = "1siix3wakzil31r2cydmh3v8a1nyq4605dwiabqc5lx73j4xzrzi"; };
+    bzip2   = fetch { file = "bzip2"; sha256 = "0zvqm977k11b5cl4ixxb5h0ds24g6z0f8m28z4pqxzpa353lqbla"; };
+    mkdir   = fetch { file = "mkdir"; sha256 = "13frk8lsfgzlb65p9l26cvxf06aag43yjk7vg9msn7ix3v8cmrg1"; };
+    cpio    = fetch { file = "cpio";  sha256 = "0ms5i9m1vdksj575sf1djwgm7zhnvfrrb44dxnfh9avr793rc2w4"; };
+    tarball = fetch { file = "bootstrap-tools.cpio.bz2"; sha256 = "1lz1b0grl4642h6n635xvi6imf0yyy1zyzdr9ing5aphzz0z5iic"; executable = false; };
+  }
 }:
 
 let
   libSystemProfile = ''
     (import "${./standard-sandbox.sb}")
   '';
-
-  fetch = { file, sha256, executable ? true }: import <nix/fetchurl.nix> {
-    url = "http://tarballs.nixos.org/stdenv-darwin/x86_64/4f07c88d467216d9692fefc951deb5cd3c4cc722/${file}";
-    inherit sha256 system executable;
-  };
-
-  bootstrapFiles = {
-    sh    = fetch { file = "sh";    sha256 = "1siix3wakzil31r2cydmh3v8a1nyq4605dwiabqc5lx73j4xzrzi"; };
-    bzip2 = fetch { file = "bzip2"; sha256 = "0zvqm977k11b5cl4ixxb5h0ds24g6z0f8m28z4pqxzpa353lqbla"; };
-    mkdir = fetch { file = "mkdir"; sha256 = "13frk8lsfgzlb65p9l26cvxf06aag43yjk7vg9msn7ix3v8cmrg1"; };
-    cpio  = fetch { file = "cpio";  sha256 = "0ms5i9m1vdksj575sf1djwgm7zhnvfrrb44dxnfh9avr793rc2w4"; };
-  };
-
-  tarball = fetch { file = "bootstrap-tools.cpio.bz2"; sha256 = "1lz1b0grl4642h6n635xvi6imf0yyy1zyzdr9ing5aphzz0z5iic"; executable = false; };
 in rec {
   allPackages = import ../../top-level/all-packages.nix;
 
@@ -42,13 +41,13 @@ in rec {
   '';
 
   bootstrapTools = derivation rec {
-    inherit system tarball;
+    inherit system;
 
     name    = "bootstrap-tools";
     builder = bootstrapFiles.sh; # Not a filename! Attribute 'sh' on bootstrapFiles
     args    = [ ./unpack-bootstrap-tools.sh ];
 
-    inherit (bootstrapFiles) mkdir bzip2 cpio;
+    inherit (bootstrapFiles) mkdir bzip2 cpio tarball;
 
     __sandboxProfile = binShClosure + libSystemProfile;
   };
@@ -306,4 +305,6 @@ in rec {
       inherit cc;
     };
   };
+
+  stdenvDarwin = stage5;
 }
diff --git a/pkgs/stdenv/darwin/make-bootstrap-tools.nix b/pkgs/stdenv/darwin/make-bootstrap-tools.nix
index 961adbeaaad..d9d501ca0f5 100644
--- a/pkgs/stdenv/darwin/make-bootstrap-tools.nix
+++ b/pkgs/stdenv/darwin/make-bootstrap-tools.nix
@@ -1,4 +1,6 @@
-with import ../../top-level/all-packages.nix { system = "x86_64-darwin"; };
+{ system ? builtins.currentSystem }:
+
+with import ../../top-level/all-packages.nix { inherit system; };
 
 rec {
   # We want coreutils without ACL support.
@@ -169,7 +171,15 @@ rec {
     '';
   };
 
-  unpack = stdenv.mkDerivation {
+  bootstrapFiles = {
+    sh      = "${build}/on-server/sh";
+    bzip2   = "${build}/on-server/bzip2";
+    mkdir   = "${build}/on-server/mkdir";
+    cpio    = "${build}/on-server/cpio";
+    tarball = "${build}/on-server/bootstrap-tools.cpio.bz2";
+  };
+
+  unpack = stdenv.mkDerivation (bootstrapFiles // {
     name = "unpack";
 
     # This is by necessity a near-duplicate of unpack-bootstrap-tools.sh. If we refer to it directly,
@@ -216,14 +226,8 @@ rec {
       EOF
     '';
 
-    tarball = "${build}/on-server/bootstrap-tools.cpio.bz2";
-
-    mkdir = "${build}/on-server/mkdir";
-    bzip2 = "${build}/on-server/bzip2";
-    cpio  = "${build}/on-server/cpio";
-
     allowedReferences = [ "out" ];
-  };
+  });
 
   test = stdenv.mkDerivation {
     name = "test";
@@ -283,4 +287,12 @@ rec {
       $out/bin/hello
     '';
   };
+
+  # The ultimate test: bootstrap a whole stdenv from the tools specified above and get a package set out of it
+  test-pkgs = let
+    stdenv = import ./. { inherit system bootstrapFiles; };
+  in import ../../top-level/all-packages.nix {
+    inherit system;
+    bootStdenv = stdenv.stdenvDarwin;
+  };
 }
diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix
index 44be0ac83f8..9ea69fe88e9 100644
--- a/pkgs/stdenv/default.nix
+++ b/pkgs/stdenv/default.nix
@@ -36,7 +36,7 @@ rec {
   # Linux standard environment.
   stdenvLinux = (import ./linux { inherit system allPackages platform config lib; }).stdenvLinux;
 
-  stdenvDarwin = (import ./darwin { inherit system allPackages platform config;}).stage5;
+  stdenvDarwin = (import ./darwin { inherit system allPackages platform config;}).stdenvDarwin;
 
   # Select the appropriate stdenv for the platform `system'.
   stdenv =