Commit graph

127 commits

Author SHA1 Message Date
Martin Weinelt cdcb6d35ec
nixos/postfix: fix typo in networksStyle option rename 2025-09-30 17:14:23 +02:00
Anton Mosich 608ba7a407
modules/postfix: fix manpage number in option description 2025-09-07 12:21:08 +02:00
Sandro Jäckel 1aacf9c84a
treewide: use lib.getExe' for config.services.postfix.package 2025-09-03 13:12:31 +02:00
Sandro Jäckel b5b97a6670
nixos/postfix: add a package option and use it treewide 2025-09-02 18:01:01 +02:00
Stefan Frijters 81e8a2a5f3
nixos/postfix: tweak confusing migration suggestions 2025-08-05 10:26:48 +02:00
Stefan Frijters 0f63119209
nixos/postfix: fix typo in migration suggestion 2025-08-05 10:26:42 +02:00
Martin Weinelt 7f52135a59
nixos/postfix: fold main and master config into settings attribute 2025-07-28 17:03:08 +02:00
Martin Weinelt 791dcff3a9
nixos/postfix: add maintainers 2025-07-28 16:42:18 +02:00
Martin Weinelt 23efadb26b
nixos/postfix: remove extraConfig option
The freeform type config option covers all supported values.
2025-07-28 16:42:17 +02:00
Martin Weinelt 918785c07f
nixos/postfix: advertise message_size_limit option 2025-07-28 16:42:17 +02:00
Martin Weinelt 03950314c6
nixos/postfix: migrate options in freeform config options
This is a first step that reduces the intransparent configuration aspects
by migrating relevant options from `service`postfix` into the `config`
option that represents the `main.cf` file.

Not all options were migrated since Postfix provides reasonable defaults,
e.g. `myorigin` defaults to `$myhostname`, so it is rarely needed.

The `inet_protocols` integration with `networking.enableIPv6` was also
a thing I removed, because Postfix is capable of understand what inet
protocols are available at runtime, so I concluded it a niche option.

Every option on the `config` freeform setting now also references the
upstream documentation, which provides a great number of examples and is
always worth a look.
2025-07-28 16:41:59 +02:00
Martin Weinelt 7d6c8e24ce
nixos/postfix: improve option documentation for service toggles
In particular we now explain what port the service listens on and what
protocol to expect. Update the RFC8341 recommendation to discourage
submission and recommend submissions.
2025-07-28 16:31:19 +02:00
Wolfgang Walther 5a0711127c
treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Martin Weinelt fbc56958af
nixos/pfix-srsd: migrate postfix integration from postfix module
The postfix module is too big to host every individual integration option
and moving it here has no downside.
2025-07-15 22:04:28 +02:00
Quinn Flavel f2eda9a6a9
nixos/postfix: fix in secure systemd-nspawn containers 2025-07-12 21:28:15 +00:00
Martin Weinelt 3cb8d47c1a
nixos/postfix: replace sslCert and sslKey options
There exist multiple issues with these options, for example they are not
introspectable, since the values are configured in the config part of the
module.

Also the keypair is always configured for both server and client usage,
which is really surprising. The postfix docs even advise against setting
up client certificates, if they aren't required. [1]

The replacements are the `smtpd_tls_chain_files` for server usage and
`smtp_tls_chain_files` for client usage, which are the prefered way to
configure keys and certificates since Postfix 3.4.0. [2]

[1] https://www.postfix.org/postconf.5.html#smtp_tls_cert_file
[2] https://www.postfix.org/postconf.5.html#smtpd_tls_cert_file
2025-06-13 19:53:33 +02:00
Martin Weinelt 951a020ed4
nixos/postfix: make config freeform and drop null values
This is the basis for defining common options on
`services.postfix.config` while not rendering them, when they're set to
`null`.
2025-06-13 19:53:32 +02:00
Pol Dellaiera a22c7aad11
Revert "nixos/postfix: add slow domain" 2025-06-04 08:15:52 +02:00
liberodark b9ecd30d81 nixos/postfix: add slow domain 2025-05-27 14:44:43 +02:00
h7x4 ab0564bd10
treewide: add documentation for nixos systemd units 2025-03-12 18:00:38 +01:00
shelvacu 1a4575f9db
nixos/modules: Add security.pki.caBundle option and make all services use it for CA bundles (#352244)
Previously some modules used `config.environment.etc."ssl/certs/ca-certificates.crt".source`, some used `"/etc/ssl/certs/ca-certificates.crt"`, and some used `"${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"`. These were all bad in one way or another:

- `config.environment.etc."ssl/certs/ca-certificates.crt".source` relies on `source` being set; if `text` is set instead this breaks, introducing a weird undocumented requirement
- `"/etc/ssl/certs/ca-certificates.crt"` is probably okay but very un-nix. It's a magic string, and the path doesn't change when the file changes (and so you can't trigger service reloads, for example, when the contents change in a new system activation)
- `"${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"` silently doesn't include the options from `security.pki`

Co-authored-by: Shelvacu <git@shelvacu.com>
2025-03-08 08:41:08 +00:00
Peder Bergebakken Sundt 953f72e76e nixos/*: tag manpage references 2025-01-27 02:47:01 +01:00
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00
Rouven Seifert 2a8f335355
nixos/postfix: add missing mkDefault for smtpd tls config 2024-09-22 23:09:55 +02:00
Felix Buehler e2ff604f85 nixos/services.postfix: remove with lib; 2024-08-27 20:57:37 +02:00
Sandro Jäckel 2862350f61
nixos/postfix: allow int in config
eg. unknown_local_recipient_reject_code can be set to 550 which toString
can stringify
2024-08-05 21:18:40 +02:00
stuebinm 6afb255d97 nixos: remove all uses of lib.mdDoc
these changes were generated with nixq 0.0.2, by running

  nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix

two mentions of the mdDoc function remain in nixos/, both of which
are inside of comments.

Since lib.mdDoc is already defined as just id, this commit is a no-op as
far as Nix (and the built manual) is concerned.
2024-04-13 10:07:35 -07:00
Guillaume Girol 17fc67eb2e
Merge pull request #255464 from georgyo/postfix-dont-use-file-ownership
nixos/postfix: postalias should not use source file permissions
2023-12-31 15:20:48 +01:00
George Shammas 142d83f90e
nixos/postfix: postalias should not use source file permissions
Our postfix-setup service ensures that the directory is only writable by root.

postalias by default drops permissions to the user of the source file. In the
case of NixOS that file is in the nix store and thus always owned by root and
everything works.

The problem is that when using a nixos-container with user namespaces (`-U`)
then the nix store is owned by nobody/nogroup, and postfix-setup.service will be
unable to create or modify `aliases.db`.

Since the file would otherwise be owned by root, we should tell postfix to not
assume the user and permissions of the `aliases` file by setting -o and -p

From postalias(1)

> -o Do not release root privileges when processing a non-root input file. By
> default, postalias(1) drops root privileges and runs as the source file owner
> instead.

> -p Do not inherit the file access permissions from the input file when
> creating a new file. Instead, create a new file with default access
> permissions (mode 0644).
2023-09-16 08:22:45 -04:00
Tom Fitzhenry dd1b3b077a nixos/postfix: add systemd hardening directives
Inspired by
a9ccc48242/mail-mta/postfix/files/postfix.service

This decreases the systemd-analyze exposure level from UNSAFE to MEDIUM:

```
$ systemd-analyze security --offline=true postfix-hardened.service | grep Overall
→ Overall exposure level for postfix-hardened.service: 6.2 MEDIUM 😐

$ systemd-analyze security --offline=true postfix-original.service | grep Overall
→ Overall exposure level for postfix-original.service: 9.6 UNSAFE 😨
```
2023-09-16 06:37:00 +10:00
Felix Buehler 327b0cff7a treewide: use more lib.optionalString 2023-04-07 13:38:33 +02:00
Stefan Frijters 11fa179533
nixos/postfix: restrict inet_protocols to ipv4 when ipv6 is disabled
In the previous state, postfix would still try to use IPv6 addresses,
even when it is disabled in the global networking config.

Cf. https://www.postfix.org/postconf.5.html:

  With Postfix 2.8 and earlier the default is "ipv4". For backwards compatibility with these releases,
  the Postfix 2.9 and later upgrade procedure appends an explicit "inet_protocols = ipv4" setting to
  main.cf when no explicit setting is present.
  This compatibility workaround will be phased out as IPv6 deployment becomes more common.

  inet_protocols = ipv4
  inet_protocols = all (DEFAULT)
  inet_protocols = ipv6
  inet_protocols = ipv4, ipv6

So setting it to 'all' conditionally does not help, as we are now on version 3.x.
2023-02-03 11:29:24 +01:00
figsoda 6bb0dbf91f nixos: fix typos 2022-12-17 19:31:14 -05:00
pennae 515c4727fa nixos/*: md-"convert" empty descriptions
for some reason these are not picked up properly by nix-doc-munge, so
we'll do this instead.
2022-08-31 16:32:54 +02:00
pennae 9547123258 nixos/*: convert internal option descriptions to MD
we'll have to do it eventually, may as well be now.
2022-08-31 16:32:54 +02:00
pennae 6039648c50 nixos/*: automatically convert option docs 2022-08-19 22:40:58 +02:00
pennae b51f8036c2 nixos/*: use properly indented strings for option docs
using regular strings works well for docbook because docbook is not as
whitespace-sensitive as markdown. markdown would render all of these as
code blocks when given the chance.
2022-08-19 22:40:58 +02:00
pennae 087472b1e5 nixos/*: automatically convert option docs 2022-08-06 20:39:12 +02:00
pennae 423545fe48 nixos/*: normalize manpage references to single-line form
now nix-doc-munge will not introduce whitespace changes when it replaces
manpage references with the MD equivalent.

no change to the manpage, changes to the HTML manual are whitespace only.
2022-08-05 18:34:50 +02:00
pennae 2e751c0772 treewide: automatically md-convert option descriptions
the conversion procedure is simple:

 - find all things that look like options, ie calls to either `mkOption`
   or `lib.mkOption` that take an attrset. remember the attrset as the
   option
 - for all options, find a `description` attribute who's value is not a
   call to `mdDoc` or `lib.mdDoc`
 - textually convert the entire value of the attribute to MD with a few
   simple regexes (the set from mdize-module.sh)
 - if the change produced a change in the manual output, discard
 - if the change kept the manual unchanged, add some text to the
   description to make sure we've actually found an option. if the
   manual changes this time, keep the converted description

this procedure converts 80% of nixos options to markdown. around 2000
options remain to be inspected, but most of those fail the "does not
change the manual output check": currently the MD conversion process
does not faithfully convert docbook tags like <code> and <package>, so
any option using such tags will not be converted at all.
2022-07-30 15:16:34 +02:00
Alyssa Ross 27530ba856
nixos/postfix: make postfix-setup RemainAfterExit
Otherwise, it wouldn't get restarted when a new system configuration
was activatad, so the Postfix configuration wouldn't be updated.

Fixes: fb2fa1b50f ("nixos/postfix: pull setup into its own unit")
2022-05-22 10:33:22 +00:00
Alyssa Ross fb2fa1b50f
nixos/postfix: pull setup into its own unit
Consider a service that generates postfix lookup tables with
postmap(1), like Mailman.  It needs the Postfix configuration file to
exist, but Postfix qmgr needs all the lookup tables its configured
with to exist before it starts.  So the service that runs postmap
needs to run after the Postfix configuration and directory structure
is generated, but before Postfix itself is started.  To enable this,
we split Postfix into two units: a oneshot unit that sets up the
configuration, and a longrun unit that supervises the Postfix
daemons.  The postmap services can then be inserted in between these
two units.
2022-04-05 10:24:34 +00:00
Travis Athougies 82037871bb
nixos/postfix: Use better types for submissionOptions and submissionsOptions (#138205) 2021-11-12 17:28:39 +01:00
Michele Guerini Rocco e99b3f242c
Merge pull request #140359 from rnhmjoj/setgid-nobody
nixos: make setgid wrappers root-owned
2021-10-06 08:36:35 +02:00
Naïm Favier 2ddc335e6f
nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
rnhmjoj 31790c81dc
nixos: make setgid wrappers root-owned 2021-10-03 11:44:57 +02:00
V cc49c13a6b nixos/postfix: Fix virtual alias manpage section
virtual(8) is for virtual mailboxes, not aliases.
2021-09-27 06:39:27 +02:00
rnhmjoj 8f76a6eefc
nixos: add implict security.wrappers options
This is to keep the same permissions/setuid/setgid as before the change
in security.wrappers defaults.
2021-09-13 13:48:13 +02:00
Ben Siraphob b63a54f81c
Merge pull request #110742 from siraben/deprecate-fold 2021-07-27 15:13:31 +07:00
Luke Granger-Brown 649672e76e nixos/postfix: fix compatibility level
Postfix has started outputting an error on startup that it can't parse
the compatibility level 9999.

Instead, just set the compatibility level to be identical to the current
version, which seems to be the (new) intent for the compatibility level.
2021-05-02 21:49:33 +00:00