1 { config, lib, pkgs, ... }:
5 cfg = config.services.sourcehut;
10 rcfg = config.services.redis;
11 drv = pkgs.sourcehut.todosrht;
14 options.services.sourcehut.todo = {
27 Port on which the "todo" module should listen.
33 default = "todo.sr.ht";
35 PostgreSQL database name for todo.sr.ht.
39 statePath = mkOption {
41 default = "${cfg.statePath}/todosrht";
43 State path for todo.sr.ht.
48 config = with scfg; lib.mkIf (cfg.enable && elem "todo" cfg.services) {
54 extraGroups = [ "postfix" ];
55 description = "todo.sr.ht user";
63 services.postgresql = {
65 local ${database} ${user} trust
67 ensureDatabases = [ database ];
71 ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
78 "d ${statePath} 0750 ${user} ${user} -"
82 todosrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
83 after = [ "postgresql.service" "network.target" ];
84 requires = [ "postgresql.service" ];
85 wantedBy = [ "multi-user.target" ];
87 description = "todo.sr.ht website service";
89 serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
93 after = [ "postgresql.service" "network.target" ];
94 bindsTo = [ "postgresql.service" ];
95 wantedBy = [ "multi-user.target" ];
97 description = "todo.sr.ht process service";
102 ExecStart = "${cfg.python}/bin/todosrht-lmtp";
106 todosrht-webhooks = {
107 after = [ "postgresql.service" "network.target" ];
108 requires = [ "postgresql.service" ];
109 wantedBy = [ "multi-user.target" ];
111 description = "todo.sr.ht webhooks service";
116 ExecStart = "${cfg.python}/bin/celery -A ${drv.pname}.webhooks worker --loglevel INFO --pool eventlet";
123 services.sourcehut.settings = {
124 # URL todo.sr.ht is being served at (protocol://domain)
125 "todo.sr.ht".origin = mkDefault "http://todo.${cfg.originBase}";
126 # Address and port to bind the debug server to
127 "todo.sr.ht".debug-host = mkDefault "0.0.0.0";
128 "todo.sr.ht".debug-port = mkDefault port;
129 # Configures the SQLAlchemy connection string for the database.
130 "todo.sr.ht".connection-string = mkDefault "postgresql:///${database}?user=${user}&host=/var/run/postgresql";
131 # todo.sr.ht's OAuth client ID and secret for meta.sr.ht
132 # Register your client at meta.example.org/oauth
133 "todo.sr.ht".oauth-client-id = mkDefault null;
134 "todo.sr.ht".oauth-client-secret = mkDefault null;
135 # Outgoing email for notifications generated by users
136 "todo.sr.ht".notify-from = mkDefault "CHANGEME@example.org";
137 # The redis connection used for the webhooks worker
138 "todo.sr.ht".webhooks = mkDefault "redis://${rcfg.bind}:${toString rcfg.port}/1";
140 "todo.sr.ht".network-key = mkDefault null;
142 # Path for the lmtp daemon's unix socket. Direct incoming mail to this socket.
143 # Alternatively, specify IP:PORT and an SMTP server will be run instead.
144 "todo.sr.ht::mail".sock = mkDefault "/tmp/todo.sr.ht-lmtp.sock";
145 # The lmtp daemon will make the unix socket group-read/write for users in this
147 "todo.sr.ht::mail".sock-group = mkDefault "postfix";
149 "todo.sr.ht::mail".posting-domain = mkDefault "todo.${cfg.originBase}";
152 services.nginx.virtualHosts."todo.${cfg.originBase}" = {
154 locations."/".proxyPass = "http://${cfg.address}:${toString port}";
155 locations."/query".proxyPass = "http://${cfg.address}:${toString (port + 100)}";
156 locations."/static".root = "${pkgs.sourcehut.todosrht}/${pkgs.sourcehut.python.sitePackages}/todosrht";