nixos/roundcube: only configure postgres config if localhost is used as database

When using a different database, the evaluation fails as
`config.services.postgresql.package` is only set if `services.postgresql` is enabled.

Also, the systemd service shouldn't have a relation to postgres if a
remote database is used.
This commit is contained in:
Maximilian Bosch 2019-04-02 16:02:53 +02:00
parent 92e5745383
commit 6b6348eaba
No known key found for this signature in database
GPG Key ID: 091DBF4D1FC46B8E
1 changed files with 24 additions and 20 deletions

View File

@ -141,11 +141,14 @@ in
systemd.services.roundcube-setup = let
pgSuperUser = config.services.postgresql.superUser;
in {
in mkMerge [
(mkIf (cfg.database.host == "localhost") {
requires = [ "postgresql.service" ];
after = [ "postgresql.service" ];
wantedBy = [ "multi-user.target" ];
path = [ config.services.postgresql.package ];
})
{
wantedBy = [ "multi-user.target" ];
script = ''
mkdir -p /var/lib/roundcube
if [ ! -f /var/lib/roundcube/db-created ]; then
@ -162,6 +165,7 @@ in
${pkgs.php}/bin/php ${cfg.package}/bin/update.sh
'';
serviceConfig.Type = "oneshot";
};
}
];
};
}