nixos/stalwart: switch logging from stdout to journal

journald's centralized logging has many advantages:
- External centralized logging can simply source from journald
- journald's auto-vacuum options (e.g. SystemMaxUse) can make sure logs
  don't take up too much space
- Logs are in a single timeline, which is useful for analysis
This commit is contained in:
Axel Karjalainen
2026-04-04 20:04:10 +03:00
parent 75742d265e
commit bfd7ffcf08
2 changed files with 21 additions and 8 deletions
@@ -168,6 +168,7 @@ of pulling the upstream container image from Docker Hub. If you want the old beh
- `systemd.services.stalwart` owned by `stalwart:stalwart`. The `user` and `group` are configurable via `services.stalwart.user` and `services.stalwart.group`, respectively. By default, if `stateVersion` is older than `26.05`, will fallback to legacy value of `stalwart-mail` for both `user` and `group`.
- Default value for `services.stalwart.dataDir` has changed to `/var/lib/stalwart`. If `stateVersion` is older than `26.05`, will fallback to legacy value of `/var/lib/stalwart-mail`.
- Default tracer name and type have changed to `journal`. If `stateVersion` is older than `26.05`, will fallback to legacy value of `stdout`.
- `services.eintopf` has been renamed to `services.lauti` to align with upstream re-brand as a community online calendar.
+20 -8
View File
@@ -9,8 +9,8 @@ let
configFormat = pkgs.formats.toml { };
configFile = configFormat.generate "stalwart.toml" cfg.settings;
useLegacyStorage = lib.versionOlder cfg.stateVersion "24.11";
useLegacyIdentifier = lib.versionOlder cfg.stateVersion "26.05";
stalwartIdentifier = if useLegacyIdentifier then "stalwart-mail" else "stalwart";
pre2605 = lib.versionOlder cfg.stateVersion "26.05";
stalwartIdentifier = if pre2605 then "stalwart-mail" else "stalwart";
parsePorts =
listeners:
@@ -123,12 +123,24 @@ in
# Default config: all local
services.stalwart.settings = {
tracer.stdout = {
type = lib.mkDefault "stdout";
level = lib.mkDefault "info";
ansi = lib.mkDefault false; # no colour markers to journald
enable = lib.mkDefault true;
};
tracer =
if pre2605 then
{
stdout = {
type = lib.mkDefault "stdout";
level = lib.mkDefault "info";
ansi = lib.mkDefault false; # no colour markers to journald
enable = lib.mkDefault true;
};
}
else
{
journal = {
type = lib.mkDefault "journal";
level = lib.mkDefault "info";
enable = lib.mkDefault true;
};
};
store =
if useLegacyStorage then
{