@@ -11,9 +11,9 @@ let
1111 });
1212in rec {
1313 toStorePath = target:
14− # If a store path has been given, transform it to a string. And make sure
15− # to capture the store path in its context.
16− if lib.isStorePath target then
14+ # If a store path has been given but is not a derivation, add the missing context
15+ # to it so it will be propagated properly as a build input.
16+ if !(lib.isDerivation target) && lib.isStorePath target then
1717 let path = toString target; in
1818 builtins.appendContext path { "${path}" = { path = true; }; }
1919 # Otherwise, add to the store. This takes care of appending the store path
@@ -45,7 +45,7 @@ in rec {
4545 };
4646
4747 # TODO: eventually should this go in nixpkgs?
48− nix-user-chroot = stdenv.lib.makeOverridable stdenv.mkDerivation {
48+ nix-user-chroot = lib.makeOverridable stdenv.mkDerivation {
4949 name = "nix-user-chroot-2c52b5f";
5050 src = ./nix-user-chroot;
5151
@@ -80,19 +80,20 @@ in rec {
8080 };
8181 };
8282
83− makeStartup = { target, nixUserChrootFlags, nix-user-chroot', run }:
83+ makeStartup = { target, nixUserChrootFlags, nix-user-chroot', run, initScript }:
8484 let
8585 # Avoid re-adding a store path into the store
8686 path = toStorePath target;
8787 in
8888 writeScript "startup" ''
8989 #!/bin/sh
90+ ${initScript}
9091 .${nix-user-chroot'}/bin/nix-user-chroot -n ./nix ${nixUserChrootFlags} -- ${path}${run} "$@"
9192 '';
9293
93− nix-bootstrap = { target, extraTargets ? [], run, nix-user-chroot' ? nix-user-chroot, nixUserChrootFlags ? "" }:
94+ nix-bootstrap = { target, extraTargets ? [], run, nix-user-chroot' ? nix-user-chroot, nixUserChrootFlags ? "", initScript ? "" }:
9495 let
95− script = makeStartup { inherit target nixUserChrootFlags nix-user-chroot' run; };
96+ script = makeStartup { inherit target nixUserChrootFlags nix-user-chroot' run initScript; };
9697 in makebootstrap {
9798 startup = ".${script} '\"$@\"'";
9899 targets = [ "${script}" ] ++ extraTargets;
@@ -109,10 +110,10 @@ in rec {
109110 nix-user-chroot'' = targets: nix-user-chroot.overrideDerivation (o: {
110111 buildInputs = o.buildInputs ++ targets;
111112 makeFlags = o.makeFlags ++ [
112− ''ENV_PATH="${stdenv.lib.makeBinPath targets}"''
113+ ''ENV_PATH="${lib.makeBinPath targets}"''
113114 ];
114− }); in { target, extraTargets ? [], run }: nix-bootstrap {
115− inherit target extraTargets run;
115+ }); in { target, extraTargets ? [], run, initScript ? "" }: nix-bootstrap {
116+ inherit target extraTargets run initScript;
116117 nix-user-chroot' = nix-user-chroot'' extraTargets;
117118 };
118119}