1 { lib, pkgs, config, ... }:
3 domains = (lib.remove null (lib.flatten (map
7 domain = "${e.domain}${lib.optionalString (e.domain != "") "."}${zone.name}";
12 (zone.withEmail or [])
14 config.myEnv.dns.masterZones
16 mxes = lib.mapAttrsToList
17 (n: v: v.mx.subdomain)
18 (lib.attrsets.filterAttrs (n: v: v.mx.enable) config.myEnv.servers);
19 # FIXME: increase the id number in modules/private/dns.nix when this
20 # file change (date -u +'%Y%m%d%H%M%S'Z)
21 file = domain: pkgs.writeText "mta-sts-${domain.domain}.txt" ''
24 ${builtins.concatStringsSep "\n" (map (v: "mx: ${v}.${domain.mail}") mxes)}
27 root = pkgs.runCommand "mta-sts_root" {} ''
29 ${builtins.concatStringsSep "\n" (map (d:
30 "cp ${file d} $out/${d.domain}.txt"
33 cfg = config.myServices.websites.tools.email;
36 config = lib.mkIf cfg.enable {
37 myServices.websites.webappDirs = {
41 services.websites.env.tools.vhostConfs.mta_sts = {
44 hosts = ["mta-sts.mail.immae.eu"] ++ map (v: "mta-sts.${v.domain}") domains;
45 root = "/run/current-system/webapps/_mta-sts";
49 RewriteCond %{HTTP_HOST} ^mta-sts.(.*)$
50 RewriteRule ^/.well-known/mta-sts.txt$ %{DOCUMENT_ROOT}/%1.txt [L]
51 <Directory /run/current-system/webapps/_mta-sts>