From b1897530c83eb49c0af395329cf9c1d4d417770b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 8 Mar 2024 11:12:34 +0100 Subject: [PATCH] clan.borgbackup: drop enable option --- checks/backups/flake-module.nix | 5 +--- checks/borgbackup/default.nix | 5 +--- clanModules/borgbackup.nix | 53 +++++++++++++++++---------------- 3 files changed, 29 insertions(+), 34 deletions(-) diff --git a/checks/backups/flake-module.nix b/checks/backups/flake-module.nix index 4ebecbfd..b838dc71 100644 --- a/checks/backups/flake-module.nix +++ b/checks/backups/flake-module.nix @@ -75,10 +75,7 @@ in }; system.extraDependencies = dependencies; clanCore.state.test-backups.folders = [ "/var/test-backups" ]; - clan.borgbackup = { - enable = true; - destinations.test_backup_server.repo = "borg@server:."; - }; + clan.borgbackup.destinations.test_backup_server.repo = "borg@server:."; }; }; perSystem = { nodes, pkgs, ... }: { diff --git a/checks/borgbackup/default.nix b/checks/borgbackup/default.nix index 5c466cc1..6dd30e44 100644 --- a/checks/borgbackup/default.nix +++ b/checks/borgbackup/default.nix @@ -36,10 +36,7 @@ }; clanCore.secretStore = "vm"; - clan.borgbackup = { - enable = true; - destinations.test.repo = "borg@localhost:."; - }; + clan.borgbackup.destinations.test.repo = "borg@localhost:."; } ]; }; diff --git a/clanModules/borgbackup.nix b/clanModules/borgbackup.nix index 06358e6f..90a2b086 100644 --- a/clanModules/borgbackup.nix +++ b/clanModules/borgbackup.nix @@ -3,34 +3,35 @@ let cfg = config.clan.borgbackup; in { - options.clan.borgbackup = { - enable = lib.mkEnableOption "backups with borgbackup"; - destinations = lib.mkOption { - type = lib.types.attrsOf (lib.types.submodule ({ name, ... }: { - options = { - name = lib.mkOption { - type = lib.types.str; - default = name; - description = "the name of the backup job"; - }; - repo = lib.mkOption { - type = lib.types.str; - description = "the borgbackup repository to backup to"; - }; - rsh = lib.mkOption { - type = lib.types.str; - default = "ssh -i ${config.clanCore.secrets.borgbackup.secrets."borgbackup.ssh".path} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"; - description = "the rsh to use for the backup"; - }; - + options.clan.borgbackup.destinations = lib.mkOption { + type = lib.types.attrsOf (lib.types.submodule ({ name, ... }: { + options = { + name = lib.mkOption { + type = lib.types.str; + default = name; + description = "the name of the backup job"; }; - })); - description = '' - destinations where the machine should be backuped to - ''; - }; + repo = lib.mkOption { + type = lib.types.str; + description = "the borgbackup repository to backup to"; + }; + rsh = lib.mkOption { + type = lib.types.str; + default = "ssh -i ${config.clanCore.secrets.borgbackup.secrets."borgbackup.ssh".path} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"; + description = "the rsh to use for the backup"; + }; + + }; + })); + default = { }; + description = '' + destinations where the machine should be backuped to + ''; }; - config = lib.mkIf cfg.enable { + + imports = [ (lib.mkRemovedOptionModule [ "clan" "borgbackup" "enable" ] "Just define clan.borgbackup.destinations to enable it") ]; + + config = lib.mkIf (cfg.destinations != [ ]) { services.borgbackup.jobs = lib.mapAttrs (_: dest: { paths = lib.flatten (map (state: state.folders) (lib.attrValues config.clanCore.state));