Commit Graph

320 Commits

Author SHA1 Message Date
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
Martin Weinelt
027e6bcd76 postfix: don't cast message_size_limit to string
On unstable this will become a signed integer and there was never a good
reason for this to be a string.
2025-08-02 02:11:11 +02:00
Martin Weinelt
2b240501e0 Introduce system name and domain options
Bring them up from the DMARC reporting section to the mailserver toplevel
so they become reusable for the upcoming TLSRPT integration.

We default to the first domain in the domains option, if not set
explicitly, so that `systemDomain` doesn't become a blocker for existing
setups. We still encourage picking out the intended one, which is likely
the one used for the MX hostname.

This also simplifies the DMARC reporting configuration, which doesn't
need to be so fine-grained.

Co-Authored-By: Emily <git@emilylange.de>
2025-07-09 01:44:10 +02:00
Martin Weinelt
d6d2053b80 dovecot: use marker option as unit name migration indicator
In nixpkgs we expose `services.dovecot.hasNewUnitName` option that can be
safely inspected to understand that whether to use the `dovecot` systemd
service name instead of `dovecot2`.
2025-07-07 01:10:19 +02:00
Martin Weinelt
f9a52ca4b5 dovecot: fix check for dovecot systemd unit name
and migrate the preStart script in systemd.nix as well.
2025-07-06 05:18:01 +02:00
Martin Weinelt
b38dc8085c dovecot: add compat shim for dovecot unit name migration
In nixpkgs I renamed dovecot2 to dovecot and made dovecot2 an alias, so
adding the script to the alias does us no good.
2025-07-06 02:52:31 +02:00
emilylange
6ef1eb9ce1 assertions: fix eval error when mailserver.stateVersion is unset (null)
Eval does not stop on the first assertion failure it encouters.
Instead, it tries to evaluate all assertions and returns with a list of
those that failed.

This means our very top `config.mailserver.stateVersion != null`
assertion does not gate against any other assertions trying to compare
null against an integer.

The error prior to this commit can be reproduced by removing
`mailserver.stateVersion = 999;` in tests/lib/config.nix and then trying
to evaluate any of the tests:

~~~bash
# nix eval --raw .#checks.x86_64-linux.internal-unstable
error:
       … while evaluating the attribute 'outPath'
         at /nix/store/syvnmj3hhckkbncm94kfkbl76qsdqqj3-source/lib/customisation.nix:421:7:
          420|         drv.drvPath;
          421|       outPath =
             |       ^
          422|         assert condition;

       … while calling the 'getAttr' builtin
         at «internal»:1:500:
       (stack trace truncated; use '--show-trace' to show the full trace)

       error: cannot compare null with an integer
~~~
2025-06-21 20:15:46 +02:00
Martin Weinelt
f25495cabf dovecot: fix custom index dir configuration for ldap users 2025-06-21 09:47:03 +02:00
Martin Weinelt
62ea8a7e00 dovecot: migrate to dedicated homedir and separate maildir paths
Per the dovecot documentation[0] we were previously running with an
unsupported home directory configuration, because we shared them among
all virtual users at /var/vmail.

After resolving this by creating per user home directories at
/var/vmail/%{domain}/%{user} this now also overlaps with the location of
the Maildir, which is not recommended.

As a result we now need to migrate our Maildirs into
/var/vmail/%{domain}/%{user}/mail, for which a small shell script is
provided as part of this change.

The script is included in the documentation because we cannot provide it
in time for users, because they might already be seeing the relevant
assertion and there is no safe waiting period that would allow us to skip
shipping it like that.

[0] https://doc.dovecot.org/2.3/configuration_manual/mail_location/
2025-06-21 09:46:32 +02:00
Martin Weinelt
64aca4f2ce postfix: disable SHA1 for SMTP connections 2025-06-18 06:58:42 +02:00
Martin Weinelt
cf6ef5e9ca Create per service debug logging toggles
Enabling the rspamd debug log drowns out everything else and should be
selected explicitly as needed.

The external test does not require it and removing it makes it much
(~40.5%) faster, since it now does not block on terminal output anymore.

Before:
```
Benchmark 1: nix build .#hydraJobs.x86_64-linux.external-unstable --rebuild
  Time (mean ± σ):     151.737 s ±  1.074 s    [User: 0.310 s, System: 0.289 s]
  Range (min … max):   150.321 s … 153.512 s    10 runs
```

After:
```
Benchmark 1: nix build .#hydraJobs.x86_64-linux.external-unstable --rebuild
  Time (mean ± σ):     90.531 s ±  0.557 s    [User: 0.054 s, System: 0.045 s]
  Range (min … max):   89.579 s … 91.278 s    10 runs
```
2025-06-17 22:02:31 +02:00
Martin Weinelt
6652b57dda postfix: rearrange smtpd_tls_chain_files option 2025-06-16 07:27:03 +02:00
Martin Weinelt
c8f809fa76 postfix: migrate more options to services.postfix.config
I'm working on deprecating the top-level options, that configure main.cf
upstream in nixpkgs. With this change we stay ahead of the curve.

The `networks_style` option already defaults to `host` since Postfix 3.0,
so I dropped the setting.

```
$ postconf -d | grep networks_style
mynetworks_style = ${{$compatibility_level} <level {2} ? {subnet} : {host}}
````
2025-06-16 07:03:49 +02:00
Martin Weinelt
a2152f9807 treewide: remove overly broad with cfg
Makes it really hard to follow references and we were being explicit in
most places already anyway.
2025-06-15 05:39:20 +02:00
Martin Weinelt
fb56bcf747 treewide: remove global with lib
Instead inherit required functions from lib.
2025-06-15 05:08:47 +02:00
Martin Weinelt
1a7f3d718c treewide: reformat with nixfmt-rfc-style 2025-06-15 03:39:44 +02:00
Martin Weinelt
c7497cd5f6 treewide: remove redundant parenthesis in nix code 2025-06-15 03:28:48 +02:00
Martin Weinelt
5f592b5960 Merge branch 'crypto-v2' into 'master'
postfix, dovecot: modernize and comment TLS settings

See merge request simple-nixos-mailserver/nixos-mailserver!413
2025-06-14 22:52:29 +00:00
Martin Weinelt
21ce4b4ff8 dovecot: disable Diffie-Hellman support
Recommended in the modern recommendation by Mozilla. Support for elliptic
curves is widespread and they are much faster.
2025-06-15 00:22:58 +02:00
Martin Weinelt
efebf59b13 dovecot: configure preferred elliptic curves 2025-06-15 00:22:57 +02:00
Martin Weinelt
4fd9508d41 postfix: drop tls_random_source config
The setting already defaults to /dev/urandom.
2025-06-15 00:22:57 +02:00
Martin Weinelt
3828b00dea postfix: configure preferred curves and disable FFDHE
This aligns with the intermediate configuration recommended by Mozilla.
2025-06-15 00:22:57 +02:00
Martin Weinelt
e27326d317 postfix: refactor and prune TLS settings
- Groups settings between server and client
- Uses a range comparator for supported TLS versions
- Prune excluded primitives to what affects the supported TLS versions
2025-06-15 00:22:57 +02:00
Martin Weinelt
23cc9a3996 Merge branch 'postfix-cert-key' into 'master'
postfix: configure cert/key using smtpd_tls_chain_files

Closes #183

See merge request simple-nixos-mailserver/nixos-mailserver!410
2025-06-14 12:47:58 +00:00
Martin Weinelt
3f1c6960d3 Merge branch 'smptp-smuggling-cleanup' into 'master'
postfix: remove option to toggle SMTP smuggling workarounnd

See merge request simple-nixos-mailserver/nixos-mailserver!411
2025-06-12 22:57:43 +00:00
Martin Weinelt
f1bd4b8215 postfix: remove option to toggle SMTP smuggling workarounnd
It has been default enabled since Postfix 3.9 and can still be configured
from the NixOS option mentioned in the removal warning.

Removing the option makes our interface leaner.

Information is based on https://www.postfix.org/smtp-smuggling.html#long.
2025-06-13 00:21:16 +02:00
Martin Weinelt
e540dc864c postfix: configure cert/key using smtpd_tls_chain_files
The sslCert and sslKey options are going away, because they do too much,
e.g. provision the keypair for client certificate authentication, which
is not at all what we want or need.
2025-06-12 01:05:51 +02:00
Martin Weinelt
f9b15192b8 postfix: allow client to select the preferred cipher
As long as all cipher we support are considered safe we can allow clients
to select one that suits them best.
2025-06-03 00:45:12 +02:00
Martin Weinelt
8c835feaa7 docs/migrations: Improve title scoping for LDAP home dir migration 2025-06-02 04:31:41 +02:00
Martin Weinelt
ea1b0f8e2b assertions: guard by enable flag and reformat
None of these should trigger when you've not enabled mailserver.
2025-05-30 18:28:16 +02:00
Charlotte Van Petegem
519a85a801 Fix assertion for ldap mail directory 2025-05-30 12:49:02 +00:00
Martin Weinelt
ffd0e6f8f2 Merge branch 'dont-hardcode-ldap-home-base' into 'master'
dovecot: respect the mailDirectory base for LDAP home directories

See merge request simple-nixos-mailserver/nixos-mailserver!400
2025-05-29 21:14:25 +00:00
Martin Weinelt
7cb61e6e3a dovecot: respect the mailDirectory base for LDAP home directories
This change is safe, if you have not altered the default value of the
 `mailserver.mailDirectory` setting.
2025-05-29 23:10:33 +02:00
Martin Weinelt
233c5e1a70 dovecot: remove workaround for services.dovecot2.modules removal 2025-05-29 14:06:34 +02:00
Martin Weinelt
792225e256 Introduce stateVersion concept
With upcoming changes to the dovecot home and maildirectories we need to
introduce a way to nudge users to inform themselves about manual
migration steps they might need to carry out.

The idea here is to allow us to safely make breaking changes and notify
the user of required migration steps at eval time, so they can make the
necessary changes in time.
2025-05-27 23:54:15 +02:00
euxane
0cbdf465e4 dovecot/fts: warn on stopwords filter with multiple languages 2025-05-19 16:45:09 +02:00
euxane
2ed7a94782 dovecot/fts: switch to fts-flatcurve
This switches the full-text search plugin from fts-xapian to
fts-flatcurve, the now preferred indexer still powered by Xapian,
which will be integrated into Dovecot core 2.4.

This sets a sane minimal configuration for the plugin with
international language support.

The plugin options marked as "advanced" in Dovecot's documentation
aren't re-exposed for simplicity. They can nevertheless be overridden
by module consumers by directly setting keys with
`services.dovecot2.pluginSettings.fts_*`.

The `fullTextSearch.maintenance` option is removed as the index is now
incrementally optimised in the background.

GitLab: closes https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/issues/239
2025-05-19 16:45:09 +02:00
Martin Weinelt
aa8366d234 treewide: remove dead nix references 2025-05-15 16:41:30 +02:00
Martin Weinelt
9a6190ceea rspamd: remove indirection in path to runtime directory 2025-05-15 16:29:06 +02:00
Martin Weinelt
1e51a503b1 dovecot: drop unused pipe scripts
Leftovers from d507bd9c95
2025-05-15 16:29:05 +02:00
Martin Weinelt
dd83a2c7ad dovecot: rename sieve bayes/ham learning script
Updates the spamassasin reference to talk about rspamd.
2025-05-15 16:16:17 +02:00
Martin Weinelt
a1ff289bf9 dovecot: migrate queue-status to UNIX domain socket 2025-05-07 18:00:53 +02:00
lewo
7bb0f43503 Merge branch 'dane-lookups' into 'master'
postfix: Support opportunistic DANE TLS

See merge request simple-nixos-mailserver/nixos-mailserver!389
2025-05-07 07:02:02 +00:00