From 4531deeed8529305f327ea6bf6c06fa417331586 Mon Sep 17 00:00:00 2001 From: Thomas J Date: Sun, 25 May 2025 18:58:12 +0200 Subject: [PATCH] nixos/borgmatic: do not create source directories for empty databases (#410752) --- nixos/modules/services/backup/borgmatic.nix | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/nixos/modules/services/backup/borgmatic.nix b/nixos/modules/services/backup/borgmatic.nix index f2f35f97d0dd..75dbf5fe1c77 100644 --- a/nixos/modules/services/backup/borgmatic.nix +++ b/nixos/modules/services/backup/borgmatic.nix @@ -17,7 +17,7 @@ let addRequiredBinaries = s: s - // { + // (lib.optionalAttrs (s ? postgresql_databases && s.postgresql_databases != [ ]) { postgresql_databases = map ( d: let @@ -33,7 +33,9 @@ let psql_command = "${as_user}${postgresql}/bin/psql"; } // d - ) (s.postgresql_databases or [ ]); + ) s.postgresql_databases; + }) + // (lib.optionalAttrs (s ? mariadb_databases && s.mariadb_databases != [ ]) { mariadb_databases = map ( d: { @@ -41,7 +43,9 @@ let mariadb_command = "${mysql}/bin/mariadb"; } // d - ) (s.mariadb_databases or [ ]); + ) s.mariadb_databases; + }) + // (lib.optionalAttrs (s ? mysql_databases && s.mysql_databases != [ ]) { mysql_databases = map ( d: { @@ -49,8 +53,8 @@ let mysql_command = "${mysql}/bin/mysql"; } // d - ) (s.mysql_databases or [ ]); - }; + ) s.mysql_databases; + }); repository = with lib.types; @@ -149,7 +153,9 @@ in config = let configFiles = - (lib.optionalAttrs (cfg.settings != null) { "borgmatic/config.yaml".source = cfgfile; }) + (lib.optionalAttrs (cfg.settings != null) { + "borgmatic/config.yaml".source = cfgfile; + }) // lib.mapAttrs' ( name: value: lib.nameValuePair "borgmatic.d/${name}.yaml" {