From 7c499fed495771a1571b3b5588e72d43b825cb6a Mon Sep 17 00:00:00 2001 From: LavaDesu Date: Sun, 18 Jun 2023 20:54:08 +0700 Subject: [PATCH] hyacinth/filesystem: add cream --- hosts/hyacinth/filesystem.nix | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/hosts/hyacinth/filesystem.nix b/hosts/hyacinth/filesystem.nix index 3d15369..2b7a296 100644 --- a/hosts/hyacinth/filesystem.nix +++ b/hosts/hyacinth/filesystem.nix @@ -1,13 +1,14 @@ -{ config, ... }: +{ config, lib, ... }: let mkLabelMount = label: type: { device = "/dev/disk/by-label/${label}"; fsType = type; options = [ "defaults" "relatime" ]; }; - mkBtrfsMount = subvol: atime: mkLabelMount "CAKE" "btrfs" // { + mkBtrfsMount = name: subvol: atime: mkLabelMount name "btrfs" // { options = [ "autodefrag" "compress=zstd:3" "defaults" "discard=async" "space_cache=v2" "ssd" "subvol=${subvol}" (if atime then "relatime" else "noatime") ]; }; + mkCakeMount = mkBtrfsMount "CAKE"; in { fileSystems = { @@ -18,12 +19,14 @@ in }; "/boot" = mkLabelMount "CUP" "vfat"; - "/mnt/butter" = mkBtrfsMount "/" true; - "/nix" = mkBtrfsMount "/current/snow" false; - "/home" = mkBtrfsMount "/current/home" true; - "/home/.snapshots" = mkBtrfsMount "/snapshot/home" false; - "/root" = mkBtrfsMount "/current/root" false; - "/var" = mkBtrfsMount "/current/var" false; + "/mnt/butter" = mkCakeMount "/" true; + "/mnt/cream" = mkBtrfsMount "CREAM" "/" true; + "/mnt/cream/permanence/.snapshots" = mkBtrfsMount "CREAM" "/snapshot/permanence" false; + "/nix" = mkCakeMount "/current/snow" false; + "/home" = mkCakeMount "/current/home" true; + "/home/.snapshots" = mkCakeMount "/snapshot/home" false; + "/root" = mkCakeMount "/current/root" false; + "/var" = mkCakeMount "/current/var" false; "/persist" = { depends = [ "/var" ]; device = "/var/persist"; @@ -32,4 +35,18 @@ in neededForBoot = true; }; }; + services.snapper.configs.cream = { + fstype = "btrfs"; + subvolume = "/mnt/cream/permanence"; + extraConfig = lib.concatStringsSep "\n" (lib.mapAttrsToList (k: v: "${k}=${v}") { + TIMELINE_CLEANUP = "yes"; + TIMELINE_CREATE = "yes"; + TIMELINE_MIN_AGE = "1800"; + TIMELINE_LIMIT_HOURLY = "5"; + TIMELINE_LIMIT_DAILY = "7"; + TIMELINE_LIMIT_WEEKLY = "0"; + TIMELINE_LIMIT_MONTHLY = "0"; + TIMELINE_LIMIT_YEARLY = "0"; + }); + }; }