From 0d15976fce51cac59449ebf663070055bb809fcc Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Tue, 19 May 2026 09:46:10 +0200 Subject: [PATCH] luks: don't depend on autogenerated password --- lib/types/luks.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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