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 = {
16 enable = mkEnableOption "todo service";
30 Port on which the "todo" module should listen.
36 default = "todo.sr.ht";
38 PostgreSQL database name for todo.sr.ht.
43 config = with scfg; lib.mkIf (cfg.enable && scfg.enable) {
49 extraGroups = [ "postfix" ];
50 description = "todo.sr.ht user";
58 services.postgresql = {
60 local ${database} ${user} trust
62 ensureDatabases = [ database ];
66 ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
73 todosrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
74 after = [ "postgresql.service" "network.target" ];
75 requires = [ "postgresql.service" ];
76 wantedBy = [ "multi-user.target" ];
78 description = "todo.sr.ht website service";
80 serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
84 after = [ "postgresql.service" "network.target" ];
85 bindsTo = [ "postgresql.service" ];
86 wantedBy = [ "multi-user.target" ];
88 description = "todo.sr.ht process service";
93 ExecStart = "${cfg.python}/bin/todosrht-lmtp";
98 after = [ "postgresql.service" "network.target" ];
99 requires = [ "postgresql.service" ];
100 wantedBy = [ "multi-user.target" ];
102 description = "todo.sr.ht webhooks service";
107 ExecStart = "${cfg.python}/bin/celery -A ${drv.pname}.webhooks worker --loglevel INFO --pool eventlet";
114 services.nginx.virtualHosts."todo.${cfg.originBase}" = {
116 locations."/".proxyPass = "http://${cfg.address}:${toString port}";
117 locations."/query".proxyPass = cfgIni."meta.sr.ht".api-origin;
118 locations."/static".root = "${pkgs.sourcehut.todosrht}/${pkgs.sourcehut.python.sitePackages}/todosrht";