61 lines
1.1 KiB
Nix
61 lines
1.1 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
hostname,
|
|
...
|
|
}:
|
|
let
|
|
walletAddress = lib.strings.trim (builtins.readFile ../secrets/xmrig-wallet);
|
|
threadCount = 2;
|
|
in
|
|
{
|
|
services.xmrig = {
|
|
enable = true;
|
|
package = pkgs.xmrig;
|
|
|
|
settings = {
|
|
autosave = true;
|
|
|
|
cpu = {
|
|
enabled = true;
|
|
huge-pages = true;
|
|
"1gb-pages" = true;
|
|
hw-aes = true;
|
|
rx = lib.range 0 (threadCount - 1);
|
|
};
|
|
|
|
opencl = false;
|
|
cuda = false;
|
|
|
|
pools = [
|
|
{
|
|
url = "gulf.moneroocean.stream:20128";
|
|
user = walletAddress;
|
|
pass = hostname + "~rx/0";
|
|
keepalive = true;
|
|
tls = true;
|
|
}
|
|
];
|
|
};
|
|
};
|
|
|
|
systemd.services.xmrig.serviceConfig = {
|
|
Nice = 19;
|
|
CPUSchedulingPolicy = "idle";
|
|
IOSchedulingClass = "idle";
|
|
};
|
|
|
|
# Stop mining on UPS battery to conserve power
|
|
services.apcupsd.hooks = lib.mkIf config.services.apcupsd.enable {
|
|
onbattery = "systemctl stop xmrig";
|
|
offbattery = "systemctl start xmrig";
|
|
};
|
|
|
|
# Reserve 1GB huge pages for RandomX (dataset is ~2GB)
|
|
boot.kernelParams = [
|
|
"hugepagesz=1G"
|
|
"hugepages=3"
|
|
];
|
|
}
|