From ce39bee9dd61d6ea5c336450915d9601f3a26b9b Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Thu, 4 Aug 2022 10:00:35 +0800 Subject: [PATCH] nixos/stage-1-systemd: fix initrd-fstab generation for bind mounts --- nixos/modules/system/boot/systemd/initrd.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nixos/modules/system/boot/systemd/initrd.nix b/nixos/modules/system/boot/systemd/initrd.nix index 59cdc3077b16..f7c4d0c3a3e3 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;