@@ -11,10 +11,11 @@ let
1111 });
1212in rec {
1313 toStorePath = target:
14− # If a store path has been given but is a string, add the missing context
14+ # If a store path has been given but is not a derivation, add the missing context
1515 # to it so it will be propagated properly as a build input.
16− if builtins.isString target && lib.isStorePath target then
17− builtins.appendContext target { "${target}" = { path = true; }; }
16+ if !(lib.isDerivation target) && lib.isStorePath target then
17+ let path = toString target; in
18+ builtins.appendContext path { "${path}" = { path = true; }; }
1819 # Otherwise, add to the store. This takes care of appending the store path
1920 # in the context automatically.
2021 else "${target}";
@@ -44,7 +45,7 @@ in rec {
4445 };
4546
4647 # TODO: eventually should this go in nixpkgs?
47− nix-user-chroot = stdenv.lib.makeOverridable stdenv.mkDerivation {
48+ nix-user-chroot = lib.makeOverridable stdenv.mkDerivation {
4849 name = "nix-user-chroot-2c52b5f";
4950 src = ./nix-user-chroot;
5051
@@ -79,19 +80,20 @@ in rec {
7980 };
8081 };
8182
82− makeStartup = { target, nixUserChrootFlags, nix-user-chroot', run }:
83+ makeStartup = { target, nixUserChrootFlags, nix-user-chroot', run, initScript }:
8384 let
8485 # Avoid re-adding a store path into the store
8586 path = toStorePath target;
8687 in
8788 writeScript "startup" ''
8889 #!/bin/sh
90+ ${initScript}
8991 .${nix-user-chroot'}/bin/nix-user-chroot -n ./nix ${nixUserChrootFlags} -- ${path}${run} "$@"
9092 '';
9193
92− 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 ? "" }:
9395 let
94− script = makeStartup { inherit target nixUserChrootFlags nix-user-chroot' run; };
96+ script = makeStartup { inherit target nixUserChrootFlags nix-user-chroot' run initScript; };
9597 in makebootstrap {
9698 startup = ".${script} '\"$@\"'";
9799 targets = [ "${script}" ] ++ extraTargets;
@@ -108,10 +110,10 @@ in rec {
108110 nix-user-chroot'' = targets: nix-user-chroot.overrideDerivation (o: {
109111 buildInputs = o.buildInputs ++ targets;
110112 makeFlags = o.makeFlags ++ [
111− ''ENV_PATH="${stdenv.lib.makeBinPath targets}"''
113+ ''ENV_PATH="${lib.makeBinPath targets}"''
112114 ];
113− }); in { target, extraTargets ? [], run }: nix-bootstrap {
114− inherit target extraTargets run;
115+ }); in { target, extraTargets ? [], run, initScript ? "" }: nix-bootstrap {
116+ inherit target extraTargets run initScript;
115117 nix-user-chroot' = nix-user-chroot'' extraTargets;
116118 };
117119}