diff options
| author | Jakub Stachurski <jakub@wilkuu.xyz> | 2026-03-05 23:09:19 +0100 |
|---|---|---|
| committer | Jakub Stachurski <j.stachurski@student.utwente.nl> | 2026-03-05 23:10:06 +0100 |
| commit | e24ce7987328000c6b3da2e4f51b8392b00a9e73 (patch) | |
| tree | b42504c7af41aa546e804b5459c05719c24d5bdc | |
| parent | 3d074dc5605738c9df45437cff3737186cdd030a (diff) | |
Feat/mutliple email domains (#5)
* Add additional domain support
* Configure omega-relay to use wilkuu.nl
* Fix oopsies
| -rw-r--r-- | hosts/apocalypse/default.nix | 2 | ||||
| -rw-r--r-- | hosts/omega-relay/default.nix | 7 | ||||
| -rw-r--r-- | services/continuwuity.nix | 2 | ||||
| -rw-r--r-- | services/email.nix | 100 |
4 files changed, 63 insertions, 48 deletions
diff --git a/hosts/apocalypse/default.nix b/hosts/apocalypse/default.nix index 2753e61..0977258 100644 --- a/hosts/apocalypse/default.nix +++ b/hosts/apocalypse/default.nix @@ -14,7 +14,7 @@ }; services.logind.settings.Login = { - HandleLidSwitch = "ignore"; + HandleLidSwitch = "suspend"; HandleLidSwitchExternalPower = "lock"; HandleLidSwitchDocked = "ignore"; }; diff --git a/hosts/omega-relay/default.nix b/hosts/omega-relay/default.nix index 4a52dda..17d004f 100644 --- a/hosts/omega-relay/default.nix +++ b/hosts/omega-relay/default.nix @@ -45,6 +45,11 @@ stalwart = { enable = true; domain = if isVM then "mail.omega-relay.local" else "mail.wilkuu.xyz"; + wellKnownDomains = [ + "wilkuu.xyz" + "wilkuu.nl" + ]; + additionalDomains = [ "mail.wilkuu.nl" ]; doACME = !isVM; }; continuwuity = { @@ -93,7 +98,7 @@ maxretry = 5; ignoreIP = [ "192.168.80.0/24" - "192.168.80.0/24" + "192.168.88.0/24" ]; bantime = "24h"; bantime-increment = { diff --git a/services/continuwuity.nix b/services/continuwuity.nix index e373cec..5bd249e 100644 --- a/services/continuwuity.nix +++ b/services/continuwuity.nix @@ -88,7 +88,7 @@ in { # well-known discovery # TODO: Might need to enforce https here, if it already is not. - ${cfg.fdqn}.locations."/.well_known/matrix/".proxyPass = socket; + ${cfg.fdqn}.locations."/.well-known/matrix/".proxyPass = socket; # The matrix server ${cfg.host-domain} = { diff --git a/services/email.nix b/services/email.nix index f050b2b..7966d8f 100644 --- a/services/email.nix +++ b/services/email.nix @@ -11,6 +11,12 @@ in example = "mail.wilkuu.xyz"; description = "Domain for http connections."; }; + additionalDomains = mkOption { + type = types.listOf types.str; + default = [ ]; + example = [ "mail.wilkuu.xyz" ]; + description = "Domain for http connections."; + }; wellKnownDomains = mkOption { type = types.listOf types.str; default = [ "${hostname}.local" ]; @@ -58,7 +64,7 @@ in in { networking.hosts = { - "127.0.0.1" = [ cfg.domain ]; + "127.0.0.1" = ([ cfg.domain ] ++ cfg.additionalDomains); }; # Need this bc otherwise sops will complain for some reason @@ -80,31 +86,27 @@ in ); services.nginx.virtualHosts = - (lib.genAttrs cfg.wellKnownDomains ( - (_wdomain: { - locations = - (proxyWellKnown [ - "jmap" - "mta-sts.txt" - "mail-v1.xml" - "autoconfig/mail" - ]) - // (lib.genAttrs [ "/.well-known/caldav" "/.well-known/webdav" ] ( - uri: (makeHttpRedirect "${cfg.domain}${uri}") cfg.doACME - )); - }) - )) - // { - ${cfg.domain} = { - addSSL = cfg.doACME; - enableACME = cfg.doACME; - serverName = "${cfg.domain}"; - locations."/" = { - proxyPass = "http://localhost:3080"; - recommendedProxySettings = true; - }; + (lib.genAttrs cfg.wellKnownDomains (_wdomain: { + locations = + (proxyWellKnown [ + "jmap" + "mta-sts.txt" + "mail-v1.xml" + "autoconfig/mail" + ]) + // (lib.genAttrs [ "/.well-known/caldav/" "/.well-known/webdav/" ] ( + uri: (makeHttpRedirect "${cfg.domain}${uri}") cfg.doACME + )); + })) + // (lib.genAttrs ([ cfg.domain ] ++ cfg.additionalDomains) (domain: { + addSSL = cfg.doACME; + enableACME = cfg.doACME; + serverName = "${domain}"; + locations."/" = { + proxyPass = "http://localhost:3080"; + recommendedProxySettings = true; }; - }; + })); services.stalwart = { enable = true; @@ -112,21 +114,19 @@ in openFirewall = false; credentials = (lib.genAttrs secrets toCredfilePath) - // ( - let - acme_dir = config.security.acme.certs.${cfg.domain}.directory; - cert_path = file: "${acme_dir}/${file}"; - in - ( - if cfg.doACME then - { - "tls_cert.pem" = cert_path "cert.pem"; - "tls_key.pem" = cert_path "key.pem"; - } - else - { } - ) - ); + // (builtins.foldl' (a: b: a // b) ({ }) ( + map ( + domain: + let + acme_dir = config.security.acme.certs.${domain}.directory; + cert_path = file: "${acme_dir}/${file}"; + in + { + "tls_${domain}_cert.pem" = cert_path "cert.pem"; + "tls_${domain}_key.pem" = cert_path "key.pem"; + } + ) ([ cfg.domain ] ++ cfg.additionalDomains) + )); settings = { server.listener = { @@ -174,11 +174,21 @@ in server.hostname = "${cfg.domain}"; - certificate."nix_${cfg.domain}" = lib.mkIf cfg.doACME { - cert = toStalwartCred "tls_cert.pem"; - private-key = toStalwartCred "tls_key.pem"; - default = true; - }; + certificate = ( + lib.mkIf (cfg.doACME) ( + lib.genAttrs (map (d: "nix_${d}") ([ cfg.domain ] ++ cfg.additionalDomains)) ( + _name: + let + domain = lib.strings.removePrefix "nix_" _name; + in + { + cert = toStalwartCred "tls_${domain}_cert.pem"; + private-key = toStalwartCred "tls_${domain}_key.pem"; + default = (domain == cfg.domain); + } + ) + ) + ); }; }; } |
