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";
13 rcfg = config.services.redis;
14 drv = pkgs.sourcehut.listssrht;
17 options.services.sourcehut.lists = {
20 default = "listssrht";
30 Port on which the "lists" module should listen.
36 default = "lists.sr.ht";
38 PostgreSQL database name for lists.sr.ht.
42 statePath = mkOption {
44 default = "${cfg.statePath}/listssrht";
46 State path for lists.sr.ht.
51 config = with scfg; lib.mkIf (cfg.enable && elem "lists" cfg.services) {
57 extraGroups = [ "postfix" ];
58 description = "lists.sr.ht user";
66 services.postgresql = {
68 local ${database} ${user} trust
70 ensureDatabases = [ database ];
74 ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
81 "d ${statePath} 0750 ${user} ${user} -"
85 listssrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
86 after = [ "postgresql.service" "network.target" ];
87 requires = [ "postgresql.service" ];
88 wantedBy = [ "multi-user.target" ];
90 description = "lists.sr.ht website service";
92 serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
96 after = [ "postgresql.service" "network.target" ];
97 requires = [ "postgresql.service" ];
98 wantedBy = [ "multi-user.target" ];
100 description = "lists.sr.ht process service";
105 ExecStart = "${cfg.python}/bin/celery -A ${drv.pname}.process worker --loglevel INFO --pool eventlet";
110 after = [ "postgresql.service" "network.target" ];
111 requires = [ "postgresql.service" ];
112 wantedBy = [ "multi-user.target" ];
114 description = "lists.sr.ht process service";
119 ExecStart = "${cfg.python}/bin/listssrht-lmtp";
124 listssrht-webhooks = {
125 after = [ "postgresql.service" "network.target" ];
126 requires = [ "postgresql.service" ];
127 wantedBy = [ "multi-user.target" ];
129 description = "lists.sr.ht webhooks service";
134 ExecStart = "${cfg.python}/bin/celery -A ${drv.pname}.webhooks worker --loglevel INFO --pool eventlet";
140 services.nginx.virtualHosts."lists.${cfg.originBase}" = {
142 locations."/".proxyPass = "http://${cfg.address}:${toString port}";
143 locations."/query".proxyPass = "http://${cfg.address}:${toString (port + 100)}";
144 locations."/static".root = "${pkgs.sourcehut.listssrht}/${pkgs.sourcehut.python.sitePackages}/listssrht";