diff --git a/lib/types/luks.nix b/lib/types/luks.nix index 8ed3225..cf9e631 100644 --- a/lib/types/luks.nix +++ b/lib/types/luks.nix @@ -227,13 +227,17 @@ in export SLOT_ZERO_TO_DELETE=true ''} cryptsetup -q luksFormat "${config.device}" ${toString config.extraFormatArgs} ${formatKeyFileArgs} - fi - if ! cryptsetup status "${config.name}" >/dev/null; then ${formatCryptsetupOpen} \ --persistent fi + # Unlock without relying on the autogenerated password when someone + # calls this script after unmounting or rebooting + if ! cryptsetup status "${config.name}" >/dev/null; then + ${cryptsetupOpen} + fi + ${toString ( lib.forEach config.additionalKeyFiles (keyFile: '' if ! cryptsetup open --test-passphrase --key-file=${keyFile} "${config.device}" 2>/dev/null; then