Hello,
I currently have this in my configuration.nix and my /dev/nvme0n1p1 device encrypted by LUKS.
(Just to test) I added this small command to boot.initrd.postDeviceCommands.
But when starting the computer, after executing the command it waits for the device infinitely.
Do you have an idea why ?
I have a very similar setup, and my cryptsetup luksOpen commands are issued in the boot.initrd.preLVMCommands hook, although I don’t use LVM at all. Maybe try to move it there?
Also (I think with 5.8) there was a change that required cryptsetup to work with the encrypted-key feature. I had to add the following to my kernel modules:
My setup is almost exactly like yours, except that my key material isn’t “echo dummy”, and that I am using the preLVMCommand hook for my cryptsetup.
Try to change:
boot.initrd.postDeviceCommands = ''
echo -n "dummy" | cryptsetup luksOpen /dev/nvme0n1p1 nixos-luks
ls -l /dev/mapper/nixos-luks || sh
'';
If your cryptsetup command is successful, you should see a /dev/mapper/nixos-luks device. Otherwise, you get dropped into a shell to fix it. You could also read your /init script to see if that script is looking for “nixos-luks” or is blocked by something else.