about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorNick Cao <nickcao@nichi.co>2022-08-04 10:00:35 +0800
committerNick Cao <nickcao@nichi.co>2022-08-04 10:26:37 +0800
commitce39bee9dd61d6ea5c336450915d9601f3a26b9b (patch)
treeb433c80699597d447c1726e0c0e2815df7499a60 /nixos/modules
parentb5a9dea9c8a6dfe41ea18e7929759278d84d25c5 (diff)
nixos/stage-1-systemd: fix initrd-fstab generation for bind mounts
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/system/boot/systemd/initrd.nix3
1 files changed, 2 insertions, 1 deletions
diff --git a/nixos/modules/system/boot/systemd/initrd.nix b/nixos/modules/system/boot/systemd/initrd.nix
index 59cdc3077b16a..f7c4d0c3a3e35 100644
--- a/nixos/modules/system/boot/systemd/initrd.nix
+++ b/nixos/modules/system/boot/systemd/initrd.nix
@@ -103,7 +103,8 @@ let
   fstab = pkgs.writeText "initrd-fstab" (lib.concatMapStringsSep "\n"
     ({ fsType, mountPoint, device, options, autoFormat, autoResize, ... }@fs: let
         opts = options ++ optional autoFormat "x-systemd.makefs" ++ optional autoResize "x-systemd.growfs";
-      in "${device} /sysroot${mountPoint} ${fsType} ${lib.concatStringsSep "," opts}") fileSystems);
+        finalDevice = if (lib.elem "bind" options) then "/sysroot${device}" else device;
+      in "${finalDevice} /sysroot${mountPoint} ${fsType} ${lib.concatStringsSep "," opts}") fileSystems);
 
   needMakefs = lib.any (fs: fs.autoFormat) fileSystems;
   needGrowfs = lib.any (fs: fs.autoResize) fileSystems;