From 15675bcc9908f2980529912dc154dc47f4c191cf Mon Sep 17 00:00:00 2001 From: Kabbone Date: Sun, 15 Jan 2023 19:12:35 +0100 Subject: [PATCH] hosts: btrbk fix definitions/mount --- hosts/desktop/hardware-configuration.nix | 49 +++++++++++++++--------- hosts/laptop/hardware-configuration.nix | 49 +++++++++++++++--------- hosts/server/hardware-configuration.nix | 49 +++++++++++++++--------- 3 files changed, 90 insertions(+), 57 deletions(-) diff --git a/hosts/desktop/hardware-configuration.nix b/hosts/desktop/hardware-configuration.nix index 06646f2..fe5d098 100644 --- a/hosts/desktop/hardware-configuration.nix +++ b/hosts/desktop/hardware-configuration.nix @@ -32,19 +32,30 @@ ]; }; - services.snapper.configs = { - home = { - subvolume = "/home"; - extraConfig = '' - TIMELINE_CREATE=yes - TIMELINE_CLEANUP=yes - TIMELINE_LIMIT_HOURLY="5" - TIMELINE_LIMIT_DAILY="5" - TIMELINE_LIMIT_WEEKLY="2" - TIMELINE_LIMIT_MONTHLY="2" - TIMELINE_LIMIT_YEARLY="0" - ''; - }; + services.btrbk = { + instances = { + hf = { + onCalendar = "hourly"; + settings = { + incremental = "yes"; + snapshot_create = "ondemand"; + snapshot_dir = "@snapshots"; + timestamp_format = "long"; + + snapshot_preserve = "2m 2w 5d 5h"; + snapshot_preserve_min = "latest"; + + volume = { + "/mnt/snapshots/root" = { + snapshot_create = "always"; + subvolume = { + "@home" = {}; + }; + }; + }; + }; + }; + }; }; fileSystems."/" = @@ -59,12 +70,6 @@ options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@home,discard=async" ]; }; - fileSystems."/home/.snapshots" = - { device = "/dev/disk/by-label/NIXROOT"; - fsType = "btrfs"; - options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@snapshots,discard=async" ]; - }; - fileSystems."/srv" = { device = "/dev/disk/by-label/NIXROOT"; fsType = "btrfs"; @@ -77,6 +82,12 @@ options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@nix,discard=async" ]; }; + fileSystems."/mnt/snapshots/root" = + { device = "/dev/disk/by-label/NIXROOT"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvolid=5,discard=async" ]; + }; + fileSystems."/boot" = { device = "/dev/disk/by-label/NIXBOOT"; fsType = "vfat"; diff --git a/hosts/laptop/hardware-configuration.nix b/hosts/laptop/hardware-configuration.nix index cbea40f..b4f338d 100644 --- a/hosts/laptop/hardware-configuration.nix +++ b/hosts/laptop/hardware-configuration.nix @@ -41,19 +41,30 @@ ]; }; - services.snapper.configs = { - home = { - subvolume = "/home"; - extraConfig = '' - TIMELINE_CREATE=yes - TIMELINE_CLEANUP=yes - TIMELINE_LIMIT_HOURLY="5" - TIMELINE_LIMIT_DAILY="5" - TIMELINE_LIMIT_WEEKLY="2" - TIMELINE_LIMIT_MONTHLY="2" - TIMELINE_LIMIT_YEARLY="0" - ''; - }; + services.btrbk = { + instances = { + hf = { + onCalendar = "hourly"; + settings = { + incremental = "yes"; + snapshot_create = "ondemand"; + snapshot_dir = "@snapshots"; + timestamp_format = "long"; + + snapshot_preserve = "2m 2w 5d 5h"; + snapshot_preserve_min = "latest"; + + volume = { + "/mnt/snapshots/root" = { + snapshot_create = "always"; + subvolume = { + "@home" = {}; + }; + }; + }; + }; + }; + }; }; fileSystems."/" = @@ -68,12 +79,6 @@ options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@home,discard=async" ]; }; - fileSystems."/home/.snapshots" = - { device = "/dev/mapper/root"; - fsType = "btrfs"; - options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@snapshots,discard=async" ]; - }; - fileSystems."/srv" = { device = "/dev/mapper/root"; fsType = "btrfs"; @@ -92,6 +97,12 @@ options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@nix,discard=async" ]; }; + fileSystems."/mnt/snapshots/root" = + { device = "/dev/disk/by-label/NIXROOT"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvolid=5,discard=async" ]; + }; + fileSystems."/boot" = { device = "/dev/disk/by-label/BOOT"; fsType = "vfat"; diff --git a/hosts/server/hardware-configuration.nix b/hosts/server/hardware-configuration.nix index b3a52d4..60c846f 100644 --- a/hosts/server/hardware-configuration.nix +++ b/hosts/server/hardware-configuration.nix @@ -32,19 +32,30 @@ ]; }; - services.snapper.configs = { - home = { - subvolume = "/home"; - extraConfig = '' - TIMELINE_CREATE=yes - TIMELINE_CLEANUP=yes - TIMELINE_LIMIT_HOURLY="5" - TIMELINE_LIMIT_DAILY="5" - TIMELINE_LIMIT_WEEKLY="2" - TIMELINE_LIMIT_MONTHLY="2" - TIMELINE_LIMIT_YEARLY="0" - ''; - }; + services.btrbk = { + instances = { + hf = { + onCalendar = "hourly"; + settings = { + incremental = "yes"; + snapshot_create = "ondemand"; + snapshot_dir = "@snapshots"; + timestamp_format = "long"; + + snapshot_preserve = "2m 2w 5d 5h"; + snapshot_preserve_min = "latest"; + + volume = { + "/mnt/snapshots/root" = { + snapshot_create = "always"; + subvolume = { + "@home" = {}; + }; + }; + }; + }; + }; + }; }; fileSystems."/" = @@ -59,12 +70,6 @@ options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@home,discard=async" ]; }; - fileSystems."/home/.snapshots" = - { device = "/dev/disk/by-label/NIXROOT"; - fsType = "btrfs"; - options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@snapshots,discard=async" ]; - }; - fileSystems."/srv" = { device = "/dev/disk/by-label/NIXROOT"; fsType = "btrfs"; @@ -77,6 +82,12 @@ options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@nix,discard=async" ]; }; + fileSystems."/mnt/snapshots/root" = + { device = "/dev/disk/by-label/NIXROOT"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvolid=5,discard=async" ]; + }; + swapDevices = [ ];