diff --git a/example/luks-multiple.nix b/example/luks-multiple.nix new file mode 100644 index 0000000..88775d2 --- /dev/null +++ b/example/luks-multiple.nix @@ -0,0 +1,65 @@ +{ + disko.devices = { + disk = { + main = { + type = "disk"; + device = "/dev/vdb"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "500M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + root = { + size = "100%"; + content = { + type = "luks"; + name = "root"; + extraOpenArgs = [ ]; + settings = { + # if you want to use the key for interactive login be sure there is no trailing newline + # for example use `echo -n "password" > /tmp/secret.key` + keyFile = "/tmp/secret.key"; + allowDiscards = true; + }; + additionalKeyFiles = [ "/tmp/additionalSecret.key" ]; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + }; + }; + }; + home = { + size = "100M"; + content = { + type = "luks"; + name = "home"; + extraOpenArgs = [ ]; + settings = { + # if you want to use the key for interactive login be sure there is no trailing newline + # for example use `echo -n "password" > /tmp/secret.key` + keyFile = "/tmp/secret.key"; + allowDiscards = true; + }; + additionalKeyFiles = [ "/tmp/additionalSecret.key" ]; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/home"; + }; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/lib/tests.nix b/lib/tests.nix index 4b8b95a..eef986d 100644 --- a/lib/tests.nix +++ b/lib/tests.nix @@ -82,6 +82,8 @@ let efi ? !pkgs.stdenv.hostPlatform.isRiscV64, enableCanokey ? false, postDisko ? "", + postUnmountPreMount ? "", + postMount ? "", testMode ? "module", # can be one of direct module cli testBoot ? true, # if we actually want to test booting or just create/mount enableOCR ? false, @@ -369,7 +371,9 @@ let machine.succeed("${lib.getExe tsp-mount}") # verify that mount is idempotent machine.succeed("${lib.getExe tsp-unmount}") machine.succeed("${lib.getExe tsp-unmount}") # verify that umount is idempotent + ${postUnmountPreMount} machine.succeed("${lib.getExe tsp-mount}") # verify that mount is idempotent + ${postMount} machine.succeed("${lib.getExe tsp-disko} --yes-wipe-all-disks") # verify that we can destroy and recreate machine.succeed("mkdir -p /mnt/home") machine.succeed("touch /mnt/home/testfile") @@ -383,7 +387,9 @@ let machine.succeed("${lib.getExe nodes.machine.system.build.mount}") # verify that mount is idempotent machine.succeed("${lib.getExe nodes.machine.system.build.unmount}") machine.succeed("${lib.getExe nodes.machine.system.build.unmount}") # verify that unmount is idempotent + ${postUnmountPreMount} machine.succeed("${lib.getExe nodes.machine.system.build.mount}") # verify that mount is idempotent + ${postMount} machine.succeed("${lib.getExe nodes.machine.system.build.destroyFormatMount} --yes-wipe-all-disks") # verify that we can destroy and recreate again machine.succeed("mkdir -p /mnt/home") machine.succeed("touch /mnt/home/testfile") diff --git a/tests/luks-multiple.nix b/tests/luks-multiple.nix new file mode 100644 index 0000000..bb0bb95 --- /dev/null +++ b/tests/luks-multiple.nix @@ -0,0 +1,22 @@ +{ + pkgs ? import { }, + diskoLib ? pkgs.callPackage ../lib { }, +}: +diskoLib.testLib.makeDiskoTest { + inherit pkgs; + name = "luks-multiple"; + disko-config = ../example/luks-multiple.nix; + testBoot = false; + postUnmountPreMount = '' + machine.fail("mountpoint /mnt/"); + machine.fail("mountpoint /mnt/home"); + machine.fail("${pkgs.cryptsetup}/bin/cryptsetup status root") + machine.fail("${pkgs.cryptsetup}/bin/cryptsetup status home") + ''; + postMount = '' + machine.succeed("mountpoint /mnt/"); + machine.succeed("mountpoint /mnt/home"); + machine.succeed("${pkgs.cryptsetup}/bin/cryptsetup status root") + machine.succeed("${pkgs.cryptsetup}/bin/cryptsetup status home") + ''; +}