about summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2015-03-11 03:10:47 +0100
committeraszlig <aszlig@redmoonstudios.org>2015-03-11 03:10:47 +0100
commit3d2b4f9663cda3c7df39dc48ccbc7f25ac7696b6 (patch)
tree32a0e22134c4eae12c206deb3aca3241163f0777 /modules
parentad3678e9d06ec8d9e4b89bf1fe31c921a969d922 (diff)
Add rudimentary mail server config.
A still unfinished version of @waaaaargh's ansible deployment:

https://github.com/waaaaargh/mailserver-ansible

The idea here is to create a NixOS profile specific to large-scole mail
server deployments. All with a 100% fleshed out Postfix configuration of
course :-)

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'modules')
-rw-r--r--modules/postfix/restrictions.nix53
1 files changed, 53 insertions, 0 deletions
diff --git a/modules/postfix/restrictions.nix b/modules/postfix/restrictions.nix
new file mode 100644
index 00000000..8f2412ca
--- /dev/null
+++ b/modules/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 <option>null</option> 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;
+}