nixos/bacula: fix postgresql config and remove unneeded quotation marks

The module falsely disabled postgresql completely when the bacula-sd was not enabled.
Quotation marks are not necessary and only useful in `name` fields.
This commit is contained in:
Rouven Seifert 2023-07-29 19:28:27 +02:00
parent 6a1255d2d0
commit b12923631d
No known key found for this signature in database
GPG key ID: B95E8FE6B11C4D09

View file

@ -15,16 +15,16 @@ let
Client { Client {
Name = "${fd_cfg.name}"; Name = "${fd_cfg.name}";
FDPort = ${toString fd_cfg.port}; FDPort = ${toString fd_cfg.port};
WorkingDirectory = "${libDir}"; WorkingDirectory = ${libDir};
Pid Directory = "/run"; Pid Directory = /run;
${fd_cfg.extraClientConfig} ${fd_cfg.extraClientConfig}
} }
${concatStringsSep "\n" (mapAttrsToList (name: value: '' ${concatStringsSep "\n" (mapAttrsToList (name: value: ''
Director { Director {
Name = "${name}"; Name = "${name}";
Password = "${value.password}"; Password = ${value.password};
Monitor = "${value.monitor}"; Monitor = ${value.monitor};
} }
'') fd_cfg.director)} '') fd_cfg.director)}
@ -41,8 +41,8 @@ let
Storage { Storage {
Name = "${sd_cfg.name}"; Name = "${sd_cfg.name}";
SDPort = ${toString sd_cfg.port}; SDPort = ${toString sd_cfg.port};
WorkingDirectory = "${libDir}"; WorkingDirectory = ${libDir};
Pid Directory = "/run"; Pid Directory = /run;
${sd_cfg.extraStorageConfig} ${sd_cfg.extraStorageConfig}
} }
@ -50,8 +50,8 @@ let
Autochanger { Autochanger {
Name = "${name}"; Name = "${name}";
Device = ${concatStringsSep ", " (map (a: "\"${a}\"") value.devices)}; Device = ${concatStringsSep ", " (map (a: "\"${a}\"") value.devices)};
Changer Device = "${value.changerDevice}"; Changer Device = ${value.changerDevice};
Changer Command = "${value.changerCommand}"; Changer Command = ${value.changerCommand};
${value.extraAutochangerConfig} ${value.extraAutochangerConfig}
} }
'') sd_cfg.autochanger)} '') sd_cfg.autochanger)}
@ -59,8 +59,8 @@ let
${concatStringsSep "\n" (mapAttrsToList (name: value: '' ${concatStringsSep "\n" (mapAttrsToList (name: value: ''
Device { Device {
Name = "${name}"; Name = "${name}";
Archive Device = "${value.archiveDevice}"; Archive Device = ${value.archiveDevice};
Media Type = "${value.mediaType}"; Media Type = ${value.mediaType};
${value.extraDeviceConfig} ${value.extraDeviceConfig}
} }
'') sd_cfg.device)} '') sd_cfg.device)}
@ -68,8 +68,8 @@ let
${concatStringsSep "\n" (mapAttrsToList (name: value: '' ${concatStringsSep "\n" (mapAttrsToList (name: value: ''
Director { Director {
Name = "${name}"; Name = "${name}";
Password = "${value.password}"; Password = ${value.password};
Monitor = "${value.monitor}"; Monitor = ${value.monitor};
} }
'') sd_cfg.director)} '') sd_cfg.director)}
@ -85,18 +85,18 @@ let
'' ''
Director { Director {
Name = "${dir_cfg.name}"; Name = "${dir_cfg.name}";
Password = "${dir_cfg.password}"; Password = ${dir_cfg.password};
DirPort = ${toString dir_cfg.port}; DirPort = ${toString dir_cfg.port};
Working Directory = "${libDir}"; Working Directory = ${libDir};
Pid Directory = "/run/"; Pid Directory = /run/;
QueryFile = "${pkgs.bacula}/etc/query.sql"; QueryFile = ${pkgs.bacula}/etc/query.sql;
${dir_cfg.extraDirectorConfig} ${dir_cfg.extraDirectorConfig}
} }
Catalog { Catalog {
Name = "PostgreSQL"; Name = PostgreSQL;
dbname = "bacula"; dbname = bacula;
user = "bacula"; user = bacula;
} }
Messages { Messages {
@ -533,7 +533,7 @@ in {
}; };
}; };
services.postgresql.enable = dir_cfg.enable == true; services.postgresql.enable = lib.mkIf dir_cfg.enable true;
systemd.services.bacula-dir = mkIf dir_cfg.enable { systemd.services.bacula-dir = mkIf dir_cfg.enable {
after = [ "network.target" "postgresql.service" ]; after = [ "network.target" "postgresql.service" ];