@@ -11,6 +11,8 @@ let
1111
1212 mainCf =
1313 ''
14+ compatibility_level = 2
15+
1416 queue_directory = /var/postfix/queue
1517 command_directory = ${pkgs.postfix}/sbin
1618 daemon_directory = ${pkgs.postfix}/libexec/postfix
@@ -31,10 +33,7 @@ let
3133 mynetworks_style = ${cfg.networksStyle}
3234 ''
3335 else
34− # Postfix default is subnet, but let's play safe
35− ''
36− mynetworks_style = host
37− '')
36+ "")
3837 + optionalString (cfg.hostname != "") ''
3938 myhostname = ${cfg.hostname}
4039 ''
@@ -89,7 +88,7 @@ let
8988 masterCf = ''
9089 # ==========================================================================
9190 # service type private unpriv chroot wakeup maxproc command + args
92− # (yes) (yes) (yes) (never) (100)
91+ # (yes) (yes) (no) (never) (100)
9392 # ==========================================================================
9493 smtp inet n - n - - smtpd
9594 #submission inet n - n - - smtpd
@@ -232,8 +231,7 @@ in
232231 default = null;
233232 example = ["localdomain"];
234233 description = "
235− List of domains we agree to relay to. Default is the same as
236− destination.
234+ List of domains we agree to relay to. Default is empty.
237235 ";
238236 };
239237
@@ -357,23 +355,20 @@ in
357355 }
358356 ];
359357
360− jobs.postfix =
361− # I copy _lots_ of shipped configuration filed
362− # that can be left as is. I am afraid the exact
363− # will list slightly change in next Postfix
364− # release, so listing them all one-by-one in an
365− # accurate way is unlikely to be better.
358+ systemd.services.postfix =
366359 { description = "Postfix mail server";
367360
368361 wantedBy = [ "multi-user.target" ];
369362 after = [ "network.target" ];
370363
371− daemonType = "fork";
364+ serviceConfig = {
365+ Type = "forking";
366+ Restart = "always";
367+ PIDFile = "/var/postfix/queue/pid/master.pid";
368+ };
372369
373370 preStart = ''
374− if ! [ -d /var/spool/postfix ]; then
375− ${pkgs.coreutils}/bin/mkdir -p /var/spool/mail /var/postfix/conf /var/postfix/queue
376− fi
371+ ${pkgs.coreutils}/bin/mkdir -p /var/spool/mail /var/postfix/conf /var/postfix/queue
377372
378373 ${pkgs.coreutils}/bin/chown -R ${user}:${group} /var/postfix
379374 ${pkgs.coreutils}/bin/chown -R ${user}:${setgidGroup} /var/postfix/queue
@@ -382,7 +377,7 @@ in
382377 ${pkgs.coreutils}/bin/chmod a+rwxt /var/spool/mail
383378 ${pkgs.coreutils}/bin/ln -sf /var/spool/mail /var/
384379
385− ln -sf "${pkgs.postfix}/etc/postfix/"* /var/postfix/conf
380+ ln -sf ${pkgs.postfix}/etc/postfix/postfix-files /var/postfix/conf
386381
387382 ln -sf ${aliasesFile} /var/postfix/conf/aliases
388383 ln -sf ${virtualFile} /var/postfix/conf/virtual
@@ -391,12 +386,18 @@ in
391386
392387 ${pkgs.postfix}/sbin/postalias -c /var/postfix/conf /var/postfix/conf/aliases
393388 ${pkgs.postfix}/sbin/postmap -c /var/postfix/conf /var/postfix/conf/virtual
389+ '';
394390
391+ script = ''
395392 ${pkgs.postfix}/sbin/postfix -c /var/postfix/conf start
396393 '';
397394
395+ reload = ''
396+ ${pkgs.postfix}/sbin/postfix -c /var/postfix/conf reload
397+ '';
398+
398399 preStop = ''
399− ${pkgs.postfix}/sbin/postfix -c /var/postfix/conf stop
400+ ${pkgs.postfix}/sbin/postfix -c /var/postfix/conf stop
400401 '';
401402
402403 };