nixpkgs/nixos/tests/snapper.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
1.1 KiB
Nix
Raw Normal View History

2019-11-06 14:44:51 +03:00
import ./make-test-python.nix ({ ... }:
2017-07-05 17:19:32 +03:00
{
name = "snapper";
2022-03-21 02:15:30 +03:00
nodes.machine = { pkgs, lib, ... }: {
2017-07-05 17:19:32 +03:00
boot.initrd.postDeviceCommands = ''
${pkgs.btrfs-progs}/bin/mkfs.btrfs -f -L aux /dev/vdb
'';
virtualisation.emptyDiskImages = [ 4096 ];
virtualisation.fileSystems = {
2017-07-05 17:19:32 +03:00
"/home" = {
device = "/dev/disk/by-label/aux";
fsType = "btrfs";
};
};
services.snapper.configs.home.subvolume = "/home";
services.snapper.filters = "/nix";
};
testScript = ''
2019-11-06 14:44:51 +03: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")
2017-07-05 17:19:32 +03:00
'';
})