1 { config, lib, pkgs, ... }:
5 cfg = config.services.sourcehut;
10 drv = pkgs.sourcehut.hubsrht;
13 options.services.sourcehut.hub = {
26 Port on which the "hub" module should listen.
32 default = "hub.sr.ht";
34 PostgreSQL database name for hub.sr.ht.
38 statePath = mkOption {
40 default = "${cfg.statePath}/hubsrht";
42 State path for hub.sr.ht.
47 config = with scfg; lib.mkIf (cfg.enable && elem "hub" cfg.services) {
53 description = "hub.sr.ht user";
62 services.postgresql = {
64 local ${database} ${user} trust
66 ensureDatabases = [ database ];
70 ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
77 "d ${statePath} 0750 ${user} ${user} -"
80 services.hubsrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
81 after = [ "postgresql.service" "network.target" ];
82 requires = [ "postgresql.service" ];
83 wantedBy = [ "multi-user.target" ];
85 description = "hub.sr.ht website service";
87 serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
91 services.nginx.virtualHosts."${cfg.originBase}" = {
93 locations."/".proxyPass = "http://${cfg.address}:${toString port}";
94 locations."/query".proxyPass = "http://${cfg.address}:${toString (port + 100)}";
95 locations."/static".root = "${pkgs.sourcehut.hubsrht}/${pkgs.sourcehut.python.sitePackages}/hubsrht";
97 services.nginx.virtualHosts."hub.${cfg.originBase}" = {
98 globalRedirect = "${cfg.originBase}";