From fb2fa1b50fe32e4d4f4e251b5892598f38f40a71 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 5 Apr 2022 10:03:25 +0000 Subject: nixos/postfix: pull setup into its own unit Consider a service that generates postfix lookup tables with postmap(1), like Mailman. It needs the Postfix configuration file to exist, but Postfix qmgr needs all the lookup tables its configured with to exist before it starts. So the service that runs postmap needs to run after the Postfix configuration and directory structure is generated, but before Postfix itself is started. To enable this, we split Postfix into two units: a oneshot unit that sets up the configuration, and a longrun unit that supervises the Postfix daemons. The postmap services can then be inserted in between these two units. --- nixos/modules/services/mail/mailman.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'nixos/modules/services/mail/mailman.nix') diff --git a/nixos/modules/services/mail/mailman.nix b/nixos/modules/services/mail/mailman.nix index 0c9b38b44b2..f36abadf9d7 100644 --- a/nixos/modules/services/mail/mailman.nix +++ b/nixos/modules/services/mail/mailman.nix @@ -313,7 +313,8 @@ in { systemd.services = { mailman = { description = "GNU Mailman Master Process"; - after = [ "network.target" ]; + after = [ "network.target" ] + ++ lib.optional cfg.enablePostfix "postfix-setup.service"; restartTriggers = [ config.environment.etc."mailman.cfg".source ]; wantedBy = [ "multi-user.target" ]; serviceConfig = { -- cgit 1.4.1 From 572131c6a945069dba5a12a0354df8254224a458 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 5 Apr 2022 10:10:51 +0000 Subject: nixos/mailman: ensure Postfix is started after Mailman On first run, Postfix will refuse to start if it's started before Mailman is up, because it'll try to read the map files generated Mailman the first time it's started, and they won't exist yet. To fix this, make sure Postfix isn't started until after Mailman is up if they're both activated at the same time. --- nixos/modules/services/mail/mailman.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'nixos/modules/services/mail/mailman.nix') diff --git a/nixos/modules/services/mail/mailman.nix b/nixos/modules/services/mail/mailman.nix index f36abadf9d7..eee413df56d 100644 --- a/nixos/modules/services/mail/mailman.nix +++ b/nixos/modules/services/mail/mailman.nix @@ -313,6 +313,7 @@ in { systemd.services = { mailman = { description = "GNU Mailman Master Process"; + before = lib.optional cfg.enablePostfix "postfix.service"; after = [ "network.target" ] ++ lib.optional cfg.enablePostfix "postfix-setup.service"; restartTriggers = [ config.environment.etc."mailman.cfg".source ]; -- cgit 1.4.1