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 # Set to "yes" to automatically run migrations on package upgrade.
132 "todo.sr.ht".migrate-on-upgrade = mkDefault "yes";
133 # todo.sr.ht's OAuth client ID and secret for meta.sr.ht
134 # Register your client at meta.example.org/oauth
135 "todo.sr.ht".oauth-client-id = mkDefault null;
136 "todo.sr.ht".oauth-client-secret = mkDefault null;
137 # Outgoing email for notifications generated by users
138 "todo.sr.ht".notify-from = mkDefault "CHANGEME@example.org";
139 # The redis connection used for the webhooks worker
140 "todo.sr.ht".webhooks = mkDefault "redis://${rcfg.bind}:${toString rcfg.port}/1";
142 "todo.sr.ht".network-key = mkDefault null;
144 # Path for the lmtp daemon's unix socket. Direct incoming mail to this socket.
145 # Alternatively, specify IP:PORT and an SMTP server will be run instead.
146 "todo.sr.ht::mail".sock = mkDefault "/tmp/todo.sr.ht-lmtp.sock";
147 # The lmtp daemon will make the unix socket group-read/write for users in this
149 "todo.sr.ht::mail".sock-group = mkDefault "postfix";
151 "todo.sr.ht::mail".posting-domain = mkDefault "todo.${cfg.originBase}";
154 services.nginx.virtualHosts."todo.${cfg.originBase}" = {
156 locations."/".proxyPass = "http://${cfg.address}:${toString port}";
157 locations."/query".proxyPass = "http://${cfg.address}:${toString (port + 100)}";
158 locations."/static".root = "${pkgs.sourcehut.todosrht}/${pkgs.sourcehut.python.sitePackages}/todosrht";