From ea9d42b778ccc1cb41ff25144f2d62ca8c119639 Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 19 Jan 2025 08:18:12 +0000 Subject: [PATCH] snapper: enable for ALL hosts --- hosts/by-name/desko/default.nix | 27 --------------------------- hosts/common/default.nix | 1 + hosts/common/snapper.nix | 29 +++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 27 deletions(-) create mode 100644 hosts/common/snapper.nix diff --git a/hosts/by-name/desko/default.nix b/hosts/by-name/desko/default.nix index 7407fb8f0..54432e2f3 100644 --- a/hosts/by-name/desko/default.nix +++ b/hosts/by-name/desko/default.nix @@ -53,31 +53,4 @@ # TODO(2025-01-01): re-enable once rocm build is fixed: # hardware.amdgpu.opencl.enable = true; # desktop (AMD's opencl implementation AKA "ROCM"); probably required for ollama - - # snapper: btrfs auto-snapshots: - # - - # - `man snapper-configs` - # - # to list snapshots: `snapper list` - # to take a snapshot: `snapper create` or `systemctl start snapper-timeline.service` - # - # FIRST TIME SETUP: - # - `sudo btrfs subvolume create /nix/persist` - # - if migrating from a non-subvol `/nix/persist`, then: - # - `sudo btrfs subvolume create /nix/persist.new` - # - `sudo cp --archive --one-file-system --reflink=always /nix/persist/. /nix/persist.new` - # - `sudo bash -c 'mv /nix/persist /nix/persist.old && mv /nix/persist.new /nix/persist` - # - `sudo btrfs subvolume create /nix/persist/.snapshots` - # - reboot (else all snapper calls will fail due to dbus errors) - services.snapper.configs.root = { - SUBVOLUME = "/nix/persist"; - ALLOW_USERS = [ "colin" ]; - TIMELINE_CLEANUP = true; # remove old snapshots every 24h - TIMELINE_CREATE = true; # take a snapshot every hour - TIMELINE_LIMIT_HOURLY = 12; - TIMELINE_LIMIT_DAILY = 7; # keep snapshots for 1d ago, 2d ago, ... 7day ago - TIMELINE_LIMIT_WEEKLY = 4; # keep snapshots for 7d ago, 14d ago, 21d ago, 28d ago - TIMELINE_LIMIT_MONTHLY = 0; - TIMELINE_LIMIT_YEARLY = 0; - }; } diff --git a/hosts/common/default.nix b/hosts/common/default.nix index 1dcf36912..0bfb1f911 100644 --- a/hosts/common/default.nix +++ b/hosts/common/default.nix @@ -14,6 +14,7 @@ ./programs ./quirks.nix ./secrets.nix + ./snapper.nix ./ssh.nix ./systemd.nix ./users diff --git a/hosts/common/snapper.nix b/hosts/common/snapper.nix new file mode 100644 index 000000000..b3d8432b9 --- /dev/null +++ b/hosts/common/snapper.nix @@ -0,0 +1,29 @@ +{ ... }: +{ + # snapper: btrfs auto-snapshots: + # - + # - `man snapper-configs` + # + # to list snapshots: `snapper list` + # to take a snapshot: `snapper create` or `systemctl start snapper-timeline.service` + # + # FIRST TIME SETUP: + # - `sudo btrfs subvolume create /nix/persist` + # - if migrating from a non-subvol `/nix/persist`, then: + # - `sudo btrfs subvolume create /nix/persist.new` + # - `sudo cp --archive --one-file-system --reflink=always /nix/persist/. /nix/persist.new` + # - `sudo bash -c 'mv /nix/persist /nix/persist.old && mv /nix/persist.new /nix/persist` + # - `sudo btrfs subvolume create /nix/persist/.snapshots` + # - reboot (else all snapper calls will fail due to dbus errors) + services.snapper.configs.root = { + SUBVOLUME = "/nix/persist"; + ALLOW_USERS = [ "colin" ]; + TIMELINE_CLEANUP = true; # remove old snapshots every 24h + TIMELINE_CREATE = true; # take a snapshot every hour + TIMELINE_LIMIT_HOURLY = 12; + TIMELINE_LIMIT_DAILY = 7; # keep snapshots for 1d ago, 2d ago, ... 7day ago + TIMELINE_LIMIT_WEEKLY = 4; # keep snapshots for 7d ago, 14d ago, 21d ago, 28d ago + TIMELINE_LIMIT_MONTHLY = 0; + TIMELINE_LIMIT_YEARLY = 0; + }; +}