1 import ./make-test-python.nix ({ lib, pkgs, ... }: {
4 nodes.machine = { pkgs, ... }: {
5 imports = [ ./common/auto-format-root-device.nix ];
9 emptyDiskImages = [ 512 512 ];
12 # To boot off the encrypted disk, we need to have a init script which comes from the Nix store
13 mountHostNixStore = true;
15 boot.loader.systemd-boot.enable = true;
17 boot.kernelParams = lib.mkOverride 5 [ "console=tty1" ];
19 environment.systemPackages = with pkgs; [ cryptsetup ];
21 specialisation = rec {
22 boot-luks.configuration = {
23 boot.initrd.luks.devices = lib.mkVMOverride {
24 # We have two disks and only type one password - key reuse is in place
25 cryptroot.device = "/dev/vdb";
26 cryptroot2.device = "/dev/vdc";
28 virtualisation.rootDevice = "/dev/mapper/cryptroot";
30 boot-luks-custom-keymap.configuration = lib.mkMerge [
31 boot-luks.configuration
33 console.keyMap = "neo";
42 # Create encrypted volume
43 machine.wait_for_unit("multi-user.target")
44 machine.succeed("echo -n supersecret | cryptsetup luksFormat -q --iter-time=1 /dev/vdb -")
45 machine.succeed("echo -n supersecret | cryptsetup luksFormat -q --iter-time=1 /dev/vdc -")
47 # Boot from the encrypted disk
48 machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-luks.conf")
49 machine.succeed("sync")
52 # Boot and decrypt the disk
54 machine.wait_for_text("Passphrase for")
55 machine.send_chars("supersecret\n")
56 machine.wait_for_unit("multi-user.target")
58 assert "/dev/mapper/cryptroot on / type ext4" in machine.succeed("mount")
60 # Boot from the encrypted disk with custom keymap
61 machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-luks-custom-keymap.conf")
62 machine.succeed("sync")
65 # Boot and decrypt the disk
67 machine.wait_for_text("Passphrase for")
68 machine.send_chars("havfkhfrkfl\n")
69 machine.wait_for_unit("multi-user.target")
71 assert "/dev/mapper/cryptroot on / type ext4" in machine.succeed("mount")