1 import ./make-test-python.nix ({ lib, pkgs, ... }: {
2 name = "systemd-initrd-luks-fido2";
4 nodes.machine = { pkgs, config, ... }: {
7 emptyDiskImages = [ 512 ];
10 qemu.package = lib.mkForce (pkgs.qemu_test.override { canokeySupport = true; });
11 qemu.options = [ "-device canokey,file=/tmp/canokey-file" ];
13 boot.loader.systemd-boot.enable = true;
15 boot.initrd.systemd.enable = true;
17 environment.systemPackages = with pkgs; [ cryptsetup ];
19 specialisation.boot-luks.configuration = {
20 boot.initrd.luks.devices = lib.mkVMOverride {
23 crypttabExtraOpts = [ "fido2-device=auto" ];
26 virtualisation.bootDevice = "/dev/mapper/cryptroot";
31 # Create encrypted volume
32 machine.wait_for_unit("multi-user.target")
33 machine.succeed("echo -n supersecret | cryptsetup luksFormat -q --iter-time=1 /dev/vdc -")
34 machine.succeed("PASSWORD=supersecret SYSTEMD_LOG_LEVEL=debug systemd-cryptenroll --fido2-device=auto /dev/vdc |& systemd-cat")
36 # Boot from the encrypted disk
37 machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-luks.conf")
38 machine.succeed("sync")
41 # Boot and decrypt the disk
42 machine.wait_for_unit("multi-user.target")
43 assert "/dev/mapper/cryptroot on / type ext4" in machine.succeed("mount")