From 7e13619f6b8398d5bd2a24226709a186b1193974 Mon Sep 17 00:00:00 2001
From: Julien Moutinho <julm@sourcephile.fr>
Date: Thu, 15 Jul 2021 19:12:47 +0200
Subject: [PATCH] sanoid: use recursive

---
 hosts/losurdo/gitolite.nix                    |  2 +-
 .../losurdo/nginx/sourcephile.fr/cryptpad.nix |  2 +-
 hosts/losurdo/postgresql.nix                  |  2 +-
 hosts/losurdo/sanoid.nix                      | 56 ++++++++-----------
 nixpkgs/patches.nix                           |  5 ++
 5 files changed, 31 insertions(+), 36 deletions(-)

diff --git a/hosts/losurdo/gitolite.nix b/hosts/losurdo/gitolite.nix
index f88d78d..a3550c6 100644
--- a/hosts/losurdo/gitolite.nix
+++ b/hosts/losurdo/gitolite.nix
@@ -45,7 +45,7 @@ fileSystems."/var/lib/gitolite" = {
   fsType = "zfs";
 };
 services.sanoid.datasets."${hostName}/var/git" = {
-  use_template = [ "local" ];
+  use_template = [ "snap" ];
   daily = 7;
 };
 }
diff --git a/hosts/losurdo/nginx/sourcephile.fr/cryptpad.nix b/hosts/losurdo/nginx/sourcephile.fr/cryptpad.nix
index 410d958..dfda9b9 100644
--- a/hosts/losurdo/nginx/sourcephile.fr/cryptpad.nix
+++ b/hosts/losurdo/nginx/sourcephile.fr/cryptpad.nix
@@ -146,7 +146,7 @@ fileSystems."/var/lib/private/cryptpad" = {
 
 services.sanoid.datasets = {
   "${hostName}/var/cryptpad" = {
-    use_template = [ "local" ];
+    use_template = [ "snap" ];
     daily = 31;
   };
 };
diff --git a/hosts/losurdo/postgresql.nix b/hosts/losurdo/postgresql.nix
index 33824c7..ad3a92d 100644
--- a/hosts/losurdo/postgresql.nix
+++ b/hosts/losurdo/postgresql.nix
@@ -77,7 +77,7 @@ services.syncoid.commands = {
 };
 services.sanoid.datasets = {
   "${hostName}/var/postgresql" = {
-    use_template = [ "local" ];
+    use_template = [ "snap" ];
     daily = 31;
   };
 };
diff --git a/hosts/losurdo/sanoid.nix b/hosts/losurdo/sanoid.nix
index 44bd1ed..5969842 100644
--- a/hosts/losurdo/sanoid.nix
+++ b/hosts/losurdo/sanoid.nix
@@ -3,15 +3,23 @@
 services.sanoid = {
   enable = true;
   templates = {
-    local = {
+    snap = {
       autosnap = true;
       autoprune = true;
+      yearly = 0;
       monthly = 3;
+      daily = 31;
+      hourly = 24;
+      frequently = 0;
     };
-    remote = {
+    prune = {
       autosnap = false;
       autoprune = true;
+      yearly = 0;
       monthly = 3;
+      daily = 31;
+      hourly = 24;
+      frequently = 0;
     };
   };
   extraArgs = [
@@ -20,43 +28,25 @@ services.sanoid = {
   ];
   datasets = {
     "${hostName}/home/julm/work" = {
-      use_template = [ "local" ];
-      daily = 31;
-    };
-    "${hostName}/backup/mermet/var/git" = {
-      use_template = [ "remote" ];
-      daily = 7;
+      use_template = [ "snap" ];
+      recursive = true;
     };
-    "${hostName}/backup/mermet/var/mail" = {
-      use_template = [ "remote" ];
-      hourly = 12;
-      daily = 7;
-      monthly = 1;
-    };
-    "${hostName}/backup/mermet/var/public-inbox" = {
-      use_template = [ "remote" ];
-      daily = 7;
+    "${hostName}/backup/mermet" = {
+      use_template = [ "prune" ];
+      recursive = true;
+      process_children_only = true;
     };
     "${hostName}/backup/mermet/var/redis" = {
-      use_template = [ "remote" ];
-      hourly = 1;
-      daily = 7;
+      use_template = [ "prune" ];
       monthly = 0;
+      daily = 1;
+      hourly = 1;
     };
-    "${hostName}/backup/mermet/var/www" = {
-      use_template = [ "remote" ];
-      daily = 7;
-    };
-    "${hostName}/backup/mermet/home/julm/mail" = {
-      use_template = [ "remote" ];
-      hourly = 12;
-      daily = 7;
-    };
-    "${hostName}/backup/mermet/home/julm/log" = {
-      use_template = [ "remote" ];
+    "${hostName}/backup/mermet/var/mail" = {
+      use_template = [ "prune" ];
+      monthly = 0;
+      daily = 31;
       hourly = 12;
-      daily = 7;
-      monthly = 1;
     };
   };
 };
diff --git a/nixpkgs/patches.nix b/nixpkgs/patches.nix
index f7b3e23..b71a553 100644
--- a/nixpkgs/patches.nix
+++ b/nixpkgs/patches.nix
@@ -4,6 +4,11 @@
   url = "https://github.com/NixOS/nixpkgs/pull/83904.diff";
   sha256 = "sha256-lDY3kIsvaWkGdoApwQo8CPSHh3Gn5h8SPWNdteq+dJs=";
 }
+{
+  meta.description = "nixos/sanoid: fix submodule aliases";
+  url = "https://github.com/NixOS/nixpkgs/pull/130288.diff";
+  sha256 = "sha256-Ivqpf++6OdRng33xCbh4xCQ090g9QunEf4Jsf5TEWiQ=";
+}
 /*
 {
   meta.description = "nixos/postfix: systemd sandbox";
-- 
2.47.0