fix(installer): declare extra LUKS devices for multi-disk boot
All checks were successful
Check / eval-and-lint (push) Successful in 6m51s
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:
@@ -1467,6 +1467,42 @@ generate_flake_config() {
|
||||
impermanence_opt=$'nomarchy.system.impermanence.enable = true;\n nomarchy.system.impermanence.mainLuksName = "'"$_main_luks_name"$'";\n nomarchy.system.impermanence.user = "'"$USERNAME"$'";'
|
||||
fi
|
||||
|
||||
# Multi-disk LUKS unlock. `nixos-generate-config` only emits a
|
||||
# boot.initrd.luks.devices entry for the container that backs a
|
||||
# fileSystems device — and every subvolume mount points at the main
|
||||
# /dev/mapper/crypted_main. The extra drives in a multi-disk BTRFS array
|
||||
# are members of that filesystem but are invisible through the
|
||||
# device-mapper path it traces, so it never declares them. Without the
|
||||
# entries below, initrd unlocks only the main drive, the multi-device
|
||||
# BTRFS can never be assembled, and the installed system hangs at boot
|
||||
# (the failure is invisible single-disk and only bites multi-disk
|
||||
# hardware). We also re-assert the x-systemd.requires mount options disko
|
||||
# set on every BTRFS mount (installer/disko-config.nix) but which
|
||||
# nixos-generate-config drops — they make systemd-initrd wait for ALL
|
||||
# members before mounting. Drive→mapper/partlabel naming mirrors
|
||||
# disko-config.nix's `sanitize` (replace '/' and '-' with '_').
|
||||
local EXTRA_LUKS_OPTS=""
|
||||
local _ld=($TARGET_DRIVE)
|
||||
if (( ${#_ld[@]} > 1 )); then
|
||||
local _luks_lines="" _requires="" _i _extra _san _mapper _partlabel _uuid
|
||||
for (( _i=1; _i<${#_ld[@]}; _i++ )); do
|
||||
_extra="${_ld[$_i]}"
|
||||
_san="${_extra//\//_}"; _san="${_san//-/_}" # /dev/sdb -> _dev_sdb
|
||||
_mapper="crypted_${_san}"
|
||||
_partlabel="disk-extra_${_san}-luks"
|
||||
_uuid=$(blkid -s UUID -o value "/dev/disk/by-partlabel/$_partlabel")
|
||||
_luks_lines+=$'\n'" boot.initrd.luks.devices.\"$_mapper\".device = \"/dev/disk/by-uuid/$_uuid\";"
|
||||
_luks_lines+=$'\n'" boot.initrd.luks.devices.\"$_mapper\".allowDiscards = true;"
|
||||
_requires+=" \"x-systemd.requires=/dev/mapper/$_mapper\""
|
||||
done
|
||||
# BTRFS subvolume mountpoints — must match installer/disko-config.nix.
|
||||
local _mp _fs_lines=""
|
||||
for _mp in / /persist /home /nix /var/log /.snapshots; do
|
||||
_fs_lines+=$'\n'" fileSystems.\"$_mp\".options = [$_requires ];"
|
||||
done
|
||||
EXTRA_LUKS_OPTS="$_luks_lines"$'\n'"$_fs_lines"
|
||||
fi
|
||||
|
||||
local PROFILE_SYSTEM_OPTS=""
|
||||
local PROFILE_HOME_PACKAGES=""
|
||||
|
||||
@@ -1589,7 +1625,7 @@ FLAKE_EOF
|
||||
imports = [
|
||||
$HARDWARE_MODULES
|
||||
];
|
||||
$NOMARCHY_HW_OPTS
|
||||
$NOMARCHY_HW_OPTS$EXTRA_LUKS_OPTS
|
||||
}
|
||||
EOF
|
||||
|
||||
|
||||
Reference in New Issue
Block a user