Mail machine #47

Merged
Gonne merged 9 commits from Gonne/nixConfig:nyarlathotep into main 2025-02-27 15:59:49 +00:00
Showing only changes of commit cc91339f80 - Show all commits

View file

@ -24,18 +24,18 @@
mkEnableOption mkEnableOption
mkOption mkOption
; ;
inherit (lib.types) listOf strMatching str path; inherit (lib.types) listOf strMatching nonEmptyStr path;
cfg = config.services.mathebau-mail; cfg = config.services.mathebau-mail;
in { in {
options.services.mathebau-mail = { options.services.mathebau-mail = {
enable = mkEnableOption "mathebau mail service"; enable = mkEnableOption "mathebau mail service";
stalwartAdmin = mkOption { stalwartAdmin = mkOption {
type = path; type = path;
description = "Path to a file that contains the stalwart fallback admin password encoded for HTTP Basic Auth"; description = "Path to a file that contains the stalwart fallback admin password encoded for HTTP Basic Auth. Update together with the stalwartAdminHash and the pass store.";
Gonne marked this conversation as resolved Outdated

did you think about a more specialized type, non empty string? string matching regex? something like this?

did you think about a more specialized type, non empty string? string matching regex? something like this?
}; };
stalwartAdminHash = mkOption { stalwartAdminHash = mkOption {
type = str; type = nonEmptyStr;
Gonne marked this conversation as resolved Outdated

nonempty?

nonempty?
description = "String containing the hashed fallback admin password"; description = "String containing the hashed fallback admin password. Update together with the stalwartAdmin setting and the pass store.";
}; };
domains = mkOption { domains = mkOption {
type = listOf (lib.types.submodule { type = listOf (lib.types.submodule {
@ -98,6 +98,7 @@ in {
domains = ["fb04184.mathematik.tu-darmstadt.de" "imap.mathebau.de" "smtp.mathebau.de"]; domains = ["fb04184.mathematik.tu-darmstadt.de" "imap.mathebau.de" "smtp.mathebau.de"];
default = true; default = true;
}; };
# Reevaluate after DKIM and DMARC deployment
Gonne marked this conversation as resolved Outdated

maybe make a note here, so we find this again after we have DKIM and DMARC

maybe make a note here, so we find this again after we have DKIM and DMARC
spam.header.is-spam = "Dummyheader"; # disable moving to spam which would conflict with forwarding spam.header.is-spam = "Dummyheader"; # disable moving to spam which would conflict with forwarding
auth = { auth = {
https://www.hrz.tu-darmstadt.de/hrz_aktuelles/news_details_177024.en.jsp Maybe parts of this are now?

I would like to evaluate this in production based on logs.

I would like to evaluate this in production based on logs.

Fine by me, that should be an easy fix

Fine by me, that should be an easy fix
# TODO check if HRZ conforms to these standards and we can validate them strictly # TODO check if HRZ conforms to these standards and we can validate them strictly
@ -162,6 +163,7 @@ in {
# We here define what comes from the TOML-file and especially add "sieve.trusted.scripts.*" to the default ones # We here define what comes from the TOML-file and especially add "sieve.trusted.scripts.*" to the default ones
# because only TOML-based keys may use macros to load files from disk. # because only TOML-based keys may use macros to load files from disk.
# We want this to be able to load our sieve-script for mail forwarding. # We want this to be able to load our sieve-script for mail forwarding.
# See https://stalw.art/docs/configuration/overview/#local-and-database-settings for more details.
config.local-keys = config.local-keys =
[ [
Gonne marked this conversation as resolved Outdated

comment is outdated

comment is outdated
"store.*" "store.*"
@ -226,6 +228,7 @@ in {
}: '' }: ''
echo "process ${domain}" echo "process ${domain}"
Gonne marked this conversation as resolved

can we have a comment for this regex?

can we have a comment for this regex?
# This line gets the available mailboxes from stalwart's Rest API, searches for their addresses and collects them to a file for submission. # This line gets the available mailboxes from stalwart's Rest API, searches for their addresses and collects them to a file for submission.
# The regex searches for alphanumerics combined with some special characters as local paths and the right domain.
Gonne marked this conversation as resolved Outdated

and this one? is it the same?

and this one? is it the same?
${pkgs.curl}/bin/curl -s --header "authorization: Basic $(<${cfg.stalwartAdmin})" http://localhost/api/principal | ${pkgs.gnugrep}/bin/grep -o -e "[A-Za-z0-9.!#\$%&'*+-/=?^_{|}~]*@${domain}" | tee /tmp/addresses ${pkgs.curl}/bin/curl -s --header "authorization: Basic $(<${cfg.stalwartAdmin})" http://localhost/api/principal | ${pkgs.gnugrep}/bin/grep -o -e "[A-Za-z0-9.!#\$%&'*+-/=?^_{|}~]*@${domain}" | tee /tmp/addresses
# This line searches for available redirects and adds them to the submission file. # This line searches for available redirects and adds them to the submission file.
${pkgs.gnugrep}/bin/grep -o -e "[A-Za-z0-9.!#\$%&'*+-/=?^_{|}~]*@${domain}" /tmp/virt_aliases >> /tmp/addresses # This doesn't catch all RFC conform local parts. Improve if you need. ${pkgs.gnugrep}/bin/grep -o -e "[A-Za-z0-9.!#\$%&'*+-/=?^_{|}~]*@${domain}" /tmp/virt_aliases >> /tmp/addresses # This doesn't catch all RFC conform local parts. Improve if you need.
@ -260,6 +263,7 @@ in {
RestrictSUIDSGID = true; RestrictSUIDSGID = true;
Gonne marked this conversation as resolved Outdated

Can we make a comment that this is only an extension of the existing service?

Can we make a comment that this is only an extension of the existing service?
}; };
}; };
# This service is defined by the nixpkgs stalwart module and we only modify it.
"stalwart-mail" = { "stalwart-mail" = {
restartTriggers = lib.attrsets.mapAttrsToList (_: aliaslist: aliaslist.sopsFile) config.sops.secrets; # restart if secrets, especially alias files, have changed. restartTriggers = lib.attrsets.mapAttrsToList (_: aliaslist: aliaslist.sopsFile) config.sops.secrets; # restart if secrets, especially alias files, have changed.
serviceConfig.PrivateTmp = lib.mkForce false; # enable access to generated Sieve script serviceConfig.PrivateTmp = lib.mkForce false; # enable access to generated Sieve script