Commit Graph

362 Commits

Author SHA1 Message Date
Martin Weinelt 20f0e767cb users: remove unused common import 2026-03-24 01:58:37 +01:00
Martin Weinelt e13736db67 Group storage and vmail user options at mailserver.storage
Create a nicer option structure that deals with the mail storage and its
owner, uid, group and gid. Also includes the directory layout as a
property of how mails are stored..
2026-03-24 01:57:31 +01:00
Martin Weinelt 6826d11c58 users: remove global with config.mailserver 2026-03-24 01:35:48 +01:00
Martin Weinelt e9337b346f Rename mailserver.loginAccounts to mailserver.accounts
The "login" prefix makes this option more confusing rather than clearer,
because what other account types are there? LDAP ones for example, but
you can login with those too, so the prefix is pointless.
2026-03-24 01:35:48 +01:00
Martin Weinelt 4f3d21f386 dovecot: fix storage basedir regression in ldap home
During the rewrite of the LDAP userdb field lookups the default path for
the mail storage directory accidentally leaked into the home directory
path.
2026-03-24 01:11:09 +01:00
Martin Weinelt 31c7607ef4 Rename extraVirtualAliases to aliases and update description
The extra and virtual parts are redundant and Postfix specific and not
at all required. Compare forwards for example.
2026-03-23 16:26:32 +01:00
Martin Weinelt 23364b04e8 ldap: allow local accounts and aliases with ldap enabled
In conflicts between local addresses and LDAP addresses the local one
will always take priority in mail routing.

This is something we now document and guarantee through tests.
2026-03-23 16:25:50 +01:00
Martin Weinelt 86d256870b postfix: prune virtual delivery agent settings
We exclusively rely on delivery via dovecot-lmtp, so these are redundant.
2026-03-23 13:23:01 +01:00
Martin Weinelt 5d715c4ce8 assertions: adjust docs url for migration #4 2026-03-22 15:03:18 +01:00
Martin Weinelt 98acd76bbf Add migration story for LDAP UUID home directories 2026-03-21 22:34:50 +01:00
Martin Weinelt 63365fb1a8 postfix: document ldap map purposes 2026-03-21 01:38:04 +01:00
Martin Weinelt 762f553643 ldap: make uid the default account name
I fail to understand how mail became the uidAttribute way back when LDAP
support was introduced, but it was unintentional and clearly a mistake.

The uid attribute is the standard system login name per RFC4519 2.39 and
what we default to going forward.
2026-03-21 01:38:04 +01:00
Martin Weinelt a87d01ea79 ldap: reorganize and regroup options
Now that we have more experience with how we use the LDAP module options
we can make smarter decisions in how to organize them. We can also
explain much better what these options imply, which results in more
extensive option documentation.
2026-03-21 01:38:04 +01:00
Martin Weinelt 609fd80936 dovecot: make sure vid/gid are not overridable
The only storage scheme we support is a single declarative user with
fixed uid/gid. The default_fields are overridable if these fields leak
in from LDAP, so promote them to override_fields instead.
2026-03-21 00:47:59 +01:00
Martin Weinelt af480dba87 ldap: replace pass_attrs option with password attr option
The passdb only checks password access, so instead of customizing the
whole pass_attrs setting we now allow customization of the password field
used.
2026-03-21 00:47:59 +01:00
Martin Weinelt 091eda1ed2 ldap: migrate to UUID based Dovecot home directories
The LDAP support was not in a good shape when it was merged. This is a
breaking change and course correction to apply best practices going
forward.

This fixes various issues experienced with the Dovecot LDAP home
directory.

The gravest issue is that the `homeDirectory` attribute from
the `posixAccount` schema would overwrite the Dovecot home directory and
cause permission errors. This was possible because we defined the home
variable in `default_fields` that is inherently mutable and just a preset
if no other value gets transmitted from LDAP. This did not surface in
tests, because our LDAP schema was too minimal compared to a common
production dataset.

The most annoying issue and the actual breaking change is that we now
default to UUID based home directories. Every entry in an IDM that
supports LDAP comes with a unique identifier that does not change upon
account name changes. We want those to enable simple account name
migrations that don't require any manual data migration.

To migrate existing dovecot home directories a migration script is
included, which will be backported to the 25.11 release, so the migration
can already be started from the previous release version.
2026-03-21 00:47:59 +01:00
lennart 5544b0fa70 Add rejectSenderMessage option 2026-03-20 10:16:09 +00:00
Martin Weinelt 3da442701a dovecot: restore compat for RSA key material
In TLS1.2 available cipher suites depend on the available key material,
so the last round of cipher suites updates broke TLS1.2 support with RSA
key pairs.

The NixOS ACME module has been defaulting to EC256 (and earlier EC384)
key material, so I assume this did not affect many setups in practice.
2026-03-18 14:06:10 +01:00
Martin Weinelt 33b8946c87 Deprecate borgbackup, rsnapshot, monit integrations
The plan is to start warning now with the intent to remove these
integrations before the 26.11 release.
2026-03-14 04:30:39 +01:00
Martin Weinelt 271e6e54fd Reorganize imports
With the growing number of option refactors centralize the module import
within the mail-server directory.

Also group deprecations by release, so we can eventually yank them in
bulk after a while.
2026-03-12 13:21:51 +01:00
Martin Weinelt 06cc71c76e treewide: add language annotations for inline code
Instruct editors to correctly highlight and evaluate inline code blocks.
2026-03-12 12:59:03 +01:00
Martin Weinelt 6ff4a50f02 Add support for DKIM key management
After bumping the generation of new DKIM keys to RSA 2048 in NixOS 25.11
key rotation for existing users could not be done safely.

To resolve this situation we now support multiple generations of
selectors per domain to enable proper DKIM key transitions as described
in RFC6376 3.1. The added documentation introduces and motivates DKIM
and guides the user through a DKIM key rotation.

Additionally, DKIM key material can now also be treated as a managed
secrets when autogenerated state on the mail server host is undesirable.

This change is fully backwards compatible in behavior and will continue
to use the previously generated DKIM key without any additional
configuration up until the point when DKIM selectors are configured
explicitly.
2026-03-11 22:37:49 +01:00
Martin Weinelt 1c57aab586 treewide: fix typos and other minor issues 2026-03-11 01:50:14 +01:00
Ryan Gibb 12ae5dd89b support unhashed password files 2026-03-05 11:06:01 +00:00
teutat3s 9b90a9837a rspamd: fix duplicate systemd dependencies
These are also declared in mail-server/systemd.nix.
2025-12-28 20:40:33 +01:00
Martin Weinelt 3579eb0001 dovecot: restrict TLS cipher suites 2025-12-19 04:00:47 +01:00
Martin Weinelt 1415623586 dovecot: support X25519MLKEM768 hybrid kex 2025-12-19 03:13:47 +01:00
Martin Weinelt e437760341 treewide: replace/remove dovecot2 service name
The unit name is now dovecot.service.
2025-12-19 02:52:55 +01:00
Martin Weinelt 33ba1ff52b Switch to NixOS ACME module for certificate management
Drop most of the existing certificate handling, because we're effectively
duplicating functionality that NixOS offers for free with better
design, testing and maintainance than what we could provide downstream.

The remaining two options are to reference an
existing `security.acme.certs` configuration through
`mailserver.x509.useACMEHost` or to provide existing key material via
`mailserver.x509.certificateFile` and `mailserver.x509.privateKeyFile`.

Support for automatic creation of self-signed certificates has been
removed, because it is undesirable in public mail setups.

The updated setup guide now displays the recommended configuration that
relies on the NixOS ACME module, but requires further customization to
select a suitable challenge.

Co-Authored-By: Emily <git@emilylange.de>
2025-12-19 02:36:28 +01:00
Martin Weinelt e04e5b7ea6 assertions: bump mailserver version for release check 2025-11-29 02:43:16 +01:00
Martin Weinelt cbdf90f639 rspamd: fix DKIM signing for subdomains
With the eSLD normalization feature in rspamd subdomains actually use the
DKIM key for their parent domain, which simplifies the setup if you serve
multiple subdomains.

We however currently create DKIM key pairs for every given domain
name, no matter if it is a second-level domain or subdomain for one, so
disabling eSLD normalization aligns with the current intent behind our
configuration.

In the future it would be nice if we could reuse the parent domain DKIM
key for all its subdomains, but that requires some thought on how to
achieve that normalization in nixos-mailserver first.

Reapplies 1a3a618a30 to the correct
configuration file.
2025-11-16 19:29:16 +01:00
Martin Weinelt b88e6182f0 Revert "rspamd: fix DKIM signing for subdomains"
This reverts commit 1a3a618a30.

This went into the wrong configuration file unfortunately
2025-11-16 19:26:22 +01:00
Martin Weinelt b946f74261 mail-server/common: fix eval
CI has a shitty failure mode where jobs that don't eval get removed and
hydra-cli will still exit cleanly.
2025-11-16 18:41:47 +01:00
Martin Weinelt 1cb4295b74 Remove dovecot service name compat code 2025-11-16 18:18:22 +01:00
Martin Weinelt db66559815 Merge branch 'srs' into 'master'
Add support for sender rewriting for forwards using postsrsd

See merge request simple-nixos-mailserver/nixos-mailserver!431
2025-11-16 14:00:07 +00:00
Martin Weinelt 1a3a618a30 rspamd: fix DKIM signing for subdomains
With the eSLD normalization feature in rspamd subdomains actually use the
DKIM key for their parent domain, which simplifies the setup if you serve
multiple subdomains.

We however currently create DKIM key pairs for every given domain
name, no matter if it is a second-level domain or subdomain for one, so
disabling eSLD normalization aligns with the current intent behind our
configuration.

In the future it would be nice if we could reuse the parent domain DKIM
key for all its subdomains, but that requires some thought on how to
achieve that normalization in nixos-mailserver first.
2025-11-16 14:55:41 +01:00
Martin Weinelt eeda8ba39e Add support for sender rewriting using postsrsd
With SRS we support forwarding of mails without (fully) breaking SPF
alignment.
2025-11-11 13:45:03 +01:00
Martin Weinelt edb7b661e4 postfix: resolve main/master option deprecation 2025-11-10 02:56:51 +01:00
Martin Weinelt b99f353ab8 postfix: unquote tls_config_file value
This can now be a path type due to changes applied to nixos unstable.
2025-11-10 02:51:46 +01:00
Martin Weinelt a1532a552f postfix: enable X25519MLKEM768 key exchange
This migrates the key exchange curve group configuration into the OpenSSL
configuration format, which is the only path forward to configure these.

We now prefer a hybrid key exchange for TLS handshake and as a client
we'll send key shares for that and pure X25519, while keeping backwards-
compat for P256 and P384.

The statistics for my personal mail server over the last month show a
clear trend for X25519 key exchanges:

    156 secp384r1
    225 secp256r1
    19541 x25519
2025-11-10 00:31:43 +01:00
Martin Weinelt 3555a546ab Add support for SMTP TLS reports
When enabled the tlsrpt services will send out aggregated reports about
TLS connections the local Postfix made to interested parties, who set up
a `_smtp._tls` TXT record with a rua attribute.

Introduces mailserver.systemContact to specify an administrative contact
advertised in these automated reports.
2025-11-08 22:39:29 +01:00
Martin Weinelt 0812ca1e48 Use postfix-tlspol for DANE/MTA-STS policy lookups
Postfix with plain DANE only secures domains that configure DNSSEC and
publish TLSA records. With postfix-tlspol we support MTA-STS protected
connections and get caching for its policy results.

Finally, we use this as a stepping stone to build TLSRPT support on top.
2025-11-08 15:49:34 +01:00
Martin Weinelt 6dbbac29f9 Check release version compat
To move into a better position to align this project with nixpkgs
unstable breaking changes we now default to require a matching nixpkgs
release.
2025-11-08 13:39:33 +01:00
Antoine Eiche 9b57654b31 Only set acme.extraDomainNames when the certificate scheme is acme
Otherwise, certificate domains appear twice in the certificate, since
they are added by the acme module and the nginx module.
2025-10-02 09:36:14 +02:00
Giel van Schijndel bf2b313365 fix(acme): request certificates for the extra domains too
Instead of just making it _possible_ to perform the name validation...
2025-09-28 19:03:32 +02:00
Martin Weinelt 1a2d7a4bf5 rspamd: restrict addresses we disable checks for to localhost
By default this includes private network subnets, but those should really
use authentication instead, if they want to skip checks.

Closes: #326
2025-08-25 04:12:30 +02:00
Martin Weinelt fc955088e3 Respect configureLocally flag for redis 2025-08-08 00:01:45 +02:00
Martin Weinelt 43f87f5520 Tokenize dmarc reporter commandline 2025-08-08 00:01:45 +02:00
Martin Weinelt aa06b2f489 Allow AF_UNIX sockets for dmarc reporter and allow group access
This is required to use redis over UNIX domain sockets.
2025-08-08 00:01:45 +02:00
Martin Weinelt b76a547bec treewide: reformat with nixfmt 1.0.0 2025-08-02 02:19:15 +02:00