2019-11-06 11:44:51 +00:00
|
|
|
import ./make-test-python.nix (
|
|
|
|
{ ... }:
|
2017-07-05 14:19:32 +00:00
|
|
|
{
|
|
|
|
name = "snapper";
|
|
|
|
|
2022-03-20 23:15:30 +00:00
|
|
|
nodes.machine =
|
|
|
|
{ pkgs, lib, ... }:
|
|
|
|
{
|
2017-07-05 14:19:32 +00:00
|
|
|
boot.initrd.postDeviceCommands = ''
|
|
|
|
${pkgs.btrfs-progs}/bin/mkfs.btrfs -f -L aux /dev/vdb
|
|
|
|
'';
|
|
|
|
|
|
|
|
virtualisation.emptyDiskImages = [ 4096 ];
|
|
|
|
|
2021-02-14 11:23:50 +00:00
|
|
|
virtualisation.fileSystems = {
|
2017-07-05 14:19:32 +00:00
|
|
|
"/home" = {
|
|
|
|
device = "/dev/disk/by-label/aux";
|
|
|
|
fsType = "btrfs";
|
2024-12-10 19:26:33 +00:00
|
|
|
};
|
|
|
|
};
|
2023-06-18 14:20:31 +00:00
|
|
|
services.snapper.configs.home.SUBVOLUME = "/home";
|
2017-07-05 14:19:32 +00:00
|
|
|
services.snapper.filters = "/nix";
|
|
|
|
};
|
|
|
|
|
2024-06-18 02:31:50 +00:00
|
|
|
testScript =
|
|
|
|
{ nodes, ... }:
|
|
|
|
let
|
|
|
|
inherit (nodes.machine.services.snapper) snapshotRootOnBoot;
|
|
|
|
in
|
|
|
|
''
|
2019-11-06 11:44:51 +00:00
|
|
|
machine.succeed("btrfs subvolume create /home/.snapshots")
|
|
|
|
machine.succeed("snapper -c home list")
|
|
|
|
machine.succeed("snapper -c home create --description empty")
|
|
|
|
machine.succeed("echo test > /home/file")
|
|
|
|
machine.succeed("snapper -c home create --description file")
|
|
|
|
machine.succeed("snapper -c home status 1..2")
|
|
|
|
machine.succeed("snapper -c home undochange 1..2")
|
|
|
|
machine.fail("ls /home/file")
|
|
|
|
machine.succeed("snapper -c home delete 2")
|
|
|
|
machine.succeed("systemctl --wait start snapper-timeline.service")
|
|
|
|
machine.succeed("systemctl --wait start snapper-cleanup.service")
|
2024-06-18 02:31:50 +00:00
|
|
|
machine.${if snapshotRootOnBoot then "succeed" else "fail"}("systemctl cat snapper-boot.service")
|
2017-07-05 14:19:32 +00:00
|
|
|
'';
|
|
|
|
}
|
|
|
|
)
|