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 = {
18 default = "pastesrht";
28 Port on which the "paste" module should listen.
34 default = "paste.sr.ht";
36 PostgreSQL database name for paste.sr.ht.
41 config = with scfg; lib.mkIf (cfg.enable && elem "paste" cfg.services) {
47 description = "paste.sr.ht user";
56 services.postgresql = {
58 local ${database} ${user} trust
60 ensureDatabases = [ database ];
64 ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
71 pastesrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
72 after = [ "postgresql.service" "network.target" ];
73 requires = [ "postgresql.service" ];
74 wantedBy = [ "multi-user.target" ];
76 description = "paste.sr.ht website service";
78 serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
81 pastesrht-webhooks = {
82 after = [ "postgresql.service" "network.target" ];
83 requires = [ "postgresql.service" ];
84 wantedBy = [ "multi-user.target" ];
86 description = "paste.sr.ht webhooks service";
91 ExecStart = "${cfg.python}/bin/celery -A ${drv.pname}.webhooks worker --loglevel INFO --pool eventlet";
98 services.sourcehut.settings = {
101 services.nginx.virtualHosts."paste.${cfg.originBase}" = {
103 locations."/".proxyPass = "http://${cfg.address}:${toString port}";
104 locations."/query".proxyPass = cfgIni."meta.sr.ht".api-origin;
105 locations."/static".root = "${pkgs.sourcehut.pastesrht}/${pkgs.sourcehut.python.sitePackages}/pastesrht";