@@ -1,43 +1,9 @@
1−{ stdenv, writeText, nix-user-chroot, nix, cacert, coreutils, bash }:
1+{ stdenv, writeText, nix-user-chroot, bash, makebootstrap }:
22
3−{ name, stage3 }:
3+{ name, target, run }:
44
5−let
6− stage1 = writeText "stage1.sh" ''
7− ./${nix-user-chroot}/bin/nix-user-chroot ./nix ./${bash}/bin/sh -c $(dirname $0)/stage2.sh
8− '';
9−
10− stage2 = writeText "stage2.sh" ''
11− unset NIX_REMOTE NIX_PROFILES NIX_USER_PROFILE_DIR NIX_OTHER_STORES NIX_PATH
12− export NIX_CONF_DIR=/nix/etc/nix/
13− export NIX_PROFILE=/nix/var/nix/profiles/default
14− export SSL_CERT_FILE="${cacert}/etc/ssl/certs/ca-bundle.crt"
15− export PATH="${coreutils}/bin:${bash}/bin:${nix.out}/bin"
16−
17− chmod -R a-w /nix/
18− chmod u+w /nix/ /nix/store/
19− mkdir -p /nix/etc/nix/ /nix/var/nix/profiles $HOME /bin/
20− ln -s ${bash}/bin/sh /bin/sh
21−
22− nix-store --init
23− nix-store --load-db < ./.reginfo
24−
25− . ${nix.out}/etc/profile.d/nix.sh
26−
27− nix-channel --add https://nixos.org/channels/nixpkgs-unstable
28− nix-channel --update nixpkgs
29−
30− nix-shell --pure -p ${nix.out} --run "${stage3}"
31− '';
32−
33−in
34−
35− stdenv.mkDerivation {
5+ makebootstrap {
366 inherit name;
37− buildInputs = [ nix-user-chroot nix cacert ];
38− buildCommand = ''
39− mkdir -p $out
40− install -m 755 ${stage1} $out/stage1.sh
41− install -m 755 ${stage2} $out/stage2.sh
42− '';
7+ startup = ".${nix-user-chroot}/bin/nix-user-chroot ./nix .${bash}/bin/sh -c ${target}${run}";
8+ targets = [ nix-user-chroot target bash ];
439 }