This repository has been archived on 2026-04-18. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
server-config/services/monero/xmrig-auto-pause.nix
Simon Gardling e57c9cb83b
All checks were successful
Build and Deploy / deploy (push) Successful in 1m59s
xmrig-auto-pause: raise thresholds for server background load
2026-04-07 01:09:16 -04:00

39 lines
1.1 KiB
Nix

{
config,
lib,
pkgs,
...
}:
lib.mkIf config.services.xmrig.enable {
systemd.services.xmrig-auto-pause = {
description = "Auto-pause xmrig when other services need CPU";
after = [ "xmrig.service" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${pkgs.python3}/bin/python3 ${./xmrig-auto-pause.py}";
Restart = "always";
RestartSec = "10s";
NoNewPrivileges = true;
ProtectHome = true;
ProtectSystem = "strict";
PrivateTmp = true;
RestrictAddressFamilies = [
"AF_UNIX" # systemctl talks to systemd over D-Bus unix socket
];
MemoryDenyWriteExecute = true;
StateDirectory = "xmrig-auto-pause";
};
environment = {
POLL_INTERVAL = "3";
GRACE_PERIOD = "15";
# This server's background services (qbittorrent, monero, bazarr, etc.)
# produce 5-14% non-nice CPU during normal operation. Thresholds must
# sit above that noise floor.
CPU_STOP_THRESHOLD = "40";
CPU_RESUME_THRESHOLD = "30";
STARTUP_COOLDOWN = "10";
STATE_DIR = "/var/lib/xmrig-auto-pause";
};
};
}