diff options
author | Matthias Berndt <matthias_berndt@gmx.de> | 2023-05-07 18:47:44 +0200 |
---|---|---|
committer | Matthias Berndt <matthias_berndt@gmx.de> | 2023-05-07 18:48:28 +0200 |
commit | d1411444b62e4d4c0d83dd8d7d44a4a45de1c51d (patch) | |
tree | cebedd8cfdb64cb28c3a7b93f7d843eca37abbfe /nixos | |
parent | 9f1bc0fa02647fb826968f5d217c204feb38babc (diff) | |
download | nixlib-d1411444b62e4d4c0d83dd8d7d44a4a45de1c51d.tar nixlib-d1411444b62e4d4c0d83dd8d7d44a4a45de1c51d.tar.gz nixlib-d1411444b62e4d4c0d83dd8d7d44a4a45de1c51d.tar.bz2 nixlib-d1411444b62e4d4c0d83dd8d7d44a4a45de1c51d.tar.lz nixlib-d1411444b62e4d4c0d83dd8d7d44a4a45de1c51d.tar.xz nixlib-d1411444b62e4d4c0d83dd8d7d44a4a45de1c51d.tar.zst nixlib-d1411444b62e4d4c0d83dd8d7d44a4a45de1c51d.zip |
add installer test for stratis root fs
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/tests/installer-systemd-stage-1.nix | 1 | ||||
-rw-r--r-- | nixos/tests/installer.nix | 60 |
2 files changed, 58 insertions, 3 deletions
diff --git a/nixos/tests/installer-systemd-stage-1.nix b/nixos/tests/installer-systemd-stage-1.nix index 03f0ec8d746b..05fb2b2ae89c 100644 --- a/nixos/tests/installer-systemd-stage-1.nix +++ b/nixos/tests/installer-systemd-stage-1.nix @@ -27,6 +27,7 @@ simpleUefiGrub simpleUefiGrubSpecialisation simpleUefiSystemdBoot + stratisRoot # swraid zfsroot ; diff --git a/nixos/tests/installer.nix b/nixos/tests/installer.nix index 51d0d232ebbf..5a58744d6209 100644 --- a/nixos/tests/installer.nix +++ b/nixos/tests/installer.nix @@ -19,6 +19,7 @@ let { imports = [ ./hardware-configuration.nix <nixpkgs/nixos/modules/testing/test-instrumentation.nix> + ./amendments.nix ]; documentation.enable = false; @@ -72,7 +73,7 @@ let # partitions and filesystems. testScriptFun = { bootLoader, createPartitions, grubVersion, grubDevice, grubUseEfi , grubIdentifier, preBootCommands, postBootCommands, extraConfig - , testSpecialisationConfig + , testSpecialisationConfig, amendConfig }: let iface = if grubVersion == 1 then "ide" else "virtio"; isEfi = bootLoader == "systemd-boot" || (bootLoader == "grub" && grubUseEfi); @@ -129,6 +130,9 @@ let "/mnt/etc/nixos/configuration.nix", ) machine.copy_from_host("${pkgs.writeText "secret" "secret"}", "/mnt/etc/nixos/secret") + amendments = '{}' + ${amendConfig} + machine.succeed(f"printf '{amendments}' > /mnt/etc/nixos/amendments.nix") with subtest("Perform the installation"): machine.succeed("nixos-install < /dev/null >&2") @@ -281,7 +285,7 @@ let makeInstallerTest = name: - { createPartitions, preBootCommands ? "", postBootCommands ? "", extraConfig ? "" + { createPartitions, preBootCommands ? "", postBootCommands ? "", extraConfig ? "", amendConfig ? "" , extraInstallerConfig ? {} , bootLoader ? "grub" # either "grub" or "systemd-boot" , grubVersion ? 2, grubDevice ? "/dev/vda", grubIdentifier ? "uuid", grubUseEfi ? false @@ -392,7 +396,7 @@ let testScript = testScriptFun { inherit bootLoader createPartitions preBootCommands postBootCommands - grubVersion grubDevice grubIdentifier grubUseEfi extraConfig + grubVersion grubDevice grubIdentifier grubUseEfi extraConfig amendConfig testSpecialisationConfig; }; }; @@ -1017,4 +1021,54 @@ in { ) ''; }; +} // optionalAttrs systemdStage1 { + stratisRoot = makeInstallerTest "stratisRoot" { + createPartitions = '' + machine.succeed( + "sgdisk --zap-all /dev/vda", + "sgdisk --new=1:0:+100M --typecode=0:ef00 /dev/vda", # /boot + "sgdisk --new=2:0:+1G --typecode=0:8200 /dev/vda", # swap + "sgdisk --new=3:0:+5G --typecode=0:8300 /dev/vda", # / + "udevadm settle", + + "mkfs.vfat /dev/vda1", + "mkswap /dev/vda2 -L swap", + "swapon -L swap", + "stratis pool create my-pool /dev/vda3", + "stratis filesystem create my-pool nixos", + "udevadm settle", + + "mount /dev/stratis/my-pool/nixos /mnt", + "mkdir -p /mnt/boot", + "mount /dev/vda1 /mnt/boot" + ) + ''; + bootLoader = "systemd-boot"; + extraInstallerConfig = { modulesPath, ...}: { + imports = [ (modulesPath + "/tasks/stratis.nix") ]; + config = { + services.stratis.enable = true; + environment.systemPackages = [ + pkgs.stratis-cli + pkgs.thin-provisioning-tools + pkgs.lvm2.bin + pkgs.stratisd.initrd + ]; + }; + }; + amendConfig = '' + # This comment is here for Python indentation purposes + (header, pool_line) = machine.succeed("stratis pool list").splitlines() + index = header.find("UUID") + uuid = pool_line[index - 32: index + 4] + amendments = f"""{{ modulesPath, ... }}: {{ + imports = [ + (modulesPath + "/system/boot/stratisroot.nix") + ]; + config = {{ + boot.stratis.rootPoolUuid = "{uuid}"; + }}; + }}""" + ''; + }; } |