1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-21 21:21:06 +00:00
nixpkgs/nixos/tests/snapper.nix
Christian Kögler e8a8f1233a snapper: add nixos module
fixes #27154
2017-07-16 10:06:42 +01:00

44 lines
1.1 KiB
Nix

import ./make-test.nix ({ ... }:
{
name = "snapper";
machine = { pkgs, lib, ... }: {
boot.initrd.postDeviceCommands = ''
${pkgs.btrfs-progs}/bin/mkfs.btrfs -f -L aux /dev/vdb
'';
virtualisation.emptyDiskImages = [ 4096 ];
fileSystems = lib.mkVMOverride {
"/home" = {
device = "/dev/disk/by-label/aux";
fsType = "btrfs";
};
};
services.snapper.configs.home.subvolume = "/home";
services.snapper.filters = "/nix";
};
testScript = ''
$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");
'';
})