blob: 0369419930f15723645152b0cf9645e0ea95ae8d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
import ./make-test-python.nix ({ ... }:
{
name = "snapper";
nodes.machine = { pkgs, lib, ... }: {
boot.initrd.postDeviceCommands = ''
${pkgs.btrfs-progs}/bin/mkfs.btrfs -f -L aux /dev/vdb
'';
virtualisation.emptyDiskImages = [ 4096 ];
virtualisation.fileSystems = {
"/home" = {
device = "/dev/disk/by-label/aux";
fsType = "btrfs";
};
};
services.snapper.configs.home.SUBVOLUME = "/home";
services.snapper.filters = "/nix";
};
testScript = { nodes, ... }: let
inherit (nodes.machine.services.snapper) snapshotRootOnBoot;
in ''
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")
machine.${if snapshotRootOnBoot then "succeed" else "fail"}("systemctl cat snapper-boot.service")
'';
})
|