|
28 | 28 | };
|
29 | 29 |
|
30 | 30 | # TODO: eventually should this go in nixpkgs?
|
31 |
| - nix-user-chroot = stdenv.mkDerivation { |
| 31 | + nix-user-chroot = stdenv.lib.makeOverridable stdenv.mkDerivation { |
32 | 32 | name = "nix-user-chroot-2b144e";
|
33 | 33 | src = fetchFromGitHub {
|
34 | 34 | owner = "matthewbauer";
|
|
37 | 37 | sha256 = "16bmshhvk6941w04rx78i5a1305876qni2n2rvm7rkziz49j158n";
|
38 | 38 | };
|
39 | 39 |
|
| 40 | + # hack to use when /nix/store is not available |
40 | 41 | postFixup = ''
|
41 | 42 | exe=$out/bin/nix-user-chroot
|
42 | 43 | patchelf \
|
|
46 | 47 | '';
|
47 | 48 |
|
48 | 49 | installPhase = ''
|
| 50 | + runHook preInstall |
| 51 | +
|
49 | 52 | mkdir -p $out/bin/
|
50 | 53 | cp nix-user-chroot $out/bin/nix-user-chroot
|
| 54 | +
|
| 55 | + runHook postInstall |
51 | 56 | '';
|
52 | 57 | };
|
53 | 58 |
|
|
59 | 64 | };
|
60 | 65 | };
|
61 | 66 |
|
62 |
| - nix-bootstrap = { target, run }: |
| 67 | + nix-bootstrap = { target, extraTargets ? [], run, nix-user-chroot' ? nix-user-chroot }: |
63 | 68 | makebootstrap {
|
64 |
| - startup = ''.${nix-user-chroot}/bin/nix-user-chroot ./nix ${target}${run} \$@''; |
65 |
| - targets = [ nix-user-chroot target ]; |
| 69 | + startup = ''.${nix-user-chroot'}/bin/nix-user-chroot ./nix ${target}${run} \$@''; |
| 70 | + targets = [ nix-user-chroot' target ] ++ extraTargets; |
| 71 | + }; |
| 72 | + |
| 73 | + # special case handling because of impurities in nix bootstrap |
| 74 | + # anything that needs Nix will have to have these setup before they can be run |
| 75 | + nix-bootstrap-nix = let |
| 76 | + nix-user-chroot' = nix-user-chroot.override { |
| 77 | + buildInputs = [ cacert gnutar bzip2 gzip coreutils ]; |
| 78 | + makeFlags = [ |
| 79 | + ''NIX_SSL_CERT_FILE="${cacert}/etc/ssl/certs/ca-bundle.crt"'' |
| 80 | + ''NIX_PATH="nixpkgs=https://github.com/matthewbauer/nixpkgs/archive/nix-bundle.tar.gz"'' |
| 81 | + ''ENV_PATH="${stdenv.lib.makeBinPath [ coreutils gnutar bzip2 gzip bash ]}"'' |
| 82 | + ]; |
| 83 | + }; in { target, extraTargets ? [], run }: nix-bootstrap { inherit target extraTargets run nix-user-chroot'; }; |
| 84 | + |
| 85 | + # special case adding path to the environment before launch |
| 86 | + nix-bootstrap-path = let |
| 87 | + nix-user-chroot'' = targets: nix-user-chroot.override { |
| 88 | + buildInputs = targets; |
| 89 | + makeFlags = [ |
| 90 | + ''ENV_PATH="${stdenv.lib.makeBinPath targets}"'' |
| 91 | + ]; |
| 92 | + }; in { target, extraTargets ? [], run }: nix-bootstrap { |
| 93 | + inherit target extraTargets run; |
| 94 | + nix-user-chroot' = nix-user-chroot'' extraTargets; |
66 | 95 | };
|
67 | 96 | }
|
0 commit comments