# roles/thin-client/deployment/snapper.nix # # BTRFS snapshots for the root subvolume via snapper. Snapshots taken # before and after each `nixos-rebuild switch`, plus hourly/daily. # # Q18 decision: Generation-Picker + BTRFS-Snapshot. {config, lib, ...}: let inherit (lib) mkIf; cfg = config.az.tc; in { config = mkIf cfg.enable { services.snapper = { snapshotRootOnBoot = true; configs = { root = { SUBVOLUME = "/"; ALLOW_USERS = ["root"]; TIMELINE_CREATE = true; TIMELINE_CLEANUP = true; TIMELINE_LIMIT_HOURLY = "12"; TIMELINE_LIMIT_DAILY = "7"; TIMELINE_LIMIT_WEEKLY = "4"; TIMELINE_LIMIT_MONTHLY = "0"; }; }; }; # Take a snapshot before any nixos-rebuild switch — hooks into the # toplevel system path activation. system.activationScripts.snapperPreSwitch = { deps = []; text = '' if [ -d /.snapshots ]; then ${config.services.snapper.package}/bin/snapper -c root create \ -d "pre-switch $(date +%Y-%m-%d-%H%M)" || true fi ''; }; }; }