@@ -11,10 +11,11 @@ let
13 toStorePath = target:
13 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
15 # to it so it will be propagated properly as a build input.
15 # to it so it will be propagated properly as a build input.
16− if builtins.isString target && lib.isStorePath target then
16+ if !(lib.isDerivation target) && lib.isStorePath target then
17+ let path = toString target; in
17− builtins.appendContext target { "${target}" = { path = true; }; }
18+ builtins.appendContext path { "${path}" = { path = true; }; }
18 # Otherwise, add to the store. This takes care of appending the store path
19 # Otherwise, add to the store. This takes care of appending the store path
19 # in the context automatically.
20 # in the context automatically.
20 else "${target}";
21 else "${target}";
@@ -44,7 +45,7 @@ in rec {
46 # TODO: eventually should this go in nixpkgs?
47 # TODO: eventually should this go in nixpkgs?
47− nix-user-chroot = stdenv.lib.makeOverridable stdenv.mkDerivation {
48+ nix-user-chroot = lib.makeOverridable stdenv.mkDerivation {
48 name = "nix-user-chroot-2c52b5f";
49 name = "nix-user-chroot-2c52b5f";
49 src = ./nix-user-chroot;
50 src = ./nix-user-chroot;
@@ -79,19 +80,20 @@ in rec {
82− makeStartup = { target, nixUserChrootFlags, nix-user-chroot', run }:
83+ makeStartup = { target, nixUserChrootFlags, nix-user-chroot', run, initScript }:
84 # Avoid re-adding a store path into the store
85 # Avoid re-adding a store path into the store
85 path = toStorePath target;
86 path = toStorePath target;
87 writeScript "startup" ''
88 writeScript "startup" ''
89 .${nix-user-chroot'}/bin/nix-user-chroot -n ./nix ${nixUserChrootFlags} -- ${path}${run} "$@"
91 .${nix-user-chroot'}/bin/nix-user-chroot -n ./nix ${nixUserChrootFlags} -- ${path}${run} "$@"
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 ? "" }:
94− script = makeStartup { inherit target nixUserChrootFlags nix-user-chroot' run; };
96+ script = makeStartup { inherit target nixUserChrootFlags nix-user-chroot' run initScript; };
95 in makebootstrap {
97 in makebootstrap {
96 startup = ".${script} '\"$@\"'";
98 startup = ".${script} '\"$@\"'";
97 targets = [ "${script}" ] ++ extraTargets;
99 targets = [ "${script}" ] ++ extraTargets;
@@ -108,10 +110,10 @@ in rec {
108 nix-user-chroot'' = targets: nix-user-chroot.overrideDerivation (o: {
110 nix-user-chroot'' = targets: nix-user-chroot.overrideDerivation (o: {
109 buildInputs = o.buildInputs ++ targets;
111 buildInputs = o.buildInputs ++ targets;
110 makeFlags = o.makeFlags ++ [
112 makeFlags = o.makeFlags ++ [
111− ''ENV_PATH="${stdenv.lib.makeBinPath targets}"''
113+ ''ENV_PATH="${lib.makeBinPath targets}"''
113− }); in { target, extraTargets ? [], run }: nix-bootstrap {
115+ }); in { target, extraTargets ? [], run, initScript ? "" }: nix-bootstrap {
114− inherit target extraTargets run;
116+ inherit target extraTargets run initScript;
115 nix-user-chroot' = nix-user-chroot'' extraTargets;
117 nix-user-chroot' = nix-user-chroot'' extraTargets;