From ef050a50a08207c85f9b1a4e5c421409fa824806 Mon Sep 17 00:00:00 2001 From: asonix Date: Sun, 14 May 2023 11:34:10 -0500 Subject: [PATCH] Fix enableBackups flag --- flake.nix | 3 +- modules/btrbk/default.nix | 68 +++++++++++++++++++-------------------- 2 files changed, 35 insertions(+), 36 deletions(-) diff --git a/flake.nix b/flake.nix index f328b17..b8fafbd 100644 --- a/flake.nix +++ b/flake.nix @@ -440,6 +440,7 @@ , selfIp , unlockMounts ? true , mountVolumes ? true + , enableBackups ? true , backupHosts ? [ ] }: let @@ -455,7 +456,7 @@ (btrbkModule { instances = backupHosts; localMountDir = mountDir; - enabled = unlockMounts && mountVolumes; + enabled = unlockMounts && mountVolumes && enableBackups; }) ({ config, lib, pkgs, ... }: let diff --git a/modules/btrbk/default.nix b/modules/btrbk/default.nix index 58ff936..e767021 100644 --- a/modules/btrbk/default.nix +++ b/modules/btrbk/default.nix @@ -96,40 +96,38 @@ in else [ ]); - services.btrbk = - if enabled then { - sshAccess = [{ - key = - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHTqU3EvTgY5/e9m6YyQWypQPK58t9iPmPnPYAvnODGB asonix@lionheart"; - roles = [ "source" "info" "send" ]; - }]; - extraPackages = with pkgs; [ gzip ]; - instances = - if localMountDir == null then - (builtins.foldl' - (acc: - { primaryIp ? null, mountDir, subvolumes, name ? "btrbk" }: - let - selected = - if primaryIp == null then - (primary mountDir subvolumes) - else - (secondary primaryIp mountDir subvolumes); - in - acc // { - ${name} = { - onCalendar = "hourly"; - settings = selected; - }; - }) - { } - instances) - else { - btrbk = { - onCalendar = "hourly"; - settings = (backup instances); - }; + services.btrbk = { + sshAccess = [{ + key = + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHTqU3EvTgY5/e9m6YyQWypQPK58t9iPmPnPYAvnODGB asonix@lionheart"; + roles = [ "source" "info" "send" ]; + }]; + extraPackages = with pkgs; [ gzip ]; + instances = + if localMountDir == null then + (builtins.foldl' + (acc: + { primaryIp ? null, mountDir, subvolumes, name ? "btrbk" }: + let + selected = + if primaryIp == null then + (primary mountDir subvolumes) + else + (secondary primaryIp mountDir subvolumes); + in + acc // { + ${name} = { + onCalendar = "hourly"; + settings = selected; + }; + }) + { } + instances) + else if enabled then { + btrbk = { + onCalendar = "hourly"; + settings = (backup instances); }; - } else - { }; + } else { }; + }; }