mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-15 14:26:33 +01:00
46 lines
1.1 KiB
Nix
46 lines
1.1 KiB
Nix
import ./make-test-python.nix ({ lib, ... }:
|
|
{
|
|
name = "swap-file-btrfs";
|
|
|
|
meta.maintainers = with lib.maintainers; [ oxalica ];
|
|
|
|
nodes.machine =
|
|
{ pkgs, ... }:
|
|
{
|
|
virtualisation.useDefaultFilesystems = false;
|
|
|
|
virtualisation.bootDevice = "/dev/vda";
|
|
|
|
boot.initrd.postDeviceCommands = ''
|
|
${pkgs.btrfs-progs}/bin/mkfs.btrfs --label root /dev/vda
|
|
'';
|
|
|
|
virtualisation.fileSystems = {
|
|
"/" = {
|
|
device = "/dev/disk/by-label/root";
|
|
fsType = "btrfs";
|
|
};
|
|
};
|
|
|
|
swapDevices = [
|
|
{
|
|
device = "/var/swapfile";
|
|
size = 1; # 1MiB.
|
|
}
|
|
];
|
|
};
|
|
|
|
testScript = ''
|
|
machine.wait_for_unit('var-swapfile.swap')
|
|
machine.succeed("stat --file-system --format=%T /var/swapfile | grep btrfs")
|
|
# First run. Auto creation.
|
|
machine.succeed("swapon --show | grep /var/swapfile")
|
|
|
|
machine.shutdown()
|
|
machine.start()
|
|
|
|
# Second run. Use it as-is.
|
|
machine.wait_for_unit('var-swapfile.swap')
|
|
machine.succeed("swapon --show | grep /var/swapfile")
|
|
'';
|
|
})
|