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 1/3] 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 4ebecbfdd..b838dc71d 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 5c466cc17..6dd30e441 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 06358e6f9..90a2b086f 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)); From 349d3b379c2914e4d0372048669b137a3d2d1bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 12 Mar 2024 13:06:12 +0100 Subject: [PATCH 2/3] update flake --- flake.lock | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/flake.lock b/flake.lock index 30440e795..1c25ea822 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1709632354, - "narHash": "sha256-jxRHwqrtNze51WKFKvxlQ8Inf62UNRl5cFqEQ2V96vE=", + "lastModified": 1710169806, + "narHash": "sha256-HeWFrRuHpnAiPmIr26OKl2g142HuGerwoO/XtW53pcI=", "owner": "nix-community", "repo": "disko", - "rev": "0d11aa8d6431326e10b8656420f91085c3bd0b12", + "rev": "fe064a639319ed61cdf12b8f6eded9523abcc498", "type": "github" }, "original": { @@ -27,11 +27,11 @@ ] }, "locked": { - "lastModified": 1706830856, - "narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=", + "lastModified": 1709336216, + "narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f", + "rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2", "type": "github" }, "original": { @@ -42,11 +42,11 @@ }, "nixlib": { "locked": { - "lastModified": 1708217146, - "narHash": "sha256-nGfEv7k78slqIR5E0zzWSx214d/4/ZPKDkObLJqVLVw=", + "lastModified": 1709426687, + "narHash": "sha256-jLBZmwXf0WYHzLkmEMq33bqhX55YtT5edvluFr0RcSA=", "owner": "nix-community", "repo": "nixpkgs.lib", - "rev": "e623008d8a46517470e6365505f1a3ce171fa46a", + "rev": "7873d84a89ae6e4841528ff7f5697ddcb5bdfe6c", "type": "github" }, "original": { @@ -63,11 +63,11 @@ ] }, "locked": { - "lastModified": 1708563055, - "narHash": "sha256-FaojUZNu+YPFi3eCI7mL4kxPKQ51DoySa7mqmllUOuc=", + "lastModified": 1710164763, + "narHash": "sha256-6p7yebSjzrL8qK4Q0gx2RnsxaudGUQcgkSxFG/J265Y=", "owner": "nix-community", "repo": "nixos-generators", - "rev": "f4631dee1a0fd56c0db89860e83e3588a28c7631", + "rev": "1d9c8cd24eba7942955f92fdcefba5a6a7543bc6", "type": "github" }, "original": { @@ -78,11 +78,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1709764733, - "narHash": "sha256-GptBnEUy8IcRrnd8X5WBJPDXG7M4bjj8OG4Wjg8dCDs=", + "lastModified": 1710213926, + "narHash": "sha256-D6wdwb289veivPoRV5/+IZaUG/XrdJPHpbR08cA5og0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "edf9f14255a7ac20f8da7b70609e980a964fca7a", + "rev": "e4e2121b151e492fd15d4bdb034e793738fdc120", "type": "github" }, "original": { @@ -110,11 +110,11 @@ "nixpkgs-stable": [] }, "locked": { - "lastModified": 1708830076, - "narHash": "sha256-Cjh2xdjxC6S6nW6Whr2dxSeh8vjodzhTmQdI4zPJ4RA=", + "lastModified": 1710195194, + "narHash": "sha256-KFxCJp0T6TJOz1IOKlpRdpsCr9xsvlVuWY/VCiAFnTE=", "owner": "Mic92", "repo": "sops-nix", - "rev": "2874fbbe4a65bd2484b0ad757d27a16107f6bc17", + "rev": "e52d8117b330f690382f1d16d81ae43daeb4b880", "type": "github" }, "original": { @@ -130,11 +130,11 @@ ] }, "locked": { - "lastModified": 1708897213, - "narHash": "sha256-QECZB+Hgz/2F/8lWvHNk05N6NU/rD9bWzuNn6Cv8oUk=", + "lastModified": 1710088047, + "narHash": "sha256-eSqKs6ZCsX9xJyNYLeMDMrxzIDsYtaWClfZCOp0ok6Y=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "e497a9ddecff769c2a7cbab51e1ed7a8501e7a3a", + "rev": "720322c5352d7b7bd2cb3601a9176b0e91d1de7d", "type": "github" }, "original": { From 823b5e67ed00be50b6f017ba9e2150acb766c85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 12 Mar 2024 13:17:04 +0100 Subject: [PATCH 3/3] fix backup not beeing activated --- clanModules/borgbackup.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clanModules/borgbackup.nix b/clanModules/borgbackup.nix index 90a2b086f..d7ded0902 100644 --- a/clanModules/borgbackup.nix +++ b/clanModules/borgbackup.nix @@ -31,7 +31,7 @@ in imports = [ (lib.mkRemovedOptionModule [ "clan" "borgbackup" "enable" ] "Just define clan.borgbackup.destinations to enable it") ]; - config = lib.mkIf (cfg.destinations != [ ]) { + config = lib.mkIf (cfg.destinations != { }) { services.borgbackup.jobs = lib.mapAttrs (_: dest: { paths = lib.flatten (map (state: state.folders) (lib.attrValues config.clanCore.state));