{ pkgs, lib, config, ... }:
let
- inherit (builtins) attrNames concatStringsSep readFile toPath;
+ inherit (builtins) attrNames readFile toPath;
inherit (lib) types;
- inherit (pkgs.lib) loadFile unlines unwords unlinesAttrs;
inherit (config) networking users;
inherit (config.services) postfix dovecot2 openldap;
- domains = [
- "sourcephile.fr"
- "autogeree.net"
- ];
in
{
-imports = map (domain: (./postfix + "/${domain}.nix")) domains;
-options = {
- services.postfix = {
- tls_server_sni_maps = lib.mkOption {
- type = types.attrsOf (types.listOf types.path);
- default = {};
- apply = m: pkgs.writeText "sni" (lib.concatStringsSep "\n" (lib.mapAttrsToList (domain: x509: ''
- ${domain} ${unwords x509}
- '') m));
- };
- };
-};
-config = {
+imports = [
+ postfix/autogeree.net.nix
+ postfix/sourcephile.fr.nix
+];
users.groups.acme.members = [ postfix.user ];
-systemd.services.postfix = {
- wants = ["openldap.service"];
- after = ["openldap.service"];
- preStart = ''
- install -m 400 -o root -g root ${postfix.tls_server_sni_maps} /run/keys/postfix-sni
- ${pkgs.postfix}/bin/postmap -F hash:/run/keys/postfix-sni
- '';
-};
networking.nftables.ruleset = ''
add rule inet filter net2fw tcp dport 25 counter accept comment "SMTP"
add rule inet filter net2fw tcp dport 465 counter accept comment "submissions"
tls_server_sni_maps = "hash:/run/keys/postfix-sni";
# Only explicitely aliased accounts have a mail, not all the passwd
- local_recipient_maps = "$alias_maps";
+ #local_recipient_maps = "$alias_maps";
# Note that the local transport rewrites the envelope recipient
# according to the alias_maps, and thus the aliasing is transparent
# to the nexthop (eg. dovecot)
let
mkVal = value:
if lib.isList value
- then concatStringsSep "," value
+ then lib.concatStringsSep "," value
else
if value == true then "yes"
else if value == false then "no"
cleanup_service_name = "submissions-header-cleanup";
};
};
- submissions-header-cleanup = {
- type = "unix";
- private = false;
- maxproc = 0;
- command = "cleanup";
- args = mkArgs {
- header_checks = "pcre:" + pkgs.writeText "submission_header_cleanup_rules" ''
- # Removes sensitive headers from mails handed in via the submission or smtps port.
- # See https://thomas-leister.de/mailserver-debian-stretch/
- # Uses "pcre" style regex.
-
- /^Received:/ IGNORE
- /^User-Agent:/ IGNORE
- /^X-Enigmail:/ IGNORE
- /^X-Mailer:/ IGNORE
- /^X-Originating-IP:/ IGNORE
- '';
- };
- };
};
extraMasterConf = ''
#spfcheck unix - n n - 0 spawn
#noclue unix - n n - - pipe
# flags=q user=noclue argv=/usr/local/bin/noclue-delivery ${recipient} ${sender}
};
-};
}