From 2e8b3fb166db9c06a85d8e0becfbf7d8c15c22bc Mon Sep 17 00:00:00 2001
From: ibizaman <ibizapeanut@gmail.com>
Date: Fri, 23 Aug 2024 22:45:02 +0200
Subject: [PATCH] remove group and retention from backup contract

Group is not strictly needed.
Retention is an implementation detail of the service backing up, not part of the contract.
---
 modules/blocks/restic.nix    | 18 +-----------------
 modules/contracts/backup.nix | 19 -------------------
 2 files changed, 1 insertion(+), 36 deletions(-)

diff --git a/modules/blocks/restic.nix b/modules/blocks/restic.nix
index c8a54d7..a10da4a 100644
--- a/modules/blocks/restic.nix
+++ b/modules/blocks/restic.nix
@@ -23,16 +23,6 @@ let
       default = cfg.user;
     };
 
-    group = lib.mkOption {
-      description = ''
-        Unix group doing the backups.
-
-        For Restic, the same group must be used for all instances.
-      '';
-      type = lib.types.str;
-      default = cfg.group;
-    };
-
     sourceDirectories = lib.mkOption {
       description = "Source directories.";
       type = lib.types.nonEmptyListOf lib.types.str;
@@ -131,12 +121,6 @@ in
       default = "backup";
     };
 
-    group = lib.mkOption {
-      description = "Unix group doing the backups.";
-      type = lib.types.str;
-      default = "backup";
-    };
-
     instances = lib.mkOption {
       description = "Each instance is a backup setting";
       default = {};
@@ -209,7 +193,7 @@ in
         systemd.tmpfiles.rules =
           let
             mkRepositorySettings = name: instance: repository: lib.optionals (lib.hasPrefix "/" repository.path) [
-              "d '${repository.path}' 0750 ${instance.user} ${instance.group} - -"
+              "d '${repository.path}' 0750 ${instance.user} root - -"
             ];
 
             mkSettings = name: instance: builtins.map (mkRepositorySettings name instance) instance.repositories;
diff --git a/modules/contracts/backup.nix b/modules/contracts/backup.nix
index 0f983d4..2cb6d10 100644
--- a/modules/contracts/backup.nix
+++ b/modules/contracts/backup.nix
@@ -6,13 +6,6 @@ lib.types.submodule {
     user = lib.mkOption {
       description = "Unix user doing the backups.";
       type = lib.types.str;
-      default = "backup";
-    };
-
-    group = lib.mkOption {
-      description = "Unix group doing the backups.";
-      type = lib.types.str;
-      default = "backup";
     };
 
     sourceDirectories = lib.mkOption {
@@ -26,18 +19,6 @@ lib.types.submodule {
       default = [];
     };
 
-    retention = lib.mkOption {
-      description = "Backup files retention.";
-      type = lib.types.attrsOf (lib.types.oneOf [ lib.types.int lib.types.nonEmptyStr ]);
-      default = {
-        keep_within = "1d";
-        keep_hourly = 24;
-        keep_daily = 7;
-        keep_weekly = 4;
-        keep_monthly = 6;
-      };
-    };
-
     hooks = lib.mkOption {
       description = "Hooks to run around the backup.";
       default = {};