diff --git a/configuration.nix b/configuration.nix index e9d1265..7ce700a 100644 --- a/configuration.nix +++ b/configuration.nix @@ -39,6 +39,7 @@ ./services/bitwarden.nix ./services/monero.nix + ./services/xmrig.nix # KEEP UNTIL 2028 ./services/caddy_senior_project.nix diff --git a/secrets/xmrig-wallet b/secrets/xmrig-wallet new file mode 100644 index 0000000..64676de Binary files /dev/null and b/secrets/xmrig-wallet differ diff --git a/services/xmrig.nix b/services/xmrig.nix new file mode 100644 index 0000000..0763655 --- /dev/null +++ b/services/xmrig.nix @@ -0,0 +1,53 @@ +{ + 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; + 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"; + }; +}