From 915e56fb4453b0701a423b0c96fb145318162ffd Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 18 Mar 2015 20:58:26 +0100 Subject: Move last machine from labernix to vuizvui. I've moved the restrictions config of Postfix into the default module for now and actually fixed it so that it's actually working (the config value wasn't set before). Also, the option type was incorrectly set to types.list, which aliases to types.listOf and expects another function (kind) as its argument. This marks the end of LaberNix and the beginning of a new Vuizvui! Signed-off-by: aszlig --- modules/services/postfix/default.nix | 65 ++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 modules/services/postfix/default.nix (limited to 'modules/services/postfix/default.nix') diff --git a/modules/services/postfix/default.nix b/modules/services/postfix/default.nix new file mode 100644 index 00000000..8a0865b9 --- /dev/null +++ b/modules/services/postfix/default.nix @@ -0,0 +1,65 @@ +{ config, lib, ... }: + +with lib; + +let + cfg = config.vuizvui.services.postfix; + + mkRestriction = name: specificDescription: { + option.${name} = mkOption { + default = null; + type = types.nullOr (types.listOf types.str); + description = '' + A list of restrictions to apply or to use the + built-in default value from Postfix. + ${specificDescription} + ''; + }; + + config = let + restrictions = cfg.restrictions.${name}; + in mkIf (restrictions != null) { + services.postfix.extraConfig = '' + smtpd_${name}_restrictions = ${concatStringsSep ", " restrictions} + ''; + }; + }; + + restrictions = mapAttrsToList mkRestriction { + client = '' + SMTP server access restrictions in the context of a client SMTP connection + request. + ''; + data = '' + Access restrictions that the Postfix SMTP server applies in the context of + the SMTP DATA command. + ''; + end_of_data = '' + Access restrictions that the Postfix SMTP server applies in the context of + the SMTP END-OF-DATA command. + ''; + etrn = '' + SMTP server access restrictions in the context of a client ETRN request. + ''; + helo = '' + Restrictions that the Postfix SMTP server applies in the context of the + SMTP HELO command. + ''; + recipient = '' + Access restrictions that the Postfix SMTP server applies in the context of + the RCPT TO command. + ''; + sender = '' + Restrictions that the Postfix SMTP server applies in the context of the + MAIL FROM command. + ''; + }; + +in { + options.vuizvui.services.postfix = { + enable = mkEnableOption "Vuizvui Postfix"; + restrictions = fold mergeAttrs {} (catAttrs "option" restrictions); + }; + + config = mkIf cfg.enable (mkMerge (catAttrs "config" restrictions)); +} -- cgit 1.4.1