nixos/snapper: Don't create broken snapper-boot.service

This commit is contained in:
Rodney Lorrimar 2024-06-18 10:31:50 +08:00
parent b60ebf54c1
commit 52ef91d339
No known key found for this signature in database
GPG Key ID: D8B75C95FB4D1143
2 changed files with 5 additions and 2 deletions

View File

@ -235,7 +235,7 @@ in
timerConfig.OnUnitActiveSec = cfg.cleanupInterval;
};
systemd.services.snapper-boot = lib.optionalAttrs cfg.snapshotRootOnBoot {
systemd.services.snapper-boot = lib.mkIf cfg.snapshotRootOnBoot {
description = "Take snapper snapshot of root on boot";
inherit documentation;
serviceConfig.ExecStart = "${pkgs.snapper}/bin/snapper --config root create --cleanup-algorithm number --description boot";

View File

@ -19,7 +19,9 @@ import ./make-test-python.nix ({ ... }:
services.snapper.filters = "/nix";
};
testScript = ''
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")
@ -31,5 +33,6 @@ import ./make-test-python.nix ({ ... }:
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")
'';
})