diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/module-list.nix | 1 | ||||
-rw-r--r-- | modules/services/postfix/default.nix | 65 |
2 files changed, 66 insertions, 0 deletions
diff --git a/modules/module-list.nix b/modules/module-list.nix index 26e740b2..2fc50017 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -1,5 +1,6 @@ [ ./profiles/common.nix + ./services/postfix ./user/aszlig/profiles/base.nix ./user/aszlig/profiles/workstation ./user/aszlig/programs/gajim 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 <option>null</option> 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)); +} |