p2pool: init

This commit is contained in:
2026-03-11 11:01:25 -04:00
parent 393553c6c5
commit 01dbfc69a5
6 changed files with 83 additions and 0 deletions

48
services/p2pool.nix Normal file
View File

@@ -0,0 +1,48 @@
{
config,
service_configs,
lib,
...
}:
let
walletAddress = lib.strings.trim (builtins.readFile ../secrets/xmrig-wallet);
in
{
imports = [
(lib.serviceMountWithZpool "p2pool" service_configs.zpool_hdds [
service_configs.p2pool.dataDir
])
(lib.serviceFilePerms "p2pool" [
"Z ${service_configs.p2pool.dataDir} 0700 p2pool p2pool"
])
];
services.p2pool = {
enable = true;
dataDir = service_configs.p2pool.dataDir;
walletAddress = walletAddress;
sidechain = "nano";
host = "127.0.0.1";
rpcPort = service_configs.ports.monero_rpc;
zmqPort = service_configs.ports.monero_zmq;
extraArgs = [
"--stratum 0.0.0.0:${builtins.toString service_configs.ports.p2pool_stratum}"
];
};
# Ensure p2pool starts after monero is ready
systemd.services.p2pool = {
after = [ "monero.service" ];
wants = [ "monero.service" ];
};
# Stop p2pool on UPS battery to conserve power
services.apcupsd.hooks = lib.mkIf config.services.apcupsd.enable {
onbattery = "systemctl stop p2pool";
offbattery = "systemctl start p2pool";
};
networking.firewall.allowedTCPPorts = [
service_configs.ports.p2pool_p2p
];
}