From cd4f1a1df502f10a8494c5305121b1b9c4d80f63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Na=C3=AFm=20Favier?= Date: Tue, 17 Jan 2023 11:39:34 +0100 Subject: [PATCH] nixos-install: only mount if root --- nixos/modules/installer/tools/nixos-install.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) mode change 100644 => 100755 nixos/modules/installer/tools/nixos-install.sh diff --git a/nixos/modules/installer/tools/nixos-install.sh b/nixos/modules/installer/tools/nixos-install.sh old mode 100644 new mode 100755 index 7247451a85d9..9f609cefe6ea --- a/nixos/modules/installer/tools/nixos-install.sh +++ b/nixos/modules/installer/tools/nixos-install.sh @@ -193,9 +193,11 @@ touch "$mountPoint/etc/NIXOS" # the root with `nixos-enter`. # Without this the bootloader installation may fail due to options that # contain paths referenced during evaluation, like initrd.secrets. -mount --rbind --mkdir "$mountPoint" "$mountPoint$mountPoint" -mount --make-rslave "$mountPoint$mountPoint" -trap 'umount -R "$mountPoint$mountPoint" && rmdir "$mountPoint$mountPoint"' EXIT +if (( EUID == 0 )); then + mount --rbind --mkdir "$mountPoint" "$mountPoint$mountPoint" + mount --make-rslave "$mountPoint$mountPoint" + trap 'umount -R "$mountPoint$mountPoint" && rmdir "$mountPoint$mountPoint"' EXIT +fi # Switch to the new system configuration. This will install Grub with # a menu default pointing at the kernel/initrd/etc of the new