nixos-wiki-infra/modules/postfix.nix

52 lines
1.5 KiB
Nix
Raw Normal View History

2024-04-01 18:31:43 +02:00
{ config, pkgs, ... }:
2024-03-06 19:27:33 +01:00
let
domain = "wiki.nixos.org";
in
{
services.opendkim.enable = true;
services.opendkim.domains = domain;
services.opendkim.selector = "mail";
services.opendkim.user = config.services.postfix.user;
services.opendkim.group = config.services.postfix.group;
sops.secrets.opendkim-private-key.owner = config.services.postfix.user;
services.opendkim.keyPath = "/run/opendkim-keys";
2024-04-01 18:31:43 +02:00
systemd.services.opendkim.serviceConfig = {
ExecStartPre = [
(
"+${pkgs.writeShellScript "opendkim-keys" ''
install -o ${config.services.postfix.user} -g ${config.services.postfix.group} -D -m0700 ${config.sops.secrets.opendkim-private-key.path} /run/opendkim-keys/${config.services.opendkim.selector}.private
''}"
)
];
};
2024-03-06 19:27:33 +01:00
# postfix configuration for sending emails only
services.postfix = {
enable = true;
hostname = domain;
inherit domain;
config = {
smtp_tls_note_starttls_offer = "yes";
smtp_tls_security_level = "dane";
tls_medium_cipherlist = "AES128+EECDH:AES128+EDH";
smtpd_relay_restrictions = "permit_mynetworks permit_sasl_authenticated defer_unauth_destination";
mydestination = "localhost.$mydomain, localhost, $myhostname";
myorigin = "$mydomain";
milter_default_action = "accept";
milter_protocol = "6";
smtpd_milters = "unix:/run/opendkim/opendkim.sock";
non_smtpd_milters = "unix:/run/opendkim/opendkim.sock";
inet_interfaces = "loopback-only";
inet_protocols = "all";
};
};
}