From 6b857eebbafba660cc57b19bd11f6484c91f8fd7 Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 18 Mar 2015 00:14:27 +0100 Subject: Integrate Postfix config into module-list.nix. This currently is just a dummy module for now with a big fat TODO, but at least we now have a homogenous module namespace starting with "labernix." and categorized by services/config/tasks/whatnot. Signed-off-by: aszlig --- machines/mailserver.nix | 7 ++-- modules/module-list.nix | 1 + modules/postfix/restrictions.nix | 53 ------------------------------- modules/services/postfix/default.nix | 1 + modules/services/postfix/restrictions.nix | 53 +++++++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 58 deletions(-) delete mode 100644 modules/postfix/restrictions.nix create mode 100644 modules/services/postfix/default.nix create mode 100644 modules/services/postfix/restrictions.nix diff --git a/machines/mailserver.nix b/machines/mailserver.nix index 86f6edac..7d4bd397 100644 --- a/machines/mailserver.nix +++ b/machines/mailserver.nix @@ -35,10 +35,7 @@ ''}"; in { - imports = [ - ../common.nix - ../modules/postfix/restrictions.nix # XXX: Refactor and remove! - ]; + imports = [ ../common.nix ]; services.spamassassin.enable = true; @@ -49,7 +46,7 @@ in { fileSystems."/".label = "root"; boot.loader.grub.device = "nodev"; - openlab.postfix.restrictions = { + labernix.postfix.restrictions = { sender = [ "reject_authenticated_sender_login_mismatch" "reject_unknown_sender_domain" diff --git a/modules/module-list.nix b/modules/module-list.nix index 864019b1..5137c672 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -1,3 +1,4 @@ [ ./config/labernix-pkgs.nix + ./services/postfix ] diff --git a/modules/postfix/restrictions.nix b/modules/postfix/restrictions.nix deleted file mode 100644 index 8f2412ca..00000000 --- a/modules/postfix/restrictions.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ config, lib, ... }: - -with lib; - -let - mkRestriction = name: specificDescription: { - option.${name} = mkOption { - default = null; - type = types.nullOr types.list; - description = '' - A list of restrictions to apply or to use the - built-in default value from Postfix. - ${specificDescription} - ''; - }; - config = let - cfg = config.openlab.postfix.restrictions.${name}; - in mkIf (cfg != null) '' - smtpd_${name}_restrictions = ${concatStringsSep ", " cfg} - ''; - }; - restrictions = mapAttrsToList mkRestriction { - client = mkRestriction '' - SMTP server access restrictions in the context of a client SMTP connection - request. - ''; - data = mkRestriction '' - Access restrictions that the Postfix SMTP server applies in the context of - the SMTP DATA command. - ''; - end_of_data = mkRestriction '' - Access restrictions that the Postfix SMTP server applies in the context of - the SMTP END-OF-DATA command. - ''; - etrn = mkRestriction '' - SMTP server access restrictions in the context of a client ETRN request. - ''; - helo = mkRestriction '' - Restrictions that the Postfix SMTP server applies in the context of the - SMTP HELO command. - ''; - recipient = mkRestriction '' - Access restrictions that the Postfix SMTP server applies in the context of - the RCPT TO command. - ''; - sender = mkRestriction '' - Restrictions that the Postfix SMTP server applies in the context of the - MAIL FROM command. - ''; - }; -in { - options.openlab.postfix.restrictions = mapAttrs mkRestriction restrictions; -} diff --git a/modules/services/postfix/default.nix b/modules/services/postfix/default.nix new file mode 100644 index 00000000..4103a41b --- /dev/null +++ b/modules/services/postfix/default.nix @@ -0,0 +1 @@ +import ./restrictions.nix # TODO: Dummy for now, implement me! diff --git a/modules/services/postfix/restrictions.nix b/modules/services/postfix/restrictions.nix new file mode 100644 index 00000000..fbb47f10 --- /dev/null +++ b/modules/services/postfix/restrictions.nix @@ -0,0 +1,53 @@ +{ config, lib, ... }: + +with lib; + +let + mkRestriction = name: specificDescription: { + option.${name} = mkOption { + default = null; + type = types.nullOr types.list; + description = '' + A list of restrictions to apply or to use the + built-in default value from Postfix. + ${specificDescription} + ''; + }; + config = let + cfg = config.labernix.postfix.restrictions.${name}; + in mkIf (cfg != null) '' + smtpd_${name}_restrictions = ${concatStringsSep ", " cfg} + ''; + }; + restrictions = mapAttrsToList mkRestriction { + client = mkRestriction '' + SMTP server access restrictions in the context of a client SMTP connection + request. + ''; + data = mkRestriction '' + Access restrictions that the Postfix SMTP server applies in the context of + the SMTP DATA command. + ''; + end_of_data = mkRestriction '' + Access restrictions that the Postfix SMTP server applies in the context of + the SMTP END-OF-DATA command. + ''; + etrn = mkRestriction '' + SMTP server access restrictions in the context of a client ETRN request. + ''; + helo = mkRestriction '' + Restrictions that the Postfix SMTP server applies in the context of the + SMTP HELO command. + ''; + recipient = mkRestriction '' + Access restrictions that the Postfix SMTP server applies in the context of + the RCPT TO command. + ''; + sender = mkRestriction '' + Restrictions that the Postfix SMTP server applies in the context of the + MAIL FROM command. + ''; + }; +in { + options.labernix.postfix.restrictions = mapAttrs mkRestriction restrictions; +} -- cgit 1.4.1