From 37afc5cda13abfbc2dd838e8a242efca1e4cd68a Mon Sep 17 00:00:00 2001
From: Joachim Fasting <joachifm@fastmail.fm>
Date: Mon, 24 Oct 2016 17:53:20 +0200
Subject: [PATCH 1/5] opensmtpd service: serviceConfiguration option as
 types.lines

---
 nixos/modules/services/mail/opensmtpd.nix | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/nixos/modules/services/mail/opensmtpd.nix b/nixos/modules/services/mail/opensmtpd.nix
index fb94560e10aa..2de7ef48ad10 100644
--- a/nixos/modules/services/mail/opensmtpd.nix
+++ b/nixos/modules/services/mail/opensmtpd.nix
@@ -48,12 +48,12 @@ in {
       };
 
       serverConfiguration = mkOption {
-        type = types.string;
+        type = types.lines;
         default = "";
         example = ''
           listen on lo
           accept for any deliver to lmtp localhost:24
-        ''; 
+        '';
         description = ''
           The contents of the smtpd.conf configuration file. See the
           OpenSMTPD documentation for syntax information. If this option

From 946fe73b56779210419bb93f4fcf700b1ec67a21 Mon Sep 17 00:00:00 2001
From: Joachim Fasting <joachifm@fastmail.fm>
Date: Mon, 24 Oct 2016 17:53:50 +0200
Subject: [PATCH 2/5] opensmtpd service: use explicit pkgs for consistency

---
 nixos/modules/services/mail/opensmtpd.nix | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/nixos/modules/services/mail/opensmtpd.nix b/nixos/modules/services/mail/opensmtpd.nix
index 2de7ef48ad10..c54fd1950cfb 100644
--- a/nixos/modules/services/mail/opensmtpd.nix
+++ b/nixos/modules/services/mail/opensmtpd.nix
@@ -1,17 +1,16 @@
 { config, lib, pkgs, ... }:
 
-with pkgs;
 with lib;
 
 let
 
   cfg = config.services.opensmtpd;
-  conf = writeText "smtpd.conf" cfg.serverConfiguration;
+  conf = pkgs.writeText "smtpd.conf" cfg.serverConfiguration;
   args = concatStringsSep " " cfg.extraServerArgs;
 
   sendmail = pkgs.runCommand "opensmtpd-sendmail" {} ''
     mkdir -p $out/bin
-    ln -s ${opensmtpd}/sbin/smtpctl $out/bin/sendmail
+    ln -s ${pkgs.opensmtpd}/sbin/smtpctl $out/bin/sendmail
   '';
 
 in {
@@ -100,7 +99,7 @@ in {
     systemd.services.opensmtpd = let
       procEnv = pkgs.buildEnv {
         name = "opensmtpd-procs";
-        paths = [ opensmtpd ] ++ cfg.procPackages;
+        paths = [ pkgs.opensmtpd ] ++ cfg.procPackages;
         pathsToLink = [ "/libexec/opensmtpd" ];
       };
     in {

From 3851afc8eb5f3c5d691ec73a370ee26fd0bd385e Mon Sep 17 00:00:00 2001
From: Joachim Fasting <joachifm@fastmail.fm>
Date: Mon, 24 Oct 2016 17:54:10 +0200
Subject: [PATCH 3/5] opensmtpd service: path -> package for option
 procPackages

---
 nixos/modules/services/mail/opensmtpd.nix | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nixos/modules/services/mail/opensmtpd.nix b/nixos/modules/services/mail/opensmtpd.nix
index c54fd1950cfb..3b493d2015dc 100644
--- a/nixos/modules/services/mail/opensmtpd.nix
+++ b/nixos/modules/services/mail/opensmtpd.nix
@@ -61,7 +61,7 @@ in {
       };
 
       procPackages = mkOption {
-        type = types.listOf types.path;
+        type = types.listOf types.package;
         default = [];
         description = ''
           Packages to search for filters, tables, queues, and schedulers.

From f24ffc4919ed2cab8e49a85ff038a09c069aa2ca Mon Sep 17 00:00:00 2001
From: Joachim Fasting <joachifm@fastmail.fm>
Date: Mon, 24 Oct 2016 17:56:30 +0200
Subject: [PATCH 4/5] opensmtpd service: require serverConfiguration

If the daemon won't function without a valid config, it makes no sense
to default to an empty config.  Instead, turn that case into a build
failure.
---
 nixos/modules/services/mail/opensmtpd.nix | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/nixos/modules/services/mail/opensmtpd.nix b/nixos/modules/services/mail/opensmtpd.nix
index 3b493d2015dc..f048a382ca42 100644
--- a/nixos/modules/services/mail/opensmtpd.nix
+++ b/nixos/modules/services/mail/opensmtpd.nix
@@ -48,15 +48,13 @@ in {
 
       serverConfiguration = mkOption {
         type = types.lines;
-        default = "";
         example = ''
           listen on lo
           accept for any deliver to lmtp localhost:24
         '';
         description = ''
           The contents of the smtpd.conf configuration file. See the
-          OpenSMTPD documentation for syntax information. If this option
-          is left empty, the OpenSMTPD server will not start.
+          OpenSMTPD documentation for syntax information.
         '';
       };
 

From ab1e216942a227d00ac8aaad84df6483335b14d1 Mon Sep 17 00:00:00 2001
From: Joachim Fasting <joachifm@fastmail.fm>
Date: Mon, 24 Oct 2016 18:02:18 +0200
Subject: [PATCH 5/5] opensmtpd service: remove redundant wants network.target

Already part of normal bootup.
---
 nixos/modules/services/mail/opensmtpd.nix | 1 -
 1 file changed, 1 deletion(-)

diff --git a/nixos/modules/services/mail/opensmtpd.nix b/nixos/modules/services/mail/opensmtpd.nix
index f048a382ca42..5856b4697553 100644
--- a/nixos/modules/services/mail/opensmtpd.nix
+++ b/nixos/modules/services/mail/opensmtpd.nix
@@ -102,7 +102,6 @@ in {
       };
     in {
       wantedBy = [ "multi-user.target" ];
-      wants = [ "network.target" ];
       after = [ "network.target" ];
       preStart = ''
         mkdir -p /var/spool/smtpd