summary refs log tree commit diff
path: root/nixos/modules/services/mail/postfix.nix
diff options
context:
space:
mode:
authorPeter Simons <simons@cryp.to>2015-11-08 18:10:26 +0100
committerPeter Simons <simons@cryp.to>2015-11-08 18:10:26 +0100
commitadb74ad2f935e2ec66b799d6a001825fc6736c85 (patch)
tree60fbb95a557056f75f1ece45840a22cf6624f13e /nixos/modules/services/mail/postfix.nix
parent6687047a049a5c5d6dc2dc895e42d1af4fce9674 (diff)
parent929e734f19f6b3a4ff89fe87e0ff424bd70bb7c9 (diff)
downloadnixpkgs-adb74ad2f935e2ec66b799d6a001825fc6736c85.tar
nixpkgs-adb74ad2f935e2ec66b799d6a001825fc6736c85.tar.gz
nixpkgs-adb74ad2f935e2ec66b799d6a001825fc6736c85.tar.bz2
nixpkgs-adb74ad2f935e2ec66b799d6a001825fc6736c85.tar.lz
nixpkgs-adb74ad2f935e2ec66b799d6a001825fc6736c85.tar.xz
nixpkgs-adb74ad2f935e2ec66b799d6a001825fc6736c85.tar.zst
nixpkgs-adb74ad2f935e2ec66b799d6a001825fc6736c85.zip
Merge pull request #10620 from gebner/postfix-3.0.3
postfix: 2.11.5 -> 3.0.3
Diffstat (limited to 'nixos/modules/services/mail/postfix.nix')
-rw-r--r--nixos/modules/services/mail/postfix.nix39
1 files changed, 20 insertions, 19 deletions
diff --git a/nixos/modules/services/mail/postfix.nix b/nixos/modules/services/mail/postfix.nix
index d1aaebdfdf2..3a9e62a0205 100644
--- a/nixos/modules/services/mail/postfix.nix
+++ b/nixos/modules/services/mail/postfix.nix
@@ -11,6 +11,8 @@ let
 
   mainCf =
     ''
+      compatibility_level = 2
+
       queue_directory = /var/postfix/queue
       command_directory = ${pkgs.postfix}/sbin
       daemon_directory = ${pkgs.postfix}/libexec/postfix
@@ -31,10 +33,7 @@ let
           mynetworks_style = ${cfg.networksStyle}
         ''
       else
-        # Postfix default is subnet, but let's play safe
-        ''
-          mynetworks_style = host
-        '')
+        "")
     + optionalString (cfg.hostname != "") ''
       myhostname = ${cfg.hostname}
     ''
@@ -89,7 +88,7 @@ let
   masterCf = ''
     # ==========================================================================
     # service type  private unpriv  chroot  wakeup  maxproc command + args
-    #               (yes)   (yes)   (yes)   (never) (100)
+    #               (yes)   (yes)   (no)    (never) (100)
     # ==========================================================================
     smtp      inet  n       -       n       -       -       smtpd
     #submission inet n       -       n       -       -       smtpd
@@ -232,8 +231,7 @@ in
         default = null;
         example = ["localdomain"];
         description = "
-          List of domains we agree to relay to. Default is the same as
-          destination.
+          List of domains we agree to relay to. Default is empty.
         ";
       };
 
@@ -357,23 +355,20 @@ in
         }
       ];
 
-    jobs.postfix =
-      # I copy _lots_ of shipped configuration filed
-      # that can be left as is. I am afraid the exact
-      # will list slightly change in next Postfix
-      # release, so listing them all one-by-one in an
-      # accurate way is unlikely to be better.
+    systemd.services.postfix =
       { description = "Postfix mail server";
 
         wantedBy = [ "multi-user.target" ];
         after = [ "network.target" ];
 
-        daemonType = "fork";
+        serviceConfig = {
+          Type = "forking";
+          Restart = "always";
+          PIDFile = "/var/postfix/queue/pid/master.pid";
+        };
 
         preStart = ''
-          if ! [ -d /var/spool/postfix ]; then
-            ${pkgs.coreutils}/bin/mkdir -p /var/spool/mail /var/postfix/conf /var/postfix/queue
-          fi
+          ${pkgs.coreutils}/bin/mkdir -p /var/spool/mail /var/postfix/conf /var/postfix/queue
 
           ${pkgs.coreutils}/bin/chown -R ${user}:${group} /var/postfix
           ${pkgs.coreutils}/bin/chown -R ${user}:${setgidGroup} /var/postfix/queue
@@ -382,7 +377,7 @@ in
           ${pkgs.coreutils}/bin/chmod a+rwxt /var/spool/mail
           ${pkgs.coreutils}/bin/ln -sf /var/spool/mail /var/
 
-          ln -sf "${pkgs.postfix}/etc/postfix/"* /var/postfix/conf
+          ln -sf ${pkgs.postfix}/etc/postfix/postfix-files /var/postfix/conf
 
           ln -sf ${aliasesFile} /var/postfix/conf/aliases
           ln -sf ${virtualFile} /var/postfix/conf/virtual
@@ -391,12 +386,18 @@ in
 
           ${pkgs.postfix}/sbin/postalias -c /var/postfix/conf /var/postfix/conf/aliases
           ${pkgs.postfix}/sbin/postmap -c /var/postfix/conf /var/postfix/conf/virtual
+        '';
 
+        script = ''
           ${pkgs.postfix}/sbin/postfix -c /var/postfix/conf start
         '';
 
+        reload = ''
+          ${pkgs.postfix}/sbin/postfix -c /var/postfix/conf reload
+        '';
+
         preStop = ''
-            ${pkgs.postfix}/sbin/postfix -c /var/postfix/conf stop
+          ${pkgs.postfix}/sbin/postfix -c /var/postfix/conf stop
         '';
 
       };