Commit Graph

924 Commits

Author SHA1 Message Date
Martin Weinelt 80d21ed7a1 Merge branch 'system-options' into 'master'
Introduce system name and domain options

See merge request simple-nixos-mailserver/nixos-mailserver!427
2025-07-09 11:20:39 +00:00
Martin Weinelt e9953aa154 ruff: reject implicit string concat
This is a common mistake that could have been prevented.

```
migrations/nixos-mailserver-migration-03.py:42:9: ISC002 Implicitly concatenated string literals over multiple lines
   |
40 |   def is_maildir_related(path: Path, layout: FolderLayout) -> bool:
41 |       if path.name in [
42 | /         "subscriptions"
43 | |         # https://doc.dovecot.org/2.3/admin_manual/mailbox_formats/maildir/#imap-uid-mapping
44 | |         "dovecot-uidlist",
   | |_________________________^ ISC002
45 |           # https://doc.dovecot.org/2.3/admin_manual/mailbox_formats/maildir/#imap-keywords
46 |           "dovecot-keywords",
   |
```
2025-07-09 03:59:54 +02:00
Martin Weinelt dda91cfc15 Merge branch 'patch-1' into 'master'
migrations: add missing comma in list

See merge request simple-nixos-mailserver/nixos-mailserver!429
2025-07-09 01:43:03 +00:00
Yureka c2df33f76a migrations: add missing comma in list 2025-07-09 01:39:51 +00: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 0aeb2849ad mail-check: fix format string 2025-07-08 04:39:36 +02:00
Martin Weinelt 47786932cb tests: fix deprecate machine config access 2025-07-08 03:58:37 +02:00
Martin Weinelt 358a44674e Merge branch 'flake-bump' into 'master'
flake.lock: Update

See merge request simple-nixos-mailserver/nixos-mailserver!428
2025-07-08 01:29:06 +00:00
Martin Weinelt 679bce8bbb flake.lock: Update
Flake lock file updates:

• Updated input 'git-hooks':
    'github:cachix/git-hooks.nix/623c56286de5a3193aa38891a6991b28f9bab056' (2025-06-11)
  → 'github:cachix/git-hooks.nix/16ec914f6fb6f599ce988427d9d94efddf25fe6d' (2025-06-24)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/3e3afe5174c561dee0df6f2c2b2236990146329f' (2025-06-07)
  → 'github:NixOS/nixpkgs/1fd8bada0b6117e6c7eb54aad5813023eed37ccb' (2025-07-06)
• Updated input 'nixpkgs-25_05':
    'github:NixOS/nixpkgs/fd487183437963a59ba763c0cc4f27e3447dd6dd' (2025-06-12)
  → 'github:NixOS/nixpkgs/29e290002bfff26af1db6f64d070698019460302' (2025-07-05)
2025-07-08 03:20:45 +02:00
Martin Weinelt 334e370c1f Merge branch 'dovecot-unit-name-migration' into 'master'
dovecot: use marker option as unit name migration indicator

See merge request simple-nixos-mailserver/nixos-mailserver!426
2025-07-06 23:24:27 +00: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 6004878dc6 Merge branch 'dovecot-migration-compat-fixup' into 'master'
dovecot: fix check for dovecot systemd unit name

See merge request simple-nixos-mailserver/nixos-mailserver!425
2025-07-06 03:22:41 +00: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 a40574beb5 Merge branch 'dovecot-migration-compat' into 'master'
dovecot: add compat shim for dovecot unit name migration

See merge request simple-nixos-mailserver/nixos-mailserver!424
2025-07-06 00:58:47 +00: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
Martin Weinelt b10c54606b migrations: ignore maildir when in folder layout
Otherwise we'd be tryhing to move the maildir into itself and error out.
2025-06-26 16:52:49 +02:00
Martin Weinelt c45b8a1253 Merge branch 'migrate-dovecot-control-files' into 'master'
migrations: also migrate dovecot control files

See merge request simple-nixos-mailserver/nixos-mailserver!423
2025-06-26 00:01:26 +00:00
Martin Weinelt d91d94be94 migrations: also migrate dovecot control files 2025-06-25 22:09:41 +02:00
Martin Weinelt b9e28e23af migrations: fix move of subscriptions
It is a file and we skip over files in the location I added it before.
2025-06-23 03:48:18 +02:00
Martin Weinelt 67f0b864cc migrations: also migrate subscriptions file in maildir migration
Otherwise users will be unsubscribed from all maildir folders.
2025-06-23 02:38:01 +02:00
Martin Weinelt cfb3136cf0 Merge branch 'fix-cannot-compare-null-with-an-integer' into 'master'
assertions: fix eval error when `mailserver.stateVersion` is unset (null)

See merge request simple-nixos-mailserver/nixos-mailserver!421
2025-06-22 13:25:22 +00: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 9d8caf5944 Merge branch 'dovecot-home-mail-migration' into 'master'
dovecot: migrate to dedicated homedir and separate maildir paths

Closes #324

See merge request simple-nixos-mailserver/nixos-mailserver!408
2025-06-21 10:23:58 +00:00
Martin Weinelt 3c1cff431c tests: test for the expected maildir and index dir locations
These are not ideal yet, but we should make them a fixture, so that we
are always aware what they are for the different supported setups.
2025-06-21 10:28:43 +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 601b33d2a7 tests/minimal: drop
We have other tests that are minimal, e.g. the multiple test. And this
test wasn't even hooked up in flake.nix, so I'm doubtful that we really
need it.
2025-06-19 01:04:56 +02:00
Martin Weinelt ed6d699eb4 Merge branch 'nuke-sha1' into 'master'
postfix: disable SHA1 for SMTP connections

See merge request simple-nixos-mailserver/nixos-mailserver!420
2025-06-18 16:54:39 +00:00
Martin Weinelt 64aca4f2ce postfix: disable SHA1 for SMTP connections 2025-06-18 06:58:42 +02:00
Martin Weinelt 217ec6008a Merge branch 'fast-tests' into 'master'
📉 Make tests fast

See merge request simple-nixos-mailserver/nixos-mailserver!419
2025-06-18 00:01:53 +00:00
Martin Weinelt 0774c93ae6 tests: make rspamd not block on dns queries
These will never suceed while running the tests in the Nix sandbox, and
skipping them leads to very noticable (~51%) speedups.

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 ± σ):     74.010 s ±  0.746 s    [User: 0.269 s, System: 0.266 s]
  Range (min … max):   72.814 s … 75.190 s    10 runs
```
2025-06-17 22:04:46 +02:00
Martin Weinelt f08ee8da38 tests: provide a second cpu core
Provides a small (~7.5%) reduction in the test runtime measured for the external
test:

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 ± σ):     140.647 s ±  1.092 s    [User: 0.331 s, System: 0.296 s]
  Range (min … max):   138.536 s … 142.298 s    10 runs
```
2025-06-17 22:04:08 +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 7405122dde Merge branch 'postfix-config' into 'master'
postfix: migrate more options to services.postfix.config

See merge request simple-nixos-mailserver/nixos-mailserver!418
2025-06-16 05:34:22 +00: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 5c1b9921e6 Merge branch 'suggest-dmarc' into 'master'
Suggest that folks enable DMARC reporting

See merge request simple-nixos-mailserver/nixos-mailserver!377
2025-06-15 23:15:19 +00:00
Martin Weinelt 67b0a7e946 Merge branch 'cleanup' into 'master'
treewide: remove global `with lib` and overly broad `with cfg`

See merge request simple-nixos-mailserver/nixos-mailserver!416
2025-06-15 03:48:33 +00: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 b555b3e8dc Merge branch 'cleanup' into 'master'
Format with nixfmt, drop redundant parentheses

See merge request simple-nixos-mailserver/nixos-mailserver!415
2025-06-15 02:45:24 +00:00
Martin Weinelt 1a7f3d718c treewide: reformat with nixfmt-rfc-style 2025-06-15 03:39:44 +02:00
Martin Weinelt 03433d472f flake.nix: enable nixfmt-rfc-style hook and formatter 2025-06-15 03:34:20 +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