From 8fad959b15cba08a11a1f95b2f8fec6f977b06d1 Mon Sep 17 00:00:00 2001 From: Viktor Kleen Date: Tue, 5 Jan 2016 02:57:52 -0800 Subject: [PATCH 1/2] postfix service: make SMTP services optional using enableSmtp option --- nixos/modules/services/mail/postfix.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nixos/modules/services/mail/postfix.nix b/nixos/modules/services/mail/postfix.nix index 3a9e62a0205..c18ed599868 100644 --- a/nixos/modules/services/mail/postfix.nix +++ b/nixos/modules/services/mail/postfix.nix @@ -108,10 +108,14 @@ let flush unix n - n 1000? 0 flush proxymap unix - - n - - proxymap proxywrite unix - - n - 1 proxymap + '' + + optionalString cfg.enableSmtp '' smtp unix - - n - - smtp relay unix - - n - - smtp -o smtp_fallback_relay= # -o smtp_helo_timeout=5 -o smtp_connect_timeout=5 + '' + + '' showq unix n - n - - showq error unix - - n - - error retry unix - - n - - error @@ -154,6 +158,11 @@ in description = "Whether to run the Postfix mail server."; }; + enableSmtp = mkOption { + default = true; + description = "Whether to enable smtp in master.cf."; + }; + setSendmail = mkOption { default = true; description = "Whether to set the system sendmail to postfix's."; From ebd8e2c380c42e375f9860347a20245f01fbfc24 Mon Sep 17 00:00:00 2001 From: Viktor Kleen Date: Tue, 5 Jan 2016 02:59:16 -0800 Subject: [PATCH 2/2] postfix service: include configuration option for transport maps --- nixos/modules/services/mail/postfix.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nixos/modules/services/mail/postfix.nix b/nixos/modules/services/mail/postfix.nix index c18ed599868..2b9175036be 100644 --- a/nixos/modules/services/mail/postfix.nix +++ b/nixos/modules/services/mail/postfix.nix @@ -83,6 +83,9 @@ let + optionalString (cfg.virtual != "") '' virtual_alias_maps = hash:/etc/postfix/virtual '' + + optionalString (cfg.transport != "") '' + transport_maps = hash:/etc/postfix/transport + '' + cfg.extraConfig; masterCf = '' @@ -142,6 +145,7 @@ let virtualFile = pkgs.writeText "postfix-virtual" cfg.virtual; mainCfFile = pkgs.writeText "postfix-main.cf" mainCf; masterCfFile = pkgs.writeText "postfix-master.cf" masterCf; + transportFile = pkgs.writeText "postfix-transport" cfg.transport; in @@ -314,6 +318,13 @@ in "; }; + transport = mkOption { + default = ""; + description = " + Entries for the transport map, cf. man-page transport(8). + "; + }; + extraMasterConf = mkOption { default = ""; example = "submission inet n - n - - smtpd"; @@ -392,6 +403,7 @@ in ln -sf ${virtualFile} /var/postfix/conf/virtual ln -sf ${mainCfFile} /var/postfix/conf/main.cf ln -sf ${masterCfFile} /var/postfix/conf/master.cf + ln -sf ${transportFile} /var/postfix/conf/transport ${pkgs.postfix}/sbin/postalias -c /var/postfix/conf /var/postfix/conf/aliases ${pkgs.postfix}/sbin/postmap -c /var/postfix/conf /var/postfix/conf/virtual