dovecot: fix check for dovecot systemd unit name

and migrate the preStart script in systemd.nix as well.
This commit is contained in:
Martin Weinelt 2025-07-06 04:53:38 +02:00
parent a40574beb5
commit f9a52ca4b5
No known key found for this signature in database
GPG key ID: 87C1E9888F856759
2 changed files with 32 additions and 26 deletions

View file

@ -16,7 +16,6 @@
{
config,
options,
pkgs,
lib,
...
@ -27,7 +26,11 @@ with (import ./common.nix { inherit config pkgs lib; });
let
cfg = config.mailserver;
dovecotUnitName = if lib.hasAttr "dovecot" options.systemd.services then "dovecot" else "dovecot2";
dovecotPreStart =
''
${genPasswdScript}
''
+ (lib.optionalString cfg.ldap.enable setPwdInLdapConfFile);
passwdDir = "/run/dovecot2";
passwdFile = "${passwdDir}/passwd";
@ -442,11 +445,10 @@ in
'';
};
systemd.services.${dovecotUnitName}.preStart =
''
${genPasswdScript}
''
+ (lib.optionalString cfg.ldap.enable setPwdInLdapConfFile);
systemd.services.dovecot.preStart = lib.mkIf (config.systemd.services ? "dovecot") dovecotPreStart;
systemd.services.dovecot2.preStart = lib.mkIf (
config.systemd.services ? "dovecot2"
) dovecotPreStart;
systemd.services.postfix.restartTriggers = [
genPasswdScript