From 8921b406fac3f0b3cb03139587675acbaf09ddc5 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Wed, 1 Feb 2023 18:58:09 +0100 Subject: [PATCH] mailman wip --- hosts/flora-6/caddy.nix | 7 +- hosts/flora-6/mailman.nix | 207 +++++++++++++++++++--------------- hosts/flora-6/postfix/main.cf | 15 +-- 3 files changed, 124 insertions(+), 105 deletions(-) diff --git a/hosts/flora-6/caddy.nix b/hosts/flora-6/caddy.nix index 648bfe33..75746bc7 100644 --- a/hosts/flora-6/caddy.nix +++ b/hosts/flora-6/caddy.nix @@ -77,12 +77,7 @@ output discard ''; extraConfig = '' - handle_path /static/* { - root * /var/lib/mailman/web - file_server - } - - reverse_proxy :8000 + reverse_proxy :${services.sourcehut.lists.port} ''; }; "obs-portal.pub.solar" = { diff --git a/hosts/flora-6/mailman.nix b/hosts/flora-6/mailman.nix index 2bbc0866..90840234 100644 --- a/hosts/flora-6/mailman.nix +++ b/hosts/flora-6/mailman.nix @@ -49,95 +49,124 @@ in { owner = "mailman"; }; - virtualisation = { - docker = { - enable = true; - }; - - oci-containers = { - backend = "docker"; - containers."mailman-core" = { - image = "maxking/mailman-core:0.4"; - autoStart = true; - user = "993"; - volumes = [ - "/var/lib/mailman/core:/opt/mailman/" - ]; - extraOptions = [ - "--network=mailman-net" - ]; - environment = { - DATABASE_TYPE = "postgres"; - DATABASE_CLASS = "mailman.database.postgresql.PostgreSQLDatabase"; - MTA = "postfix"; - }; - environmentFiles = [ - config.age.secrets.mailman-core-secrets.path - ]; - ports = [ - "127.0.0.1:8001:8001" # API - "127.0.0.1:8024:8024" # LMTP - incoming emails - ]; - }; - - containers."mailman-web" = { - image = "maxking/mailman-web:0.4"; - autoStart = true; - user = "993"; - volumes = [ - "/var/lib/mailman/web:/opt/mailman-web-data" - ]; - extraOptions = [ - "--network=mailman-net" - ]; - environment = { - DATABASE_TYPE = "postgres"; - SERVE_FROM_DOMAIN = "list.pub.solar"; - MAILMAN_ADMIN_USER = "admin"; - MAILMAN_ADMIN_EMAIL = "admins@pub.solar"; - }; - environmentFiles = [ - config.age.secrets.mailman-web-secrets.path - ]; - ports = [ - "127.0.0.1:8000:8000" # HTTP - # "127.0.0.1:8080:8080" # uwsgi - ]; - }; - - containers."mailman-db" = { - image = "postgres:14-alpine"; - autoStart = true; - user = "993"; - extraOptions = [ - "--network=mailman-net" - ]; - volumes = [ - "/var/lib/mailman/database:/var/lib/postgresql/data" - ]; - environmentFiles = [ - config.age.secrets.mailman-db-secrets.path - ]; - }; - - containers."mailman-postfix" = { - image = "mailu/postfix:1.9.46"; - autoStart = true; - user = "993"; - extraOptions = [ - "--network=mailman-net" - ]; - volumes = [ - "/var/lib/mailman/postfix/overrides:/overrides:ro" - "/var/lib/mailman/postfix/mailqueue:/var/spool/postfix" - "/var/lib/mailman/postfix/data:/var/lib/postfix" - "/var/lib/mailman/core:/var/lib/mailman/core" - "${postfixConfig}:/etc/postfix/main.cf" - ]; - environmentFiles = [ - config.age.secrets.mailman-db-secrets.path - ]; - }; + services.postfix = { + enable = true; + relayDomains = ["hash:/var/lib/mailman/data/postfix_domains"]; + #sslCert = config.security.acme.certs."lists.example.org".directory + "/full.pem"; + #sslKey = config.security.acme.certs."lists.example.org".directory + "/key.pem"; + config = { + transport_maps = ["hash:/var/lib/mailman/data/postfix_lmtp"]; + local_recipient_maps = ["hash:/var/lib/mailman/data/postfix_lmtp"]; }; }; + services.mailman = { + enable = true; + #serve.enable = true; + hyperkitty.enable = true; + webHosts = ["list.pub.solar"]; + siteOwner = "admins@pub.solar"; + }; + + #virtualisation = { + # docker = { + # enable = true; + # }; + + # oci-containers = { + # backend = "docker"; + # containers."mailman-core" = { + # image = "maxking/mailman-core:0.4"; + # autoStart = true; + # #user = "993"; + # volumes = [ + # "/var/lib/mailman/core:/opt/mailman/" + # ]; + # extraOptions = [ + # "--network=mailman-net" + # ]; + # environment = { + # DATABASE_TYPE = "postgres"; + # DATABASE_CLASS = "mailman.database.postgresql.PostgreSQLDatabase"; + # MTA = "postfix"; + # }; + # environmentFiles = [ + # config.age.secrets.mailman-core-secrets.path + # ]; + # ports = [ + # "127.0.0.1:8001:8001" # API + # "127.0.0.1:8024:8024" # LMTP - incoming emails + # ]; + # }; + + # containers."mailman-web" = { + # image = "maxking/mailman-web:0.4"; + # autoStart = true; + # #user = "993:992"; + # volumes = [ + # "/var/lib/mailman/web:/opt/mailman-web-data" + # ]; + # extraOptions = [ + # "--network=mailman-net" + # ]; + # environment = { + # DATABASE_TYPE = "postgres"; + # SERVE_FROM_DOMAIN = "list.pub.solar"; + # MAILMAN_ADMIN_USER = "admin"; + # MAILMAN_ADMIN_EMAIL = "admins@pub.solar"; + # }; + # environmentFiles = [ + # config.age.secrets.mailman-web-secrets.path + # ]; + # ports = [ + # "127.0.0.1:8000:8000" # HTTP + # # "127.0.0.1:8080:8080" # uwsgi + # ]; + # }; + + # containers."mailman-db" = { + # image = "postgres:14-alpine"; + # autoStart = true; + # user = "993"; + # extraOptions = [ + # "--network=mailman-net" + # ]; + # volumes = [ + # "/var/lib/mailman/database:/var/lib/postgresql/data" + # ]; + # environmentFiles = [ + # config.age.secrets.mailman-db-secrets.path + # ]; + # }; + + # containers."mailman-postfix" = { + # image = "mailu/postfix:1.9.46"; + # autoStart = true; + # #user = "993"; + # extraOptions = [ + # "--hostname=list.pub.solar" + # "--network=mailman-net" + # ]; + # environment = { + # HOSTNAMES = "list.pub.solar"; + # FRONT_ADDRESS = "localhost"; + # ADMIN_ADDRESS = "localhost"; + # ANTISPAM_MILTER_ADDRESS = "localhost:11332"; + # LMTP_ADDRESS = "localhost:2525"; + # }; + # volumes = [ + # # https://mailu.io/1.9/faq.html#how-can-i-override-settings + # # Docs contain the wrong path to override main.cf, this one works + # "${postfixConfig}:/overrides/postfix.cf" + # # Configured in main.cf + # "/var/lib/mailman/postfix/mailqueue:/var/spool/postfix" + # "/var/lib/mailman/postfix/data:/var/lib/postfix" + # # Contains postfix transport_maps generated by mailman-core + # "/var/lib/mailman/core:/var/lib/mailman/core" + # ]; + # environmentFiles = [ + # config.age.secrets.mailman-db-secrets.path + # ]; + # }; + # }; + #}; } diff --git a/hosts/flora-6/postfix/main.cf b/hosts/flora-6/postfix/main.cf index 56fb7947..b4998618 100644 --- a/hosts/flora-6/postfix/main.cf +++ b/hosts/flora-6/postfix/main.cf @@ -99,7 +99,7 @@ myhostname = list.pub.solar # $mydomain is used as a default value for many other configuration # parameters. # -#mydomain = domain.tld +mydomain = pub.solar # SENDING MAIL # @@ -609,9 +609,7 @@ debug_peer_level = 2 # the process marches on. If you use an X-based debugger, be sure to # set up your XAUTHORITY environment variable before starting Postfix. # -debugger_command = - PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin - ddd $daemon_directory/$process_name $process_id & sleep 5 +debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5 # If you can't use X, use this to capture the call stack when a # daemon crashes. The result is in a file in the configuration @@ -684,9 +682,6 @@ recipient_delimiter = + unknown_local_recipient_reject_code = 550 owner_request_special = no -transport_maps = - regexp:/var/lib/mailman/core/var/data/postfix_lmtp -local_recipient_maps = - regexp:/var/lib/mailman/core/var/data/postfix_lmtp -relay_domains = - regexp:/var/lib/mailman/core/var/data/postfix_domains +transport_maps = regexp:/var/lib/mailman/core/var/data/postfix_lmtp +local_recipient_maps = regexp:/var/lib/mailman/core/var/data/postfix_lmtp +relay_domains = regexp:/var/lib/mailman/core/var/data/postfix_domains