Merge pull request #11710 from kevincox/userenv-no-path

Remove PATH assumption from fhs-userenv.

Changed files
+5 -4
pkgs
build-support
build-fhs-userenv
+5 -4
pkgs/build-support/build-fhs-userenv/default.nix
···
-
{ runCommand, lib, writeText, writeScriptBin, stdenv, ruby } :
-
{ env, runScript ? "bash", extraBindMounts ? [], extraInstallCommands ? "" } :
+
{ runCommand, lib, writeText, writeScriptBin, stdenv, bash, ruby } :
+
{ env, runScript ? "${bash}/bin/bash", extraBindMounts ? [], extraInstallCommands ? "" } :
let
name = env.pname;
+
bash' = "${bash}/bin/bash";
# Sandboxing script
chroot-user = writeScriptBin "chroot-user" ''
···
runCommand "${name}-shell-env" {
shellHook = ''
export CHROOTENV_EXTRA_BINDS="${lib.concatStringsSep ":" extraBindMounts}:$CHROOTENV_EXTRA_BINDS"
-
exec ${chroot-user}/bin/chroot-user ${env} bash -l ${init "bash"} "$(pwd)"
+
exec ${chroot-user}/bin/chroot-user ${env} ${bash'} -l ${init bash'} "$(pwd)"
'';
} ''
echo >&2 ""
···
cat <<EOF >$out/bin/${name}
#! ${stdenv.shell}
export CHROOTENV_EXTRA_BINDS="${lib.concatStringsSep ":" extraBindMounts}:\$CHROOTENV_EXTRA_BINDS"
-
exec ${chroot-user}/bin/chroot-user ${env} bash -l ${init runScript} "\$(pwd)" "\$@"
+
exec ${chroot-user}/bin/chroot-user ${env} ${bash'} -l ${init runScript} "\$(pwd)" "\$@"
EOF
chmod +x $out/bin/${name}
${extraInstallCommands}