95 lines
2.4 KiB
Nix
95 lines
2.4 KiB
Nix
{ config, pkgs, ... }:
|
|
let
|
|
buzzrelay = pkgs.buzzrelay.overrideAttrs {
|
|
postPatch = ''
|
|
substituteInPlace static/index.html \
|
|
--replace '</body>' '<script defer data-domain="relay.fedi.buzz" src="https://p.spaceboyz.net/js/script.js"></script></body>'
|
|
'';
|
|
};
|
|
in
|
|
{
|
|
c3d2 = {
|
|
deployment.server = "server10";
|
|
statistics.enable = true;
|
|
};
|
|
|
|
microvm = {
|
|
mem = 1024;
|
|
vcpu = 8;
|
|
};
|
|
|
|
networking.hostName = "buzzrelay";
|
|
# Don't let journald spam the disk
|
|
services.journald.extraConfig = ''
|
|
Storage=volatile
|
|
'';
|
|
|
|
sops = {
|
|
defaultSopsFile = ./secrets.yaml;
|
|
secrets = {
|
|
"buzzrelay/privKey".owner = config.services.buzzrelay.user;
|
|
"buzzrelay/pubKey".owner = config.services.buzzrelay.user;
|
|
"buzzrelay/redis/password".owner = config.services.buzzrelay.user;
|
|
};
|
|
};
|
|
|
|
services = {
|
|
buzzrelay = {
|
|
enable = true;
|
|
package = buzzrelay;
|
|
hostName = "relay.fedi.buzz";
|
|
privKeyFile = config.sops.secrets."buzzrelay/privKey".path;
|
|
pubKeyFile = config.sops.secrets."buzzrelay/pubKey".path;
|
|
redis = {
|
|
connection = "redis://fedi.buzz:6379/";
|
|
passwordFile = config.sops.secrets."buzzrelay/redis/password".path;
|
|
};
|
|
};
|
|
|
|
nginx = {
|
|
enable = true;
|
|
virtualHosts."relay.fedi.buzz" = {
|
|
forceSSL = true;
|
|
enableACME = true;
|
|
locations."/".proxyPass = "http://127.0.0.1:${toString config.services.buzzrelay.listenPort}/";
|
|
};
|
|
};
|
|
|
|
postgresql = {
|
|
package = pkgs.postgresql_16;
|
|
settings.log_min_duration_statement = 50;
|
|
upgrade.stopServices = [ "buzzrelay" ];
|
|
ensureUsers = [ {
|
|
name = "collectd";
|
|
} ];
|
|
};
|
|
|
|
collectd.plugins.postgresql = ''
|
|
<Query unique_followers>
|
|
Statement "select count(distinct id) from follows;"
|
|
<Result>
|
|
Type gauge
|
|
InstancePrefix "unique"
|
|
ValuesFrom "count"
|
|
</Result>
|
|
</Query>
|
|
<Query total_follows>
|
|
Statement "select count(id) from follows;"
|
|
<Result>
|
|
Type gauge
|
|
InstancePrefix "total"
|
|
ValuesFrom "count"
|
|
</Result>
|
|
</Query>
|
|
|
|
<Database ${config.networking.hostName}>
|
|
Param database "${config.services.buzzrelay.database}"
|
|
Query unique_followers
|
|
Query total_follows
|
|
</Database>
|
|
'';
|
|
};
|
|
|
|
system.stateVersion = "22.11";
|
|
}
|