Can't mount filesystem on LUKS + LVM from an "external drive"


I am experimenting with NixOS on my laptop: I am booting NixOS off an USB thumb drive, and I would like to mount my home directory from the nvme drive in my laptop. My configuration.nix has the following stanza:

  boot.initrd.luks.devices.stash.device = "/dev/disk/by-uuid/a-valid-copy-pasted-uuid";
  fileSystems."/mnt" = {
    device = "/dev/mapper/vgFoo-lvBar";
    options = [ "relatime" "nosuid" "nodev" "discard" ];
    encrypted.label = "stash";
    encrypted.enable = true;

And nixos-rebuild switch: fails with this kind of error: boot.initrd.luks.devices.stash.device not of type string got nul (I can get the exact error message if needed).

Me and @rrix are confused by the error, are we missing anything obvious?

can you try to quote the device name?

boot.initrd.luks.devices."stash".device = "/dev/disk/by-uuid/a-valid-copy-pasted-uuid";

I think this can be explained by
boot.initrd.luks.devices. is expecting a string as a leaf attribute for the device name, but you gave it stash.device which is an attribute set resolved to null.

It was a good guess, but that does not seem to be the issue, I saved the error message this time:

building the system configuration...
error: A definition for option `boot.initrd.luks.devices.stash.device' is not of type `string'. Definition values:
       - In `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/tasks/encrypted-devices.nix': null
(use '--show-trace' to show detailed location information)

I am using nixos-22.05.