nixos/postfix: modernize, cleanup (#416840)

+2 -2
nixos/doc/manual/release-notes/rl-2511.section.md
···
- The Postfix module has been updated and likely requires configuration changes:
- The `services.postfix.sslCert` and `sslKey` options were removed and you now need to configure
-
- [services.postfix.config.smtpd_tls_chain_files](#opt-services.postfix.config.smtpd_tls_chain_files) for server certificates,
-
- [services.postfix.config.smtp_tls_chain_files](#opt-services.postfix.config) for client certificates.
+
- [services.postfix.settings.main.smtpd_tls_chain_files](#opt-services.postfix.settings.main.smtpd_tls_chain_files) for server certificates,
+
- [services.postfix.settings.main.smtp_tls_chain_files](#opt-services.postfix.settings.main) for client certificates.
- `vmalert` now supports multiple instances with the option `services.vmalert.instances."".enable`
+6 -4
nixos/modules/services/mail/mailman.md
···
{
services.postfix = {
enable = true;
-
relayDomains = [ "hash:/var/lib/mailman/data/postfix_domains" ];
-
sslCert = config.security.acme.certs."lists.example.org".directory + "/full.pem";
-
sslKey = config.security.acme.certs."lists.example.org".directory + "/key.pem";
-
config = {
+
settings.main = {
transport_maps = [ "hash:/var/lib/mailman/data/postfix_lmtp" ];
local_recipient_maps = [ "hash:/var/lib/mailman/data/postfix_lmtp" ];
+
relay_domains = [ "hash:/var/lib/mailman/data/postfix_domains" ];
+
smtpd_tls_chain_files = [
+
config.security.acme.certs."lists.example.org".directory + "/full.pem"
+
config.security.acme.certs."lists.example.org".directory + "/key.pem"
+
];
};
};
services.mailman = {
+2 -2
nixos/modules/services/mail/mailman.nix
···
];
services.postfix = lib.mkIf cfg.enablePostfix {
-
recipientDelimiter = "+"; # bake recipient addresses in mail envelopes via VERP
-
config = {
+
settings.main = {
owner_request_special = "no"; # Mailman handles -owner addresses on its own
+
recipient_delimiter = "+"; # bake recipient addresses in mail envelopes via VERP
};
};
+5 -4
nixos/modules/services/mail/mlmmj.nix
···
services.postfix = {
enable = true;
-
recipientDelimiter = "+";
-
masterConfig.mlmmj = {
+
settings.main = {
+
recipient_delimiter = "+";
+
propagate_unmatched_extensions = "virtual";
+
};
+
settings.master.mlmmj = {
type = "unix";
private = true;
privileged = true;
···
};
extraAliases = concatMapLines (alias cfg.listDomain) cfg.mailLists;
-
-
extraConfig = "propagate_unmatched_extensions = virtual";
virtual = concatMapLines (virtual cfg.listDomain) cfg.mailLists;
transport = concatMapLines (transport cfg.listDomain) cfg.mailLists;
+1 -1
nixos/modules/services/mail/pfix-srsd.nix
···
config = lib.mkMerge [
(lib.mkIf (cfg.enable && cfg.configurePostfix && config.services.postfix.enable) {
-
services.postfix.config = {
+
services.postfix.settings.main = {
sender_canonical_maps = [ "tcp:127.0.0.1:10001" ];
sender_canonical_classes = [ "envelope_sender" ];
recipient_canonical_maps = [ "tcp:127.0.0.1:10002" ];
+1 -1
nixos/modules/services/mail/postfix-tlspol.nix
···
config = mkMerge [
(mkIf (cfg.enable && config.services.postfix.enable && cfg.configurePostfix) {
# https://github.com/Zuplu/postfix-tlspol#postfix-configuration
-
services.postfix.config = {
+
services.postfix.settings.main = {
smtp_dns_support_level = "dnssec";
smtp_tls_security_level = "dane";
smtp_tls_policy_maps =
+337 -221
nixos/modules/services/mail/postfix.nix
···
}:
let
inherit (lib)
+
literalExpression
mkOption
types
;
···
mkEntry = name: value: "${escape name} =${mkVal value}";
in
lib.concatStringsSep "\n" (
-
lib.mapAttrsToList mkEntry (lib.filterAttrsRecursive (_: value: value != null) cfg.config)
-
)
-
+ "\n"
-
+ cfg.extraConfig;
+
lib.mapAttrsToList mkEntry (lib.filterAttrsRecursive (_: value: value != null) cfg.settings.main)
+
);
masterCfOptions =
{
···
""
];
-
masterCf = lib.mapAttrsToList (lib.const (lib.getAttr "rawEntry")) cfg.masterConfig;
+
masterCf = lib.mapAttrsToList (lib.const (lib.getAttr "rawEntry")) cfg.settings.master;
# A list of the maximum width of the columns across all lines and labels
maxWidths =
···
{
+
meta.maintainers = with lib.maintainers; [
+
dotlambda
+
hexa
+
];
+
###### interface
options = {
···
enableSmtp = lib.mkOption {
type = lib.types.bool;
default = true;
-
description = "Whether to enable smtp in master.cf.";
+
description = ''
+
Whether to enable the `smtp` service configured in the master.cf.
+
+
This service listens for plain text SMTP connections on port 25
+
and supports explicit TLS via StartTLS.
+
+
It is the primary port used by SMTP servers to exchange mail.
+
'';
};
enableSubmission = lib.mkOption {
type = lib.types.bool;
default = false;
-
description = "Whether to enable smtp submission.";
+
description = "
+
Whether to enable the `submission` service configured in master.cf.
+
+
This service listens for plain text SMTP connections on port 587
+
and supports explicit TLS via StartTLS.
+
+
It is a way for clients to login and submit mails after an inband
+
connection upgrade using StartTLS.
+
+
::: {.warning}
+
[RFC 8314](https://www.rfc-editor.org/rfc/rfc8314) discourages the use
+
of explicit TLS for mail submissionn.
+
:::
+
";
};
enableSubmissions = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
-
Whether to enable smtp submission via smtps.
+
Whether to enable the `submissions` service configured in master.cf.
+
+
This service listen for implicit TLS connections on port 465.
-
According to RFC 8314 this should be preferred
-
over STARTTLS for submission of messages by end user clients.
+
::: {.info}
+
Per [RFC 8314](https://www.rfc-editor.org/rfc/rfc8314) implicit TLS
+
is recommended for mail submission.
+
:::
'';
};
···
'';
};
-
networks = lib.mkOption {
-
type = lib.types.nullOr (lib.types.listOf lib.types.str);
-
default = null;
-
example = [ "192.168.0.1/24" ];
-
description = ''
-
Net masks for trusted - allowed to relay mail to third parties -
-
hosts. Leave empty to use mynetworks_style configuration or use
-
default (localhost-only).
-
'';
-
};
-
-
networksStyle = lib.mkOption {
-
type = lib.types.str;
-
default = "";
-
description = ''
-
Name of standard way of trusted network specification to use,
-
leave blank if you specify it explicitly or if you want to use
-
default (localhost-only).
-
'';
-
};
-
-
hostname = lib.mkOption {
-
type = lib.types.str;
-
default = "";
-
description = ''
-
Hostname to use. Leave blank to use just the hostname of machine.
-
It should be FQDN.
-
'';
-
};
-
-
domain = lib.mkOption {
-
type = lib.types.str;
-
default = "";
-
description = ''
-
Domain to use. Leave blank to use hostname minus first component.
-
'';
-
};
-
-
origin = lib.mkOption {
-
type = lib.types.str;
-
default = "";
-
description = ''
-
Origin to use in outgoing e-mail. Leave blank to use hostname.
-
'';
-
};
-
-
destination = lib.mkOption {
-
type = lib.types.nullOr (lib.types.listOf lib.types.str);
-
default = null;
-
example = [ "localhost" ];
-
description = ''
-
Full (!) list of domains we deliver locally. Leave blank for
-
acceptable Postfix default.
-
'';
-
};
-
-
relayDomains = lib.mkOption {
-
type = lib.types.nullOr (lib.types.listOf lib.types.str);
-
default = null;
-
example = [ "localdomain" ];
-
description = ''
-
List of domains we agree to relay to. Default is empty.
-
'';
-
};
-
-
relayHost = lib.mkOption {
-
type = lib.types.str;
-
default = "";
-
description = ''
-
Mail relay for outbound mail.
-
'';
-
};
-
-
relayPort = lib.mkOption {
-
type = lib.types.int;
-
default = 25;
-
description = ''
-
SMTP port for relay mail relay.
-
'';
-
};
-
-
lookupMX = lib.mkOption {
-
type = lib.types.bool;
-
default = false;
-
description = ''
-
Whether relay specified is just domain whose MX must be used.
-
'';
-
};
-
postmasterAlias = lib.mkOption {
type = lib.types.str;
default = "root";
···
description = "The format the alias map should have. Use regexp if you want to use regular expressions.";
};
-
config = lib.mkOption {
-
type = lib.types.submodule {
-
freeformType =
-
with types;
-
attrsOf (
-
nullOr (oneOf [
-
bool
-
int
-
str
-
(listOf str)
-
])
-
);
-
options = {
-
smtpd_tls_chain_files = mkOption {
-
type = with types; listOf path;
-
default = [ ];
-
example = [
-
"/var/lib/acme/mail.example.com/privkey.pem"
-
"/var/lib/acme/mail.example.com/fullchain.pem"
-
];
-
description = ''
-
List of paths to the server private keys and certificates.
+
settings = {
+
main = lib.mkOption {
+
type = lib.types.submodule {
+
freeformType =
+
with types;
+
attrsOf (
+
nullOr (oneOf [
+
bool
+
int
+
str
+
(listOf str)
+
])
+
);
+
options = {
+
message_size_limit = mkOption {
+
type = with types; nullOr int;
+
default = 10240000; # 10 MiB
+
example = 52428800; # 50 MiB
+
description = ''
+
Maximum size of an email message in bytes.
+
+
<https://www.postfix.org/postconf.5.html#message_size_limit>
+
'';
+
};
+
+
mydestination = mkOption {
+
type =
+
with types;
+
nullOr (oneOf [
+
str
+
(listOf str)
+
]);
+
default = [
+
"$myhostname"
+
"localhost.$mydomain"
+
"localhost"
+
];
+
description = ''
+
List of domain names intended for local delivery using /etc/passwd and /etc/aliases.
+
+
::: {.warning}
+
Do not include [virtual](https://www.postfix.org/VIRTUAL_README.html) domains in this list.
+
:::
+
+
<https://www.postfix.org/postconf.5.html#mydestination>
+
'';
+
};
+
+
myhostname = mkOption {
+
type = with types; nullOr types.str;
+
default = null;
+
example = "mail.example.com";
+
description = ''
+
The internet hostname of this mail system.
+
+
Leave unset to default to the system hostname with the {option}`mydomain` suffix.
+
+
<https://www.postfix.org/postconf.5.html#myhostname>
+
'';
+
};
+
+
mynetworks = mkOption {
+
type = with types; nullOr (listOf str);
+
default = null;
+
example = [
+
"127.0.0.0/8"
+
"::1"
+
];
+
description = ''
+
List of trusted remote SMTP clients, that are allowed to relay mail.
+
+
Leave unset to let Postfix populate this list based on the {option}`mynetworks_style` setting.
+
+
<https://www.postfix.org/postconf.5.html#mynetworks>
+
'';
+
};
+
+
mynetworks_style = mkOption {
+
type =
+
with types;
+
nullOr (enum [
+
"host"
+
"subnet"
+
"class"
+
]);
+
default = "host";
+
description = ''
+
The method used for generating the default value for {option}`mynetworks`, if that option is unset.
-
::: {.caution}
-
The order of items matters and a private key must always be followed by the corresponding certificate.
-
:::
+
<https://www.postfix.org/postconf.5.html#mynetworks_style>
+
'';
+
};
-
<https://www.postfix.org/postconf.5.html#smtpd_tls_chain_files>
-
'';
-
};
+
recipient_delimiter = lib.mkOption {
+
type = with types; nullOr str;
+
default = "";
+
example = "+";
+
description = ''
+
Set of characters used as the delimiters for address extensions.
-
smtpd_tls_security_level = mkOption {
-
type = types.enum [
-
"none"
-
"may"
-
"encrypt"
-
];
-
default = if config.services.postfix.config.smtpd_tls_chain_files != [ ] then "may" else "none";
-
defaultText = lib.literalExpression ''
-
if config.services.postfix.config.smtpd_tls_chain_files != [ ] then "may" else "none"
-
'';
-
example = "may";
-
description = ''
-
The server TLS security level. Enable TLS by configuring at least `may`.
+
This allows creating different forwarding rules per extension.
-
<https://www.postfix.org/postconf.5.html#smtpd_tls_security_level>
-
'';
+
<https://www.postfix.org/postconf.5.html#recipient_delimiter>
+
'';
+
};
+
+
relayhost = mkOption {
+
type = with types; nullOr (listOf str);
+
default = [ ];
+
example = [ "[relay.example.com]:587" ];
+
description = ''
+
List of hosts to use for relaying outbound mail.
+
+
::: {.note}
+
Putting the hostname in angled brackets, e.g. `[relay.example.com]`, turns off MX and SRV lookups for the hostname.
+
:::
+
+
<https://www.postfix.org/postconf.5.html#relayhost>
+
'';
+
};
+
+
relay_domains = mkOption {
+
type = with types; nullOr (listOf str);
+
default = [ ];
+
example = [ "lists.example.com" ];
+
description = ''
+
List of domains delivered via the relay transport.
+
+
<https://www.postfix.org/postconf.5.html#relay_domains>
+
'';
+
};
+
+
smtp_tls_CAfile = mkOption {
+
type = types.path;
+
default = config.security.pki.caBundle;
+
defaultText = literalExpression ''
+
config.security.pki.caBundle
+
'';
+
example = literalExpression ''
+
''${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
+
'';
+
description = ''
+
File containing CA certificates of root CAs trusted to sign either remote SMTP server certificates or intermediate CA certificates.
+
+
Defaults to the system CA bundle that is managed through the `security.pki` options.
+
+
<https://www.postfix.org/postconf.5.html#smtp_tls_CAfile>
+
'';
+
};
+
+
smtp_tls_security_level = mkOption {
+
type = types.enum [
+
"none"
+
"may"
+
"encrypt"
+
"dane"
+
"dane-only"
+
"fingerprint"
+
"verify"
+
"secure"
+
];
+
default = "may";
+
description = ''
+
The client TLS security level.
+
+
::: {.tip}
+
Use `dane` with a local DNSSEC validating DNS resolver enabled.
+
:::
+
+
<https://www.postfix.org/postconf.5.html#smtp_tls_security_level>
+
'';
+
};
+
+
smtpd_tls_chain_files = mkOption {
+
type = with types; listOf path;
+
default = [ ];
+
example = [
+
"/var/lib/acme/mail.example.com/privkey.pem"
+
"/var/lib/acme/mail.example.com/fullchain.pem"
+
];
+
description = ''
+
List of paths to the server private keys and certificates.
+
+
::: {.caution}
+
The order of items matters and a private key must always be followed by the corresponding certificate.
+
:::
+
+
<https://www.postfix.org/postconf.5.html#smtpd_tls_chain_files>
+
'';
+
};
+
+
smtpd_tls_security_level = mkOption {
+
type = types.enum [
+
"none"
+
"may"
+
"encrypt"
+
];
+
default =
+
if config.services.postfix.settings.main.smtpd_tls_chain_files != [ ] then "may" else "none";
+
defaultText = lib.literalExpression ''
+
if config.services.postfix.settings.main.smtpd_tls_chain_files != [ ] then "may" else "none"
+
'';
+
example = "may";
+
description = ''
+
The server TLS security level. Enable TLS by configuring at least `may`.
+
+
<https://www.postfix.org/postconf.5.html#smtpd_tls_security_level>
+
'';
+
};
};
};
-
};
-
description = ''
-
The main.cf configuration file as key value set.
+
description = ''
+
The main.cf configuration file as key value set.
-
Null values will not be rendered.
-
'';
-
example = {
-
mail_owner = "postfix";
-
smtp_tls_security_level = "may";
+
Null values will not be rendered.
+
+
::: {.tip}
+
Check `postconf -d` for the default values of all settings.
+
:::
+
'';
+
example = {
+
mail_owner = "postfix";
+
smtp_tls_security_level = "may";
+
};
};
-
};
-
extraConfig = lib.mkOption {
-
type = lib.types.lines;
-
default = "";
-
description = ''
-
Extra lines to be added verbatim to the main.cf configuration file.
-
'';
-
};
+
master = lib.mkOption {
+
type = lib.types.attrsOf (lib.types.submodule masterCfOptions);
+
default = { };
+
example = {
+
submission = {
+
type = "inet";
+
args = [
+
"-o"
+
"smtpd_tls_security_level=encrypt"
+
];
+
};
+
};
+
description = ''
+
The {file}`master.cf` configuration file as an attribute set of service
+
defitions
-
tlsTrustedAuthorities = lib.mkOption {
-
type = lib.types.str;
-
default = config.security.pki.caBundle;
-
defaultText = lib.literalExpression "config.security.pki.caBundle";
-
example = lib.literalExpression ''"''${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"'';
-
description = ''
-
File containing trusted certification authorities (CA) to verify certificates of mailservers contacted for mail delivery. This sets [smtp_tls_CAfile](https://www.postfix.org/postconf.5.html#smtp_tls_CAfile). Defaults to system trusted certificates (see `security.pki.*` options).
-
'';
-
};
+
::: {.tip}
+
Check <https://www.postfix.org/master.5.html> for possible settings.
+
:::
+
'';
+
};
-
recipientDelimiter = lib.mkOption {
-
type = lib.types.str;
-
default = "";
-
example = "+";
-
description = ''
-
Delimiter for address extension: so mail to user+test can be handled by ~user/.forward+test
-
'';
};
canonical = lib.mkOption {
···
default = "";
type = lib.types.lines;
description = "contents of check_client_access for overriding dnsBlacklists";
-
};
-
-
masterConfig = lib.mkOption {
-
type = lib.types.attrsOf (lib.types.submodule masterCfOptions);
-
default = { };
-
example = {
-
submission = {
-
type = "inet";
-
args = [
-
"-o"
-
"smtpd_tls_security_level=encrypt"
-
];
-
};
-
};
-
description = ''
-
An attribute set of service options, which correspond to the service
-
definitions usually done within the Postfix
-
{file}`master.cf` file.
-
'';
};
extraMasterConf = lib.mkOption {
···
};
};
-
services.postfix.config =
+
services.postfix.settings.main =
(lib.mapAttrs (_: v: lib.mkDefault v) {
compatibility_level = pkgs.postfix.version;
mail_owner = cfg.user;
···
mail_spool_directory = "/var/spool/mail/";
setgid_group = cfg.setgidGroup;
})
-
// lib.optionalAttrs (cfg.relayHost != "") {
-
relayhost =
-
if cfg.lookupMX then
-
"${cfg.relayHost}:${toString cfg.relayPort}"
-
else
-
"[${cfg.relayHost}]:${toString cfg.relayPort}";
-
}
-
// lib.optionalAttrs (!config.networking.enableIPv6) { inet_protocols = lib.mkDefault "ipv4"; }
-
// lib.optionalAttrs (cfg.networks != null) { mynetworks = cfg.networks; }
-
// lib.optionalAttrs (cfg.networksStyle != "") { mynetworks_style = cfg.networksStyle; }
-
// lib.optionalAttrs (cfg.hostname != "") { myhostname = cfg.hostname; }
-
// lib.optionalAttrs (cfg.domain != "") { mydomain = cfg.domain; }
-
// lib.optionalAttrs (cfg.origin != "") { myorigin = cfg.origin; }
-
// lib.optionalAttrs (cfg.destination != null) { mydestination = cfg.destination; }
-
// lib.optionalAttrs (cfg.relayDomains != null) { relay_domains = cfg.relayDomains; }
-
// lib.optionalAttrs (cfg.recipientDelimiter != "") {
-
recipient_delimiter = cfg.recipientDelimiter;
-
}
// lib.optionalAttrs haveAliases { alias_maps = [ "${cfg.aliasMapType}:/etc/postfix/aliases" ]; }
// lib.optionalAttrs haveTransport { transport_maps = [ "hash:/etc/postfix/transport" ]; }
// lib.optionalAttrs haveVirtual {
···
// lib.optionalAttrs (cfg.dnsBlacklists != [ ]) { smtpd_client_restrictions = clientRestrictions; }
// lib.optionalAttrs cfg.enableHeaderChecks {
header_checks = [ "regexp:/etc/postfix/header_checks" ];
-
}
-
// lib.optionalAttrs (cfg.tlsTrustedAuthorities != "") {
-
smtp_tls_CAfile = cfg.tlsTrustedAuthorities;
-
smtp_tls_security_level = lib.mkDefault "may";
};
-
services.postfix.masterConfig = {
+
services.postfix.settings.master = {
pickup = {
private = false;
wakeup = 60;
···
imports = [
(lib.mkRemovedOptionModule [ "services" "postfix" "sslCACert" ]
-
"services.postfix.sslCACert was replaced by services.postfix.tlsTrustedAuthorities. In case you intend that your server should validate requested client certificates use services.postfix.extraConfig."
+
"services.postfix.sslCACert was replaced by services.postfix.tlsTrustedAuthorities. In case you intend that your server should validate requested client certificates use services.postfix.settings.main.smtp_tls_CAfile."
(lib.mkRemovedOptionModule [ "services" "postfix" "sslCert" ]
-
"services.postfix.sslCert was removed. Use services.postfix.config.smtpd_tls_chain_files for the server certificate, or services.postfix.config.smtp_tls_chain_files for the client certificate."
+
"services.postfix.sslCert was removed. Use services.postfix.settings.main.smtpd_tls_chain_files for the server certificate, or services.postfix.settings.main.smtp_tls_chain_files for the client certificate."
(lib.mkRemovedOptionModule [ "services" "postfix" "sslKey" ]
-
"services.postfix.sslKey was removed. Use services.postfix.config.smtpd_tls_chain_files for server private key, or services.postfix.config.smtp_tls_chain_files for the client private key."
+
"services.postfix.sslKey was removed. Use services.postfix.settings.main.smtpd_tls_chain_files for server private key, or services.postfix.settings.main.smtp_tls_chain_files for the client private key."
+
)
+
(lib.mkRemovedOptionModule [ "services" "postfix" "lookupMX" ]
+
"services.postfix.lookupMX was removed. Use services.postfix.settings.main.relayhost and put the hostname in angled brackets, if you need to turn off MX and SRV lookups."
+
)
+
(lib.mkRemovedOptionModule [ "services" "postfix" "relayHost" ]
+
"services.postfix.relayHost was removed in favor of services.postfix.settings.main.relayhost, which now takes a list of host/port."
+
)
+
(lib.mkRemovedOptionModule [ "services" "postfix" "relayPort" ]
+
"services.postfix.relayHost was removed in favor of services.postfix.settings.main.relayhost, which now takes a list of host/port."
+
)
+
(lib.mkRemovedOptionModule [ "services" "postfix" "extraConfig" ]
+
"services.postfix.extraConfig was replaced by the structured freeform service.postfix.settings.main option."
+
)
+
(lib.mkRenamedOptionModule
+
[ "services" "postfix" "networks" ]
+
[ "services" "postfix" "settings" "main" "mynetworks" ]
+
)
+
(lib.mkRenamedOptionModule
+
[ "services" "postfix" "networkStyle" ]
+
[ "services" "postfix" "settings" "main" "mynetworks_style" ]
+
)
+
(lib.mkRenamedOptionModule
+
[ "services" "postfix" "hostname" ]
+
[ "services" "postfix" "settings" "main" "myhostname" ]
+
)
+
(lib.mkRenamedOptionModule
+
[ "services" "postfix" "domain" ]
+
[ "services" "postfix" "settings" "main" "mydomain" ]
+
)
+
(lib.mkRenamedOptionModule
+
[ "services" "postfix" "origin" ]
+
[ "services" "postfix" "settings" "main" "myorigin" ]
+
)
+
(lib.mkRenamedOptionModule
+
[ "services" "postfix" "destination" ]
+
[ "services" "postfix" "settings" "main" "mydestination" ]
+
)
+
(lib.mkRenamedOptionModule
+
[ "services" "postfix" "relayDomains" ]
+
[ "services" "postfix" "settings" "main" "relay_domains" ]
+
)
+
(lib.mkRenamedOptionModule
+
[ "services" "postfix" "recipientDelimiter" ]
+
[ "services" "postfix" "settings" "main" "recipient_delimiter" ]
+
)
+
(lib.mkRenamedOptionModule
+
[ "services" "postfix" "tlsTrustedAuthoriies" ]
+
[ "services" "postfix" "settings" "main" "smtp_tls_CAfile" ]
+
)
+
(lib.mkRenamedOptionModule
+
[ "services" "postfix" "config" ]
+
[ "services" "postfix" "settings" "main" ]
+
)
+
(lib.mkRenamedOptionModule
+
[ "services" "postfix" "masterConfig" ]
+
[ "services" "postfix" "settings" "master" ]
(lib.mkChangedOptionModule
[ "services" "postfix" "useDane" ]
-
[ "services" "postfix" "config" "smtp_tls_security_level" ]
+
[ "services" "postfix" "settings" "main" "smtp_tls_security_level" ]
(config: lib.mkIf config.services.postfix.useDane "dane")
(lib.mkRenamedOptionModule [ "services" "postfix" "useSrs" ] [ "services" "pfix-srsd" "enable" ])
+1 -1
nixos/modules/services/mail/postsrsd.nix
···
config = lib.mkMerge [
(lib.mkIf (cfg.enable && cfg.configurePostfix && config.services.postfix.enable) {
-
services.postfix.config = {
+
services.postfix.settings.main = {
# https://github.com/roehling/postsrsd#configuration
sender_canonical_maps = "socketmap:${cfg.settings.socketmap}:forward";
sender_canonical_classes = "envelope_sender";
+2 -2
nixos/modules/services/mail/public-inbox.nix
···
};
services.postfix = mkIf (cfg.postfix.enable && cfg.mda.enable) {
# Not sure limiting to 1 is necessary, but better safe than sorry.
-
config.public-inbox_destination_recipient_limit = "1";
+
settings.main.public-inbox_destination_recipient_limit = "1";
# Register the addresses as existing
virtual = concatStringsSep "\n" (
···
);
# The public-inbox transport
-
masterConfig.public-inbox = {
+
settings.master.public-inbox = {
type = "unix";
privileged = true; # Required for user=
command = "pipe";
+1 -1
nixos/modules/services/mail/rspamd.nix
···
'';
};
};
-
services.postfix.config = mkIf cfg.postfix.enable cfg.postfix.config;
+
services.postfix.settings.main = mkIf cfg.postfix.enable cfg.postfix.config;
systemd.services.postfix = mkIf cfg.postfix.enable {
serviceConfig.SupplementaryGroups = [ postfixCfg.group ];
+1 -3
nixos/modules/services/mail/schleuder.nix
···
flags=DRhu user=schleuder argv=/${pkgs.schleuder}/bin/schleuder work ''${recipient}
'';
transport = lib.mkIf (cfg.lists != [ ]) (postfixMap (lib.genAttrs cfg.lists (_: "schleuder:")));
-
extraConfig = ''
-
schleuder_destination_recipient_limit = 1
-
'';
+
settings.main.schleuder_destination_recipient_limit = 1;
# review: does this make sense?
localRecipients = lib.mkIf (cfg.lists != [ ]) cfg.lists;
};
+38 -36
nixos/modules/services/mail/sympa.nix
···
services.postfix = lib.mkIf (cfg.mta.type == "postfix") {
enable = true;
-
recipientDelimiter = "+";
-
config = {
-
virtual_alias_maps = [ "hash:${dataDir}/virtual.sympa" ];
-
virtual_mailbox_maps = [
-
"hash:${dataDir}/transport.sympa"
-
"hash:${dataDir}/sympa_transport"
-
"hash:${dataDir}/virtual.sympa"
-
];
-
virtual_mailbox_domains = [ "hash:${dataDir}/transport.sympa" ];
-
transport_maps = [
-
"hash:${dataDir}/transport.sympa"
-
"hash:${dataDir}/sympa_transport"
-
];
-
};
-
masterConfig = {
-
"sympa" = {
-
type = "unix";
-
privileged = true;
-
chroot = false;
-
command = "pipe";
-
args = [
-
"flags=hqRu"
-
"user=${user}"
-
"argv=${pkg}/libexec/queue"
-
"\${nexthop}"
+
settings = {
+
main = {
+
recipient_delimiter = "+";
+
virtual_alias_maps = [ "hash:${dataDir}/virtual.sympa" ];
+
virtual_mailbox_maps = [
+
"hash:${dataDir}/transport.sympa"
+
"hash:${dataDir}/sympa_transport"
+
"hash:${dataDir}/virtual.sympa"
];
-
};
-
"sympabounce" = {
-
type = "unix";
-
privileged = true;
-
chroot = false;
-
command = "pipe";
-
args = [
-
"flags=hqRu"
-
"user=${user}"
-
"argv=${pkg}/libexec/bouncequeue"
-
"\${nexthop}"
+
virtual_mailbox_domains = [ "hash:${dataDir}/transport.sympa" ];
+
transport_maps = [
+
"hash:${dataDir}/transport.sympa"
+
"hash:${dataDir}/sympa_transport"
];
+
};
+
master = {
+
"sympa" = {
+
type = "unix";
+
privileged = true;
+
chroot = false;
+
command = "pipe";
+
args = [
+
"flags=hqRu"
+
"user=${user}"
+
"argv=${pkg}/libexec/queue"
+
"\${nexthop}"
+
];
+
};
+
"sympabounce" = {
+
type = "unix";
+
privileged = true;
+
chroot = false;
+
command = "pipe";
+
args = [
+
"flags=hqRu"
+
"user=${user}"
+
"argv=${pkg}/libexec/bouncequeue"
+
"\${nexthop}"
+
];
+
};
};
};
};
+1 -1
nixos/modules/services/mail/zeyple.nix
···
-o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128
'';
-
services.postfix.extraConfig = "content_filter = zeyple";
+
services.postfix.settings.main.content_filter = "zeyple";
};
}
+2 -2
nixos/modules/services/monitoring/parsedmarc.nix
···
services.postfix = lib.mkIf cfg.provision.localMail.enable {
enable = true;
-
origin = cfg.provision.localMail.hostname;
-
config = {
+
settings.main = {
myhostname = cfg.provision.localMail.hostname;
+
myorigin = cfg.provision.localMail.hostname;
mydestination = cfg.provision.localMail.hostname;
};
};
+10 -6
nixos/modules/services/web-apps/discourse.nix
···
services.postfix = lib.mkIf cfg.mail.incoming.enable {
enable = true;
-
sslCert = lib.optionalString (cfg.sslCertificate != null) cfg.sslCertificate;
-
sslKey = lib.optionalString (cfg.sslCertificateKey != null) cfg.sslCertificateKey;
-
origin = cfg.hostname;
-
relayDomains = [ cfg.hostname ];
-
config = {
+
settings.main = {
smtpd_recipient_restrictions = "check_policy_service unix:private/discourse-policy";
append_dot_mydomain = lib.mkDefault false;
compatibility_level = "2";
smtputf8_enable = false;
smtpd_banner = lib.mkDefault "ESMTP server";
+
smtpd_tls_chain_files =
+
lib.optionals (cfg.sslCertificate != null && cfg.sslCertificateKey != null)
+
[
+
cfg.sslCertificateKey
+
cfg.sslCertificate
+
];
myhostname = lib.mkDefault cfg.hostname;
mydestination = lib.mkDefault "localhost";
+
myorigin = cfg.hostname;
+
relay_domains = [ cfg.hostname ];
};
transport = ''
${cfg.hostname} discourse-mail-receiver:
'';
-
masterConfig = {
+
settings.master = {
"discourse-mail-receiver" = {
type = "unix";
privileged = true;
+1 -1
nixos/modules/services/web-apps/mastodon.nix
···
services.postfix = lib.mkIf (cfg.smtp.createLocally && cfg.smtp.host == "127.0.0.1") {
enable = true;
-
hostname = lib.mkDefault "${cfg.localDomain}";
+
settings.main.myhostname = lib.mkDefault "${cfg.localDomain}";
};
services.redis.servers.mastodon = lib.mkIf redisActuallyCreateLocally (
+1 -1
nixos/modules/services/web-apps/peertube.nix
···
services.postfix = lib.mkIf cfg.smtp.createLocally {
enable = true;
-
hostname = lib.mkDefault "${cfg.localDomain}";
+
settings.main.myhostname = lib.mkDefault "${cfg.localDomain}";
};
users.users = lib.mkMerge [
+8 -5
nixos/tests/alps.nix
···
enable = true;
enableSubmission = true;
enableSubmissions = true;
-
tlsTrustedAuthorities = "${certs.ca.cert}";
-
config.smtpd_tls_chain_files = [
-
"${certs.${domain}.key}"
-
"${certs.${domain}.cert}"
-
];
+
+
settings.main = {
+
smtp_tls_CAfile = "${certs.ca.cert}";
+
smtpd_tls_chain_files = [
+
"${certs.${domain}.key}"
+
"${certs.${domain}.cert}"
+
];
+
};
};
services.dovecot2 = {
enable = true;
+5 -5
nixos/tests/discourse.nix
···
services.postfix = {
enable = true;
-
origin = clientDomain;
-
relayDomains = [ clientDomain ];
-
config = {
+
settings.main = {
compatibility_level = "2";
-
smtpd_banner = "ESMTP server";
+
mydestination = [ clientDomain ];
myhostname = clientDomain;
-
mydestination = clientDomain;
+
origin = clientDomain;
+
relay_domains = [ clientDomain ];
+
smtpd_banner = "ESMTP server";
};
};
+12 -10
nixos/tests/mailman.nix
···
services.mailman.webHosts = [ "example.com" ];
services.postfix.enable = true;
-
services.postfix.destination = [
-
"example.com"
-
"example.net"
-
];
-
services.postfix.relayDomains = [ "hash:/var/lib/mailman/data/postfix_domains" ];
-
services.postfix.config.local_recipient_maps = [
-
"hash:/var/lib/mailman/data/postfix_lmtp"
-
"proxy:unix:passwd.byname"
-
];
-
services.postfix.config.transport_maps = [ "hash:/var/lib/mailman/data/postfix_lmtp" ];
+
services.postfix.settings.main = {
+
mydestination = [
+
"example.com"
+
"example.net"
+
];
+
relay_domains = [ "hash:/var/lib/mailman/data/postfix_domains" ];
+
local_recipient_maps = [
+
"hash:/var/lib/mailman/data/postfix_lmtp"
+
"proxy:unix:passwd.byname"
+
];
+
transport_maps = [ "hash:/var/lib/mailman/data/postfix_lmtp" ];
+
};
users.users.user = {
isNormalUser = true;
+4 -5
nixos/tests/matrix/synapse.nix
···
services.postfix = {
enable = true;
-
hostname = "${mailerDomain}";
-
# open relay for subnet
-
networksStyle = "subnet";
enableSubmission = true;
-
tlsTrustedAuthorities = "${mailerCerts.ca.cert}";
# blackhole transport
transport = "example.com discard:silently";
-
config = {
+
settings.main = {
+
myhostname = "${mailerDomain}";
+
# open relay for subnet
+
mynetworks_style = "subnet";
debug_peer_level = "10";
smtpd_relay_restrictions = [
"permit_mynetworks"
+1 -1
nixos/tests/parsedmarc/default.nix
···
services.postfix = {
enable = true;
origin = mailDomain;
-
config = {
+
settings.main = {
myhostname = mailDomain;
mydestination = mailDomain;
};
+7 -5
nixos/tests/postfix.nix
···
enable = true;
enableSubmission = true;
enableSubmissions = true;
-
tlsTrustedAuthorities = "${certs.ca.cert}";
-
config.smtpd_tls_chain_files = [
-
certs.${domain}.key
-
certs.${domain}.cert
-
];
+
settings.main = {
+
smtp_tls_CAfile = "${certs.ca.cert}";
+
smtpd_tls_chain_files = [
+
certs.${domain}.key
+
certs.${domain}.cert
+
];
+
};
submissionsOptions = {
smtpd_sasl_auth_enable = "yes";
smtpd_client_restrictions = "permit";
+1 -1
nixos/tests/public-inbox.nix
···
setSendmail = true;
#sslCert = "${tls-cert}/cert.pem";
#sslKey = "${tls-cert}/key.pem";
-
recipientDelimiter = "+";
+
settings.main.recipient_delimiter = "+";
};
environment.systemPackages = [
+1 -1
nixos/tests/rspamd.nix
···
};
services.postfix = {
enable = true;
-
destination = [ "example.com" ];
+
settings.main.mydestination = [ "example.com" ];
};
services.rspamd = {
enable = true;
+9 -7
nixos/tests/schleuder.nix
···
services.postfix = {
enable = true;
enableSubmission = true;
-
tlsTrustedAuthorities = "${certs.ca.cert}";
-
config.smtpd_tls_chain_files = [
-
"${certs.${domain}.key}"
-
"${certs.${domain}.cert}"
-
];
-
inherit domain;
-
destination = [ domain ];
+
settings.main = {
+
mydomain = domain;
+
destination = domain;
+
smtp_tls_CAfile = "${certs.ca.cert}";
+
smtpd_tls_chain_files = [
+
"${certs.${domain}.key}"
+
"${certs.${domain}.cert}"
+
];
+
};
localRecipients = [
"root"
"alice"
+1 -1
pkgs/by-name/po/postfix/update.sh
···
# Expect the text in format of '<a href="official/postfix-3.7.4.tar.gz">Source code</a> |'
# Stable release goes first.
-
new_version="$(curl -s http://cdn.postfix.johnriley.me/mirrors/postfix-release/index.html |
+
new_version="$(curl -s https://postfix-mirror.horus-it.com/postfix-release/index.html |
pcregrep -o1 '"official/postfix-([0-9.]+)[.]tar[.]gz">' | head -n1)"
update-source-version postfix "$new_version"