@@ -10,6 +10,16 @@ let
1010 '';
1111 });
1212in rec {
13+ toStorePath = target:
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
17+ let path = toString target; in
18+ builtins.appendContext path { "${path}" = { path = true; }; }
19+ # Otherwise, add to the store. This takes care of appending the store path
20+ # in the context automatically.
21+ else "${target}";
22+
1323 arx = { archive, startup}:
1424 stdenv.mkDerivation {
1525 name = "arx";
@@ -35,7 +45,7 @@ in rec {
3545 };
3646
3747 # TODO: eventually should this go in nixpkgs?
38− nix-user-chroot = stdenv.lib.makeOverridable stdenv.mkDerivation {
48+ nix-user-chroot = lib.makeOverridable stdenv.mkDerivation {
3949 name = "nix-user-chroot-2c52b5f";
4050 src = ./nix-user-chroot;
4151
@@ -58,6 +68,8 @@ in rec {
5868
5969 runHook postInstall
6070 '';
71+
72+ meta.platforms = lib.platforms.linux;
6173 };
6274
6375 makebootstrap = { targets, startup }:
@@ -68,15 +80,20 @@ in rec {
6880 };
6981 };
7082
71− makeStartup = { target, nixUserChrootFlags, nix-user-chroot', run }:
83+ makeStartup = { target, nixUserChrootFlags, nix-user-chroot', run, initScript }:
84+ let
85+ # Avoid re-adding a store path into the store
86+ path = toStorePath target;
87+ in
7288 writeScript "startup" ''
7389 #!/bin/sh
74− .${nix-user-chroot'}/bin/nix-user-chroot -n ./nix ${nixUserChrootFlags} -- ${target}${run} $@
90+ ${initScript}
91+ .${nix-user-chroot'}/bin/nix-user-chroot -n ./nix ${nixUserChrootFlags} -- ${path}${run} "$@"
7592 '';
7693
77− 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 ? "" }:
7895 let
79− script = makeStartup { inherit target nixUserChrootFlags nix-user-chroot' run; };
96+ script = makeStartup { inherit target nixUserChrootFlags nix-user-chroot' run initScript; };
8097 in makebootstrap {
8198 startup = ".${script} '\"$@\"'";
8299 targets = [ "${script}" ] ++ extraTargets;
@@ -93,10 +110,10 @@ in rec {
93110 nix-user-chroot'' = targets: nix-user-chroot.overrideDerivation (o: {
94111 buildInputs = o.buildInputs ++ targets;
95112 makeFlags = o.makeFlags ++ [
96− ''ENV_PATH="${stdenv.lib.makeBinPath targets}"''
113+ ''ENV_PATH="${lib.makeBinPath targets}"''
97114 ];
98− }); in { target, extraTargets ? [], run }: nix-bootstrap {
99− inherit target extraTargets run;
115+ }); in { target, extraTargets ? [], run, initScript ? "" }: nix-bootstrap {
116+ inherit target extraTargets run initScript;
100117 nix-user-chroot' = nix-user-chroot'' extraTargets;
101118 };
102119}