1 { config, lib, pkgs, ... }:
5 cfg = config.services.sourcehut;
9 statePath = "/var/lib/sourcehut/todosrht";
11 rcfg = config.services.redis;
12 drv = pkgs.sourcehut.todosrht;
15 options.services.sourcehut.todo = {
28 Port on which the "todo" module should listen.
34 default = "todo.sr.ht";
36 PostgreSQL database name for todo.sr.ht.
41 config = with scfg; lib.mkIf (cfg.enable && elem "todo" cfg.services) {
47 extraGroups = [ "postfix" ];
48 description = "todo.sr.ht user";
56 services.postgresql = {
58 local ${database} ${user} trust
60 ensureDatabases = [ database ];
64 ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
71 todosrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
72 after = [ "postgresql.service" "network.target" ];
73 requires = [ "postgresql.service" ];
74 wantedBy = [ "multi-user.target" ];
76 description = "todo.sr.ht website service";
78 serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
82 after = [ "postgresql.service" "network.target" ];
83 bindsTo = [ "postgresql.service" ];
84 wantedBy = [ "multi-user.target" ];
86 description = "todo.sr.ht process service";
91 ExecStart = "${cfg.python}/bin/todosrht-lmtp";
96 after = [ "postgresql.service" "network.target" ];
97 requires = [ "postgresql.service" ];
98 wantedBy = [ "multi-user.target" ];
100 description = "todo.sr.ht webhooks service";
105 ExecStart = "${cfg.python}/bin/celery -A ${drv.pname}.webhooks worker --loglevel INFO --pool eventlet";
112 services.nginx.virtualHosts."todo.${cfg.originBase}" = {
114 locations."/".proxyPass = "http://${cfg.address}:${toString port}";
115 locations."/query".proxyPass = cfgIni."meta.sr.ht".api-origin;
116 locations."/static".root = "${pkgs.sourcehut.todosrht}/${pkgs.sourcehut.python.sitePackages}/todosrht";