Hi, I’m completely new to NixOS and after tinkering for the better part of two days I managed to install it. There’s a problem with LUKS though.
After mounting an external HDD that has LUKS on LVM, the “nixos-generate-config” command generates a “hardware-configuration.nix” that renders my PC unbootable after a rebuild.
I’m guessing there’s a problem with LVM on initrd. Anyways, I really don’t need the external drive to be available on stage 1 and I’d like to input the password during systemd launch, which I don’t know if its possible. I’d like the system to ask for a passphrase when the drive is present and not fail when it isn’t connected.
Back on Arch Linux I just added additional drives to /etc/crypttab and specified the nofail option on /etc/fstab but NixOS doesn’t have crypttab.
What do I do? What is the best way to do this?
[NixOS 20.09 channel. LUKS on LVM on mdadm root, EFI partition mounted at /etc/boot, using GRUB as bootmanager]
My GRUB config:
boot.loader.grub = {
enable = true;
version = 2;
device = "nodev";
efiSupport = true;
enableCryptodisk = true;
};
boot.loader.efi.canTouchEfiVariables = true;
EDIT: It turns out “/etc/crypttab” is also read by systemd at boot on NixOS. This lets me type the passphrase after root has been mounted.
However the generated “hardware-configuration.nix” still makes the system unbootable. I have to modify it or otherwise I can’t rebuild:
## Commented out the offending line:
# boot.initrd.luks.devices."ilanders-crypt".device = "/dev/disk/by-uuid/[uuidhere]"
Perhaps there is a way to modify “configuration.nix” instead but I haven’t figured out how to do it yet. Any thoughts?