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 = {
19 enable = mkEnableOption "lists service";
23 default = "listssrht";
33 Port on which the "lists" module should listen.
39 default = "lists.sr.ht";
41 PostgreSQL database name for lists.sr.ht.
46 config = with scfg; lib.mkIf (cfg.enable && scfg.enable) {
52 extraGroups = [ "postfix" ];
53 description = "lists.sr.ht user";
61 services.postgresql = {
63 local ${database} ${user} trust
65 ensureDatabases = [ database ];
69 ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
76 listssrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
77 after = [ "postgresql.service" "network.target" ];
78 requires = [ "postgresql.service" ];
79 wantedBy = [ "multi-user.target" ];
81 description = "lists.sr.ht website service";
83 serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
87 after = [ "postgresql.service" "network.target" ];
88 requires = [ "postgresql.service" ];
89 wantedBy = [ "multi-user.target" ];
91 description = "lists.sr.ht process service";
96 ExecStart = "${cfg.python}/bin/celery -A ${drv.pname}.process worker --loglevel INFO --pool eventlet";
101 after = [ "postgresql.service" "network.target" ];
102 requires = [ "postgresql.service" ];
103 wantedBy = [ "multi-user.target" ];
105 description = "lists.sr.ht process service";
110 ExecStart = "${cfg.python}/bin/listssrht-lmtp";
115 listssrht-webhooks = {
116 after = [ "postgresql.service" "network.target" ];
117 requires = [ "postgresql.service" ];
118 wantedBy = [ "multi-user.target" ];
120 description = "lists.sr.ht webhooks service";
125 ExecStart = "${cfg.python}/bin/celery -A ${drv.pname}.webhooks worker --loglevel INFO --pool eventlet";
131 services.nginx.virtualHosts."lists.${cfg.originBase}" = {
133 locations."/".proxyPass = "http://${cfg.address}:${toString port}";
134 locations."/query".proxyPass = cfgIni."meta.sr.ht".api-origin;
135 locations."/static".root = "${pkgs.sourcehut.listssrht}/${pkgs.sourcehut.python.sitePackages}/listssrht";