1 import ./make-test-python.nix ({ lib, ... }:
3 name = "swap-file-btrfs";
5 meta.maintainers = with lib.maintainers; [ oxalica ];
10 virtualisation.useDefaultFilesystems = false;
12 virtualisation.rootDevice = "/dev/vda";
14 boot.initrd.postDeviceCommands = ''
15 ${pkgs.btrfs-progs}/bin/mkfs.btrfs --label root /dev/vda
18 virtualisation.fileSystems = {
20 device = "/dev/disk/by-label/root";
27 device = "/var/swapfile";
34 machine.wait_for_unit('var-swapfile.swap')
35 # Ensure the swap file creation script ran to completion without failing when creating the swap file
36 machine.fail("systemctl is-failed --quiet mkswap-var-swapfile.service")
37 machine.succeed("stat --file-system --format=%T /var/swapfile | grep btrfs")
38 # First run. Auto creation.
39 machine.succeed("swapon --show | grep /var/swapfile")
44 # Second run. Use it as-is.
45 machine.wait_for_unit('var-swapfile.swap')
46 # Ensure the swap file creation script ran to completion without failing when the swap file already exists
47 machine.fail("systemctl is-failed --quiet mkswap-var-swapfile.service")
48 machine.succeed("swapon --show | grep /var/swapfile")