fix(installer): declare extra LUKS devices for multi-disk boot
All checks were successful
Check / eval-and-lint (push) Successful in 6m51s

A multi-disk install builds one LUKS container per drive joined into a
single multi-device BTRFS (-d single -m raid1). nixos-generate-config
only emits boot.initrd.luks.devices for the main drive — every subvolume
mounts through /dev/mapper/crypted_main, so the other members are
invisible to it. The installed system then unlocked only the main drive,
the array never assembled, and boot hung. Invisible single-disk, fatal
multi-disk (matches a real-hardware report).

generate_flake_config now writes, into hardware-selection.nix, a
boot.initrd.luks.devices entry for each extra drive (UUID resolved via
disko's partlabel; mapper name mirrors disko-config.nix's sanitize) and
re-asserts the x-systemd.requires= mount options disko sets but which
nixos-generate-config strips.

Verified end-to-end in a 3-disk UEFI QEMU VM: reproduced the bug, applied
the fix, ran a real nixos-install onto the array, and rebooted from the
disks — one passphrase unlocked all three containers, the 3-device BTRFS
assembled, and the system reached login.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Bernardo Magri
2026-06-02 18:50:10 +01:00
parent fdd74a0e4f
commit 5ea369d73c
3 changed files with 52 additions and 1 deletions

View File

@@ -269,6 +269,20 @@ The ISO autologins to a Hyprland live session that points you at:
After install, the system at `/etc/nixos/` is the same shape this guide
produces by hand.
**Multi-disk (BTRFS RAID) caveat.** If you select more than one target drive,
disko builds a multi-device BTRFS spanning one LUKS container per disk. The
extra containers are invisible to `nixos-generate-config` (every subvolume
mounts via the *main* `/dev/mapper/crypted_main`, so it only ever emits a
`boot.initrd.luks.devices` entry for the main drive). The installer therefore
writes the missing entries — plus the `x-systemd.requires=` mount options that
make systemd-initrd wait for every member — into `hardware-selection.nix`.
If you hand-write a multi-disk flake instead of using the installer, you must
add, for each extra drive, `boot.initrd.luks.devices."<mapper>".device =
"/dev/disk/by-uuid/<luks-partition-uuid>";` (mapper name = `crypted_` + the
device path with `/` and `-` replaced by `_`, e.g. `/dev/sdb` →
`crypted__dev_sdb`); without it the array can't be assembled and the system
hangs at boot.
---
## Verification (in-place migration)