nixos/borgmatic: do not create source directories for empty databases (#410752)

authored by Thomas J and committed by GitHub 4531deee 7517a0b3

+12 -6
+12 -6
nixos/modules/services/backup/borgmatic.nix
··· 17 17 addRequiredBinaries = 18 18 s: 19 19 s 20 - // { 20 + // (lib.optionalAttrs (s ? postgresql_databases && s.postgresql_databases != [ ]) { 21 21 postgresql_databases = map ( 22 22 d: 23 23 let ··· 33 33 psql_command = "${as_user}${postgresql}/bin/psql"; 34 34 } 35 35 // d 36 - ) (s.postgresql_databases or [ ]); 36 + ) s.postgresql_databases; 37 + }) 38 + // (lib.optionalAttrs (s ? mariadb_databases && s.mariadb_databases != [ ]) { 37 39 mariadb_databases = map ( 38 40 d: 39 41 { ··· 41 43 mariadb_command = "${mysql}/bin/mariadb"; 42 44 } 43 45 // d 44 - ) (s.mariadb_databases or [ ]); 46 + ) s.mariadb_databases; 47 + }) 48 + // (lib.optionalAttrs (s ? mysql_databases && s.mysql_databases != [ ]) { 45 49 mysql_databases = map ( 46 50 d: 47 51 { ··· 49 53 mysql_command = "${mysql}/bin/mysql"; 50 54 } 51 55 // d 52 - ) (s.mysql_databases or [ ]); 53 - }; 56 + ) s.mysql_databases; 57 + }); 54 58 55 59 repository = 56 60 with lib.types; ··· 149 153 config = 150 154 let 151 155 configFiles = 152 - (lib.optionalAttrs (cfg.settings != null) { "borgmatic/config.yaml".source = cfgfile; }) 156 + (lib.optionalAttrs (cfg.settings != null) { 157 + "borgmatic/config.yaml".source = cfgfile; 158 + }) 153 159 // lib.mapAttrs' ( 154 160 name: value: 155 161 lib.nameValuePair "borgmatic.d/${name}.yaml" {