diff --git a/pkgs/build-support/build-fhs-chrootenv/default.nix b/pkgs/build-support/build-fhs-chrootenv/default.nix index 2f3aa14c6a0f..e807a04628a3 100644 --- a/pkgs/build-support/build-fhs-chrootenv/default.nix +++ b/pkgs/build-support/build-fhs-chrootenv/default.nix @@ -1,11 +1,11 @@ {stdenv, glibc, glibcLocales, gcc, coreutils, diffutils, findutils, gnused, gnugrep, gnutar, gzip, bzip2, -bashInteractive, xz, shadow, gawk, less, su, buildEnv}: +bashInteractive, xz, shadow, gawk, less, buildEnv}: {name, pkgs ? [], profile ? ""}: let basePkgs = [ glibc glibcLocales gcc coreutils diffutils findutils gnused gnugrep gnutar - gzip bzip2 bashInteractive xz shadow gawk less su + gzip bzip2 bashInteractive xz shadow gawk less ]; # Compose a global profile for the chroot environment diff --git a/pkgs/build-support/build-fhs-chrootenv/load.sh.in b/pkgs/build-support/build-fhs-chrootenv/load.sh.in index 8d3f464186b7..6089fa275855 100644 --- a/pkgs/build-support/build-fhs-chrootenv/load.sh.in +++ b/pkgs/build-support/build-fhs-chrootenv/load.sh.in @@ -3,4 +3,4 @@ chrootenvDest=/run/chrootenv/@name@ # Enter the LFS chroot environment -chroot $chrootenvDest /usr/bin/env -i PS1="$PS1" TERM="$TERM" DISPLAY="$DISPLAY" HOME="/root" PATH="/bin:/sbin" /bin/bash --login +sudo chroot --userspec "$USER:${GROUPS[0]}" --groups "${GROUPS[0]}" $chrootenvDest /usr/bin/env -i PS1="$PS1" TERM="$TERM" DISPLAY="$DISPLAY" HOME="$HOME" PATH="/bin:/sbin" XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" /bin/bash --login diff --git a/pkgs/build-support/build-fhs-chrootenv/mount.sh.in b/pkgs/build-support/build-fhs-chrootenv/mount.sh.in index 68459cca2560..225d9dbc4f72 100644 --- a/pkgs/build-support/build-fhs-chrootenv/mount.sh.in +++ b/pkgs/build-support/build-fhs-chrootenv/mount.sh.in @@ -17,7 +17,7 @@ mount --bind /home $chrootenvDest/home # Bind mount state directories mount --bind /var $chrootenvDest/var -mount --bind /run $chrootenvDest/run +mount --rbind /run $chrootenvDest/run # Bind mount the host system's /etc mount --bind /etc $chrootenvDest/host-etc diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7fc5bd53244d..af6bdb1b198c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -270,7 +270,7 @@ let buildFHSChrootEnv = import ../build-support/build-fhs-chrootenv { inherit stdenv glibc glibcLocales gcc coreutils diffutils findutils; inherit gnused gnugrep gnutar gzip bzip2 bashInteractive xz shadow gawk; - inherit less su buildEnv; + inherit less buildEnv; }; dotnetenv = import ../build-support/dotnetenv {