diff --git a/mail-server/dovecot.nix b/mail-server/dovecot.nix index cdd46e7..757dba0 100644 --- a/mail-server/dovecot.nix +++ b/mail-server/dovecot.nix @@ -16,6 +16,7 @@ { config, + options, pkgs, lib, ... @@ -26,6 +27,8 @@ with (import ./common.nix { inherit config pkgs lib; }); let cfg = config.mailserver; + dovecotUnitName = if lib.hasAttr "dovecot" options.systemd.services then "dovecot" else "dovecot2"; + passwdDir = "/run/dovecot2"; passwdFile = "${passwdDir}/passwd"; userdbFile = "${passwdDir}/userdb"; @@ -439,13 +442,11 @@ in ''; }; - systemd.services.dovecot2 = { - preStart = - '' - ${genPasswdScript} - '' - + (lib.optionalString cfg.ldap.enable setPwdInLdapConfFile); - }; + systemd.services.${dovecotUnitName}.preStart = + '' + ${genPasswdScript} + '' + + (lib.optionalString cfg.ldap.enable setPwdInLdapConfFile); systemd.services.postfix.restartTriggers = [ genPasswdScript