1 { config, lib, pkgs, ... }:
5 cfg = config.services.sourcehut;
8 iniKey = "dispatch.sr.ht";
9 statePath = "/var/lib/sourcehut/dispatchsrht";
11 drv = pkgs.sourcehut.dispatchsrht;
14 options.services.sourcehut.dispatch = {
17 default = "dispatchsrht";
19 User for dispatch.sr.ht.
27 Port on which the "dispatch" module should listen.
33 default = "dispatch.sr.ht";
35 PostgreSQL database name for dispatch.sr.ht.
41 config = with scfg; lib.mkIf (cfg.enable && elem "dispatch" cfg.services) {
48 description = "dispatch.sr.ht user";
57 services.postgresql = {
59 local ${database} ${user} trust
61 ensureDatabases = [ database ];
65 ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
71 services.dispatchsrht = 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 = "dispatch.sr.ht website service";
78 serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
82 services.nginx.virtualHosts."dispatch.${cfg.originBase}" = {
84 locations."/".proxyPass = "http://${cfg.address}:${toString port}";
85 locations."/query".proxyPass = "http://${cfg.address}:${toString (port + 100)}";
86 locations."/static".root = "${pkgs.sourcehut.dispatchsrht}/${pkgs.sourcehut.python.sitePackages}/dispatchsrht";