From 491e567d47b027ac466fb7f2aa5ca1cfc2ef5aef Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 10 Aug 2023 12:47:01 +0200 Subject: [PATCH] tests: enable swraid, add luks-on-mdadm test --- example/luks-on-mdadm.nix | 58 +++++++++++++++++++++++++++++++++++++++ lib/tests.nix | 5 +++- tests/luks-on-mdadm.nix | 16 +++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 example/luks-on-mdadm.nix create mode 100644 tests/luks-on-mdadm.nix diff --git a/example/luks-on-mdadm.nix b/example/luks-on-mdadm.nix new file mode 100644 index 0000000..1a39d1b --- /dev/null +++ b/example/luks-on-mdadm.nix @@ -0,0 +1,58 @@ +{ lib, ... }: +{ + disko.devices.disk = lib.genAttrs [ "a" "b" ] (name: { + type = "disk"; + device = "/dev/sd${name}"; + content = { + type = "gpt"; + partitions = { + boot = { + size = "1M"; + type = "EF02"; # for grub MBR + }; + ESP = { + size = "100M"; + type = "EF00"; + content = { + type = "mdraid"; + name = "boot"; + }; + }; + mdadm = { + size = "100%"; + content = { + type = "mdraid"; + name = "raid1"; + }; + }; + }; + }; + }); + disko.devices.mdadm = { + boot = { + type = "mdadm"; + level = 1; + metadata = "1.0"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + raid1 = { + type = "mdadm"; + level = 1; + content = { + type = "luks"; + name = "crypted"; + settings.keyFile = "/tmp/secret.key"; + content= { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + }; + }; + }; + }; +} + diff --git a/lib/tests.nix b/lib/tests.nix index eacf86e..9558175 100644 --- a/lib/tests.nix +++ b/lib/tests.nix @@ -167,11 +167,14 @@ let networking.hostId = "8425e349"; }) ]; + + boot.initrd.services.swraid.enable = true; + systemd.services.mdmonitor.enable = false; # silence some weird warnings + environment.systemPackages = [ pkgs.jq ]; - # speed-up eval documentation.enable = false; diff --git a/tests/luks-on-mdadm.nix b/tests/luks-on-mdadm.nix new file mode 100644 index 0000000..bd49762 --- /dev/null +++ b/tests/luks-on-mdadm.nix @@ -0,0 +1,16 @@ +{ pkgs ? import { } +, diskoLib ? pkgs.callPackage ../lib { } +}: +diskoLib.testLib.makeDiskoTest { + inherit pkgs; + name = "luks-on-mdadm"; + disko-config = ../example/luks-on-mdadm.nix; + extraTestScript = '' + machine.succeed("test -b /dev/md/raid1"); + machine.succeed("mountpoint /"); + ''; + extraSystemConfig = { + # sadly systemd-boot fails to install to a raid /boot device + boot.loader.systemd-boot.enable = false; + }; +}