1 # Email setup is fairly involved, useful references:
2 # https://drewdevault.com/2018/08/05/Local-mail-server.html
4 { config, lib, pkgs, ... }:
8 cfg = config.services.sourcehut;
11 iniKey = "lists.sr.ht";
12 statePath = "/var/lib/sourcehut/listssrht";
14 rcfg = config.services.redis;
15 drv = pkgs.sourcehut.listssrht;
18 options.services.sourcehut.lists = {
21 default = "listssrht";
31 Port on which the "lists" module should listen.
37 default = "lists.sr.ht";
39 PostgreSQL database name for lists.sr.ht.
44 config = with scfg; lib.mkIf (cfg.enable && elem "lists" cfg.services) {
50 extraGroups = [ "postfix" ];
51 description = "lists.sr.ht user";
59 services.postgresql = {
61 local ${database} ${user} trust
63 ensureDatabases = [ database ];
67 ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
74 listssrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
75 after = [ "postgresql.service" "network.target" ];
76 requires = [ "postgresql.service" ];
77 wantedBy = [ "multi-user.target" ];
79 description = "lists.sr.ht website service";
81 serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
85 after = [ "postgresql.service" "network.target" ];
86 requires = [ "postgresql.service" ];
87 wantedBy = [ "multi-user.target" ];
89 description = "lists.sr.ht process service";
94 ExecStart = "${cfg.python}/bin/celery -A ${drv.pname}.process worker --loglevel INFO --pool eventlet";
99 after = [ "postgresql.service" "network.target" ];
100 requires = [ "postgresql.service" ];
101 wantedBy = [ "multi-user.target" ];
103 description = "lists.sr.ht process service";
108 ExecStart = "${cfg.python}/bin/listssrht-lmtp";
113 listssrht-webhooks = {
114 after = [ "postgresql.service" "network.target" ];
115 requires = [ "postgresql.service" ];
116 wantedBy = [ "multi-user.target" ];
118 description = "lists.sr.ht webhooks service";
123 ExecStart = "${cfg.python}/bin/celery -A ${drv.pname}.webhooks worker --loglevel INFO --pool eventlet";
129 services.nginx.virtualHosts."lists.${cfg.originBase}" = {
131 locations."/".proxyPass = "http://${cfg.address}:${toString port}";
132 locations."/query".proxyPass = cfgIni."meta.sr.ht".api-origin;
133 locations."/static".root = "${pkgs.sourcehut.listssrht}/${pkgs.sourcehut.python.sitePackages}/listssrht";