diff options
author | Artturin <Artturin@artturin.com> | 2024-06-19 14:59:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-19 14:59:00 +0300 |
commit | 7324a175cf6d174a13926ad026eff71c88e296e4 (patch) | |
tree | 927644d64ef5efe8f1c9578ad91d223089ae1207 /nixos | |
parent | c249dd3effcb56cb34b4a4b771d759e75ffeee44 (diff) | |
parent | 52ef91d3399b37085db9726e120bc50b4a57a9cb (diff) |
Merge pull request #320673 from rvl/snapper-systemd-fix
nixos/snapper: Don't create broken snapper-boot.service
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/misc/snapper.nix | 2 | ||||
-rw-r--r-- | nixos/tests/snapper.nix | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/nixos/modules/services/misc/snapper.nix b/nixos/modules/services/misc/snapper.nix index a42fca5b60289..4e0b4c551e23f 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 674523584fdaa..0369419930f15 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") ''; }) |