summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtturin <Artturin@artturin.com>2024-06-19 14:59:00 +0300
committerGitHub <noreply@github.com>2024-06-19 14:59:00 +0300
commit7324a175cf6d174a13926ad026eff71c88e296e4 (patch)
tree927644d64ef5efe8f1c9578ad91d223089ae1207
parentc249dd3effcb56cb34b4a4b771d759e75ffeee44 (diff)
parent52ef91d3399b37085db9726e120bc50b4a57a9cb (diff)
Merge pull request #320673 from rvl/snapper-systemd-fix
nixos/snapper: Don't create broken snapper-boot.service
-rw-r--r--nixos/modules/services/misc/snapper.nix2
-rw-r--r--nixos/tests/snapper.nix5
2 files changed, 5 insertions, 2 deletions
diff --git a/nixos/modules/services/misc/snapper.nix b/nixos/modules/services/misc/snapper.nix
index a42fca5b6028..4e0b4c551e23 100644
--- a/nixos/modules/services/misc/snapper.nix
+++ b/nixos/modules/services/misc/snapper.nix
@@ -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";
diff --git a/nixos/tests/snapper.nix b/nixos/tests/snapper.nix
index 674523584fda..0369419930f1 100644
--- a/nixos/tests/snapper.nix
+++ b/nixos/tests/snapper.nix
@@ -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")
'';
})