From b38dc8085c4ac2362853a696e1163e10e50189d1 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sun, 6 Jul 2025 02:25:21 +0200 Subject: [PATCH] dovecot: add compat shim for dovecot unit name migration In nixpkgs I renamed dovecot2 to dovecot and made dovecot2 an alias, so adding the script to the alias does us no good. --- mail-server/dovecot.nix | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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