git.iko.soy/typeable/nixpkgs
on master help sign in
stdenv-darwin: allow easier testing of bootstrap tools

This un-hardcodes the bootstrap tools passed into the Darwin stdenv and thus allows us to quickly iterate on improving the design of the full bootstrap process. We can easily change the contents of the bootstrap tools and evaluate an entire bootstrap all the way up to real packages.

commit0313b2e09cd306902fcb9967c32f048fada1f484 authorDan Peebles <pumpkin@me.com> dateSun 3 Jan 2016, 21:47 (11 years ago) parent88c41e1
3 files changed+43−30
pkgs/stdenv/darwin/default.nix+21−20 pkgs/stdenv/darwin/make-bootstrap-tools.nix+21−9 pkgs/stdenv/default.nix+1−1
pkgs/stdenv/darwin/default.nix+21−20
@@ -1,27 +1,26 @@
1−{ system ? builtins.currentSystem
2−, allPackages ? import ../../top-level/all-packages.nix
3−, platform ? null
4−, config ? {}
1+{ system ? builtins.currentSystem
2+, allPackages ? import ../../top-level/all-packages.nix
3+, platform ? null
4+, config ? {}
5+
6+# Allow passing in bootstrap files directly so we can test the stdenv bootstrap process when changing the bootstrap tools
7+, bootstrapFiles ? let
8+ fetch = { file, sha256, executable ? true }: import <nix/fetchurl.nix> {
9+ url = "http://tarballs.nixos.org/stdenv-darwin/x86_64/4f07c88d467216d9692fefc951deb5cd3c4cc722/${file}";
10+ inherit sha256 system executable;
11+ }; in {
12+ sh = fetch { file = "sh"; sha256 = "1siix3wakzil31r2cydmh3v8a1nyq4605dwiabqc5lx73j4xzrzi"; };
13+ bzip2 = fetch { file = "bzip2"; sha256 = "0zvqm977k11b5cl4ixxb5h0ds24g6z0f8m28z4pqxzpa353lqbla"; };
14+ mkdir = fetch { file = "mkdir"; sha256 = "13frk8lsfgzlb65p9l26cvxf06aag43yjk7vg9msn7ix3v8cmrg1"; };
15+ cpio = fetch { file = "cpio"; sha256 = "0ms5i9m1vdksj575sf1djwgm7zhnvfrrb44dxnfh9avr793rc2w4"; };
16+ tarball = fetch { file = "bootstrap-tools.cpio.bz2"; sha256 = "1lz1b0grl4642h6n635xvi6imf0yyy1zyzdr9ing5aphzz0z5iic"; executable = false; };
17+ }
518}:
619
720let
821 libSystemProfile = ''
922 (import "${./standard-sandbox.sb}")
1023 '';
11−
12− fetch = { file, sha256, executable ? true }: import <nix/fetchurl.nix> {
13− url = "http://tarballs.nixos.org/stdenv-darwin/x86_64/4f07c88d467216d9692fefc951deb5cd3c4cc722/${file}";
14− inherit sha256 system executable;
15− };
16−
17− bootstrapFiles = {
18− sh = fetch { file = "sh"; sha256 = "1siix3wakzil31r2cydmh3v8a1nyq4605dwiabqc5lx73j4xzrzi"; };
19− bzip2 = fetch { file = "bzip2"; sha256 = "0zvqm977k11b5cl4ixxb5h0ds24g6z0f8m28z4pqxzpa353lqbla"; };
20− mkdir = fetch { file = "mkdir"; sha256 = "13frk8lsfgzlb65p9l26cvxf06aag43yjk7vg9msn7ix3v8cmrg1"; };
21− cpio = fetch { file = "cpio"; sha256 = "0ms5i9m1vdksj575sf1djwgm7zhnvfrrb44dxnfh9avr793rc2w4"; };
22− };
23−
24− tarball = fetch { file = "bootstrap-tools.cpio.bz2"; sha256 = "1lz1b0grl4642h6n635xvi6imf0yyy1zyzdr9ing5aphzz0z5iic"; executable = false; };
2524in rec {
2625 allPackages = import ../../top-level/all-packages.nix;
2726
@@ -42,13 +41,13 @@ in rec {
4241 '';
4342
4443 bootstrapTools = derivation rec {
45− inherit system tarball;
44+ inherit system;
4645
4746 name = "bootstrap-tools";
4847 builder = bootstrapFiles.sh; # Not a filename! Attribute 'sh' on bootstrapFiles
4948 args = [ ./unpack-bootstrap-tools.sh ];
5049
51− inherit (bootstrapFiles) mkdir bzip2 cpio;
50+ inherit (bootstrapFiles) mkdir bzip2 cpio tarball;
5251
5352 __sandboxProfile = binShClosure + libSystemProfile;
5453 };
@@ -306,4 +305,6 @@ in rec {
306305 inherit cc;
307306 };
308307 };
308+
309+ stdenvDarwin = stage5;
309310}
pkgs/stdenv/darwin/make-bootstrap-tools.nix+21−9
@@ -1,4 +1,6 @@
1−with import ../../top-level/all-packages.nix { system = "x86_64-darwin"; };
1+{ system ? builtins.currentSystem }:
2+
3+with import ../../top-level/all-packages.nix { inherit system; };
24
35rec {
46 # We want coreutils without ACL support.
@@ -169,7 +171,15 @@ rec {
169171 '';
170172 };
171173
172− unpack = stdenv.mkDerivation {
174+ bootstrapFiles = {
175+ sh = "${build}/on-server/sh";
176+ bzip2 = "${build}/on-server/bzip2";
177+ mkdir = "${build}/on-server/mkdir";
178+ cpio = "${build}/on-server/cpio";
179+ tarball = "${build}/on-server/bootstrap-tools.cpio.bz2";
180+ };
181+
182+ unpack = stdenv.mkDerivation (bootstrapFiles // {
173183 name = "unpack";
174184
175185 # This is by necessity a near-duplicate of unpack-bootstrap-tools.sh. If we refer to it directly,
@@ -216,14 +226,8 @@ rec {
216226 EOF
217227 '';
218228
219− tarball = "${build}/on-server/bootstrap-tools.cpio.bz2";
220−
221− mkdir = "${build}/on-server/mkdir";
222− bzip2 = "${build}/on-server/bzip2";
223− cpio = "${build}/on-server/cpio";
224−
225229 allowedReferences = [ "out" ];
226− };
230+ });
227231
228232 test = stdenv.mkDerivation {
229233 name = "test";
@@ -283,4 +287,12 @@ rec {
283287 $out/bin/hello
284288 '';
285289 };
290+
291+ # The ultimate test: bootstrap a whole stdenv from the tools specified above and get a package set out of it
292+ test-pkgs = let
293+ stdenv = import ./. { inherit system bootstrapFiles; };
294+ in import ../../top-level/all-packages.nix {
295+ inherit system;
296+ bootStdenv = stdenv.stdenvDarwin;
297+ };
286298}
pkgs/stdenv/default.nix+1−1
@@ -36,7 +36,7 @@ rec {
3636 # Linux standard environment.
3737 stdenvLinux = (import ./linux { inherit system allPackages platform config lib; }).stdenvLinux;
3838
39− stdenvDarwin = (import ./darwin { inherit system allPackages platform config;}).stage5;
39+ stdenvDarwin = (import ./darwin { inherit system allPackages platform config;}).stdenvDarwin;
4040
4141 # Select the appropriate stdenv for the platform `system'.
4242 stdenv =