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 = {
15 enable = mkEnableOption "man service";
29 Port on which the "man" module should listen.
35 default = "man.sr.ht";
37 PostgreSQL database name for man.sr.ht.
42 config = with scfg; lib.mkIf (cfg.enable && scfg.enable) {
46 assertion = hasAttrByPath [ "git.sr.ht" "oauth-client-id" ] cfgIni;
47 message = "man.sr.ht needs access to git.sr.ht.";
56 description = "man.sr.ht user";
65 services.postgresql = {
67 local ${database} ${user} trust
69 ensureDatabases = [ database ];
73 ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
79 services.mansrht = import ./service.nix { inherit config pkgs lib; initDB = true; } scfg drv iniKey {
80 after = [ "postgresql.service" "network.target" ];
81 requires = [ "postgresql.service" ];
82 wantedBy = [ "multi-user.target" ];
84 description = "man.sr.ht website service";
86 serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
90 services.nginx.virtualHosts."man.${cfg.originBase}" = {
92 locations."/".proxyPass = "http://${cfg.address}:${toString port}";
93 locations."/query".proxyPass = cfgIni."meta.sr.ht".api-origin;
94 locations."/static".root = "${pkgs.sourcehut.mansrht}/${pkgs.sourcehut.python.sitePackages}/mansrht";