1 import ./make-test-python.nix ({ lib, pkgs, ... }: {
2 name = "systemd-initrd-btrfs-raid";
4 nodes.machine = { pkgs, ... }: {
7 emptyDiskImages = [ 512 512 ];
9 # Booting off the BTRFS RAID requires an available init script from the Nix store
10 mountHostNixStore = true;
13 boot.loader.systemd-boot.enable = true;
14 boot.loader.efi.canTouchEfiVariables = true;
16 environment.systemPackages = with pkgs; [ btrfs-progs ];
17 boot.initrd.systemd = {
19 emergencyAccess = true;
22 specialisation.boot-btrfs-raid.configuration = {
23 fileSystems = lib.mkVMOverride {
24 "/".fsType = lib.mkForce "btrfs";
26 virtualisation.rootDevice = "/dev/vdb";
32 machine.succeed("mkfs.btrfs -d raid0 /dev/vdb /dev/vdc")
33 machine.succeed("mkdir -p /mnt && mount /dev/vdb /mnt && echo hello > /mnt/test && umount /mnt")
36 machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-btrfs-raid.conf")
37 machine.succeed("sync")
39 machine.wait_for_unit("multi-user.target")
41 # Ensure we have successfully booted from the RAID
42 assert "(initrd)" in machine.succeed("systemd-analyze") # booted with systemd in stage 1
43 assert "/dev/vdb on / type btrfs" in machine.succeed("mount")
44 assert "hello" in machine.succeed("cat /test")
45 assert "Total devices 2" in machine.succeed("btrfs filesystem show")