1 { config, lib, pkgs, ... }:
5 cfg = config.services.sourcehut;
8 iniKey = "paste.sr.ht";
9 statePath = "/var/lib/sourcehut/pastesrht";
11 rcfg = config.services.redis;
12 drv = pkgs.sourcehut.pastesrht;
15 options.services.sourcehut.paste = {
16 enable = mkEnableOption "paste service";
20 default = "pastesrht";
30 Port on which the "paste" module should listen.
36 default = "paste.sr.ht";
38 PostgreSQL database name for paste.sr.ht.
43 config = with scfg; lib.mkIf (cfg.enable && scfg.enable) {
49 description = "paste.sr.ht user";
58 services.postgresql = {
60 local ${database} ${user} trust
62 ensureDatabases = [ database ];
66 ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
73 pastesrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
74 after = [ "postgresql.service" "network.target" ];
75 requires = [ "postgresql.service" ];
76 wantedBy = [ "multi-user.target" ];
78 description = "paste.sr.ht website service";
80 serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
83 pastesrht-webhooks = {
84 after = [ "postgresql.service" "network.target" ];
85 requires = [ "postgresql.service" ];
86 wantedBy = [ "multi-user.target" ];
88 description = "paste.sr.ht webhooks service";
93 ExecStart = "${cfg.python}/bin/celery -A ${drv.pname}.webhooks worker --loglevel INFO --pool eventlet";
100 services.sourcehut.settings = {
103 services.nginx.virtualHosts."paste.${cfg.originBase}" = {
105 locations."/".proxyPass = "http://${cfg.address}:${toString port}";
106 locations."/query".proxyPass = cfgIni."meta.sr.ht".api-origin;
107 locations."/static".root = "${pkgs.sourcehut.pastesrht}/${pkgs.sourcehut.python.sitePackages}/pastesrht";