1 { config, lib, pkgs, ... }:
5 cfg = config.services.sourcehut;
9 statePath = "/var/lib/sourcehut/mansrht";
11 drv = pkgs.sourcehut.mansrht;
14 options.services.sourcehut.man = {
27 Port on which the "man" module should listen.
33 default = "man.sr.ht";
35 PostgreSQL database name for man.sr.ht.
40 config = with scfg; lib.mkIf (cfg.enable && elem "man" cfg.services) {
44 assertion = hasAttrByPath [ "git.sr.ht" "oauth-client-id" ] cfgIni;
45 message = "man.sr.ht needs access to git.sr.ht.";
54 description = "man.sr.ht user";
63 services.postgresql = {
65 local ${database} ${user} trust
67 ensureDatabases = [ database ];
71 ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
77 services.mansrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
78 after = [ "postgresql.service" "network.target" ];
79 requires = [ "postgresql.service" ];
80 wantedBy = [ "multi-user.target" ];
82 description = "man.sr.ht website service";
84 serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
88 services.nginx.virtualHosts."man.${cfg.originBase}" = {
90 locations."/".proxyPass = "http://${cfg.address}:${toString port}";
91 locations."/query".proxyPass = cfgIni."meta.sr.ht".api-origin;
92 locations."/static".root = "${pkgs.sourcehut.mansrht}/${pkgs.sourcehut.python.sitePackages}/mansrht";