1 { config, lib, pkgs, ... }:
5 cfg = config.services.sourcehut;
9 statePath = "/var/lib/sourcehut/hubsrht";
11 drv = pkgs.sourcehut.hubsrht;
14 options.services.sourcehut.hub = {
27 Port on which the "hub" module should listen.
33 default = "hub.sr.ht";
35 PostgreSQL database name for hub.sr.ht.
40 config = with scfg; lib.mkIf (cfg.enable && elem "hub" cfg.services) {
46 description = "hub.sr.ht user";
55 services.postgresql = {
57 local ${database} ${user} trust
59 ensureDatabases = [ database ];
63 ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
69 services.hubsrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
70 after = [ "postgresql.service" "network.target" ];
71 requires = [ "postgresql.service" ];
72 wantedBy = [ "multi-user.target" ];
74 description = "hub.sr.ht website service";
76 serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
80 services.nginx.virtualHosts."${cfg.originBase}" = {
82 locations."/".proxyPass = "http://${cfg.address}:${toString port}";
83 locations."/query".proxyPass = cfgIni."meta.sr.ht".api-origin;
84 locations."/static".root = "${pkgs.sourcehut.hubsrht}/${pkgs.sourcehut.python.sitePackages}/hubsrht";
86 services.nginx.virtualHosts."hub.${cfg.originBase}" = {
87 globalRedirect = "${cfg.originBase}";