about summary refs log tree commit diff
path: root/nixos/modules/installer
diff options
context:
space:
mode:
authorMichele Guerini Rocco <rnhmjoj@users.noreply.github.com>2023-01-17 00:48:58 +0100
committerGitHub <noreply@github.com>2023-01-17 00:48:58 +0100
commit594b94b4c3038f5c2cfb2f5d9c10ef30c7070a4c (patch)
tree77fd1ee86169a0f9f7544012e5d8c012370f5fec /nixos/modules/installer
parentea27fb07efe68cb426593a4d7c2efe469621021d (diff)
parent9bb888c9f8224e45fc54d9f345369786cbd78bb6 (diff)
downloadnixlib-594b94b4c3038f5c2cfb2f5d9c10ef30c7070a4c.tar
nixlib-594b94b4c3038f5c2cfb2f5d9c10ef30c7070a4c.tar.gz
nixlib-594b94b4c3038f5c2cfb2f5d9c10ef30c7070a4c.tar.bz2
nixlib-594b94b4c3038f5c2cfb2f5d9c10ef30c7070a4c.tar.lz
nixlib-594b94b4c3038f5c2cfb2f5d9c10ef30c7070a4c.tar.xz
nixlib-594b94b4c3038f5c2cfb2f5d9c10ef30c7070a4c.tar.zst
nixlib-594b94b4c3038f5c2cfb2f5d9c10ef30c7070a4c.zip
Merge pull request #210812 from rnhmjoj/pr-initrd-secrets
boot.initrd.secrets fixes
Diffstat (limited to 'nixos/modules/installer')
-rw-r--r--nixos/modules/installer/tools/nixos-install.sh9
1 files changed, 9 insertions, 0 deletions
diff --git a/nixos/modules/installer/tools/nixos-install.sh b/nixos/modules/installer/tools/nixos-install.sh
index e7cf52f5e32b..7247451a85d9 100644
--- a/nixos/modules/installer/tools/nixos-install.sh
+++ b/nixos/modules/installer/tools/nixos-install.sh
@@ -188,6 +188,15 @@ nix-env --store "$mountPoint" "${extraBuildFlags[@]}" \
 mkdir -m 0755 -p "$mountPoint/etc"
 touch "$mountPoint/etc/NIXOS"
 
+# Create a bind mount for each of the mount points inside the target file
+# system. This preserves the validity of their absolute paths after changing
+# 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
+
 # Switch to the new system configuration.  This will install Grub with
 # a menu default pointing at the kernel/initrd/etc of the new
 # configuration.