From ed91ce121670b41209933d94574b8ba3b7e73e98 Mon Sep 17 00:00:00 2001 From: iFargle Date: Tue, 12 Dec 2023 14:23:58 +0900 Subject: [PATCH] Add snapper for btrfs snapshot management --- README.md | 1 + nixos/common/services/snapper.nix | 9 +++++++++ nixos/hosts/framework-server/disks.nix | 2 ++ nixos/hosts/nixos-desktop/disks.nix | 4 ++-- nixos/hosts/nixos-framework/disks.nix | 2 ++ 5 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 nixos/common/services/snapper.nix diff --git a/README.md b/README.md index f30b38ea..0bc58980 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ nix develop -c /etc/nixos/git/docs/setup.sh * Container running piaware software # To Do List +* [x] Set up Snapper - [Link](https://search.nixos.org/options?channel=23.11&size=50&sort=relevance&type=packages&query=snapper) * [ ] Try Attic - A self-hosted Nix Binary Cache server - [Link](https://discourse.nixos.org/t/introducing-attic-a-self-hostable-nix-binary-cache-server/24343) * [ ] Try [compose2nix](https://github.com/aksiksi/compose2nix) - Docker Compose to Nix converter * [ ] Make a dashboard for all Nixified devices (online status) diff --git a/nixos/common/services/snapper.nix b/nixos/common/services/snapper.nix new file mode 100644 index 00000000..16e4d591 --- /dev/null +++ b/nixos/common/services/snapper.nix @@ -0,0 +1,9 @@ +{ pkgs, desktop, ... }: { + environment.systemPackages = [ ] ++ lib.optional (builtins.isString desktop) pkgs.snapper-gui; + + services.snapper = { + snapshotRootOnBoot = true; + cleanupInterval = "1d"; + snapshotInterval = "1h"; + }; +} \ No newline at end of file diff --git a/nixos/hosts/framework-server/disks.nix b/nixos/hosts/framework-server/disks.nix index f52de50e..bec29eed 100644 --- a/nixos/hosts/framework-server/disks.nix +++ b/nixos/hosts/framework-server/disks.nix @@ -1,4 +1,6 @@ { + imports = [ ../../common/services/snapper.nix ]; + services.btrfs.autoScrub.enable = true; services.btrfs.autoScrub.interval = "weekly"; diff --git a/nixos/hosts/nixos-desktop/disks.nix b/nixos/hosts/nixos-desktop/disks.nix index 8edbc748..88cca34c 100644 --- a/nixos/hosts/nixos-desktop/disks.nix +++ b/nixos/hosts/nixos-desktop/disks.nix @@ -1,6 +1,6 @@ { - boot.loader.grub.device = "/dev/nvme0n1"; - boot.initrd.luks.devices."ROOT".device = "/dev/nvme0n1p2"; + imports = [ ../../common/services/snapper.nix ]; + services.btrfs.autoScrub.enable = true; services.btrfs.autoScrub.interval = "weekly"; diff --git a/nixos/hosts/nixos-framework/disks.nix b/nixos/hosts/nixos-framework/disks.nix index dd5ffaae..c6322a5b 100644 --- a/nixos/hosts/nixos-framework/disks.nix +++ b/nixos/hosts/nixos-framework/disks.nix @@ -1,4 +1,6 @@ { + imports = [ ../../common/services/snapper.nix ]; + services.btrfs.autoScrub.enable = true; services.btrfs.autoScrub.interval = "weekly";