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
```
This commit is contained in:
Martin Weinelt 2025-06-17 21:55:12 +02:00
parent 7405122dde
commit cf6ef5e9ca
No known key found for this signature in database
GPG key ID: 87C1E9888F856759
4 changed files with 31 additions and 11 deletions

View file

@ -1026,14 +1026,34 @@ in
}; };
}; };
debug = mkOption { debug = {
type = types.bool; all = mkOption {
default = false; type = types.bool;
description = '' default = false;
Whether to enable verbose logging for mailserver related services. This description = ''
intended be used for development purposes only, you probably don't want Whether to enable verbose logging for all mailserver related services.
to enable this unless you're hacking on nixos-mailserver. This intended be used for development purposes only, you probably
''; don't want to enable this unless you're hacking on nixos-mailserver.
'';
};
dovecot = mkOption {
type = types.bool;
default = cfg.debug.all;
defaultText = lib.literalExpression "config.mailserver.debug.all";
description = ''
Whether to enable verbose logging for Dovecot.
'';
};
rspamd = mkOption {
type = types.bool;
default = cfg.debug.all;
defaultText = lib.literalExpression "config.mailserver.debug.all";
description = ''
Whether to enable verbose logging for Rspamd.
'';
};
}; };
maxConnectionsPerUser = mkOption { maxConnectionsPerUser = mkOption {

View file

@ -262,7 +262,7 @@ in
extraConfig = '' extraConfig = ''
#Extra Config #Extra Config
${lib.optionalString cfg.debug '' ${lib.optionalString cfg.debug.dovecot ''
mail_debug = yes mail_debug = yes
auth_debug = yes auth_debug = yes
verbose_ssl = yes verbose_ssl = yes

View file

@ -67,7 +67,7 @@ in
services.rspamd = { services.rspamd = {
enable = true; enable = true;
inherit (cfg) debug; debug = cfg.debug.rspamd;
locals = { locals = {
"milter_headers.conf" = { "milter_headers.conf" = {
text = '' text = ''

View file

@ -39,7 +39,7 @@
mailserver = { mailserver = {
enable = true; enable = true;
debug = true; debug.dovecot = true; # enabled for sieve script logging
fqdn = "mail.example.com"; fqdn = "mail.example.com";
domains = [ domains = [
"example.com" "example.com"