about summary refs log tree commit diff
path: root/nixos/modules/installer
diff options
context:
space:
mode:
authorNaïm Favier <n@monade.li>2023-01-17 11:39:34 +0100
committerNaïm Favier <n@monade.li>2023-01-17 11:39:34 +0100
commitcd4f1a1df502f10a8494c5305121b1b9c4d80f63 (patch)
tree3fd8c47eed8f8bedb67dc0aedd475f450545e4b6 /nixos/modules/installer
parent682381bf3f24c4d2ddeace757ce506c69b8f7c07 (diff)
downloadnixlib-cd4f1a1df502f10a8494c5305121b1b9c4d80f63.tar
nixlib-cd4f1a1df502f10a8494c5305121b1b9c4d80f63.tar.gz
nixlib-cd4f1a1df502f10a8494c5305121b1b9c4d80f63.tar.bz2
nixlib-cd4f1a1df502f10a8494c5305121b1b9c4d80f63.tar.lz
nixlib-cd4f1a1df502f10a8494c5305121b1b9c4d80f63.tar.xz
nixlib-cd4f1a1df502f10a8494c5305121b1b9c4d80f63.tar.zst
nixlib-cd4f1a1df502f10a8494c5305121b1b9c4d80f63.zip
nixos-install: only mount if root
Diffstat (limited to 'nixos/modules/installer')
-rwxr-xr-x[-rw-r--r--]nixos/modules/installer/tools/nixos-install.sh8
1 files changed, 5 insertions, 3 deletions
diff --git a/nixos/modules/installer/tools/nixos-install.sh b/nixos/modules/installer/tools/nixos-install.sh
index 7247451a85d9..9f609cefe6ea 100644..100755
--- 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