2021-11-06 19:04:14 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.xmrig;
|
|
|
|
|
|
|
|
json = pkgs.formats.json { };
|
|
|
|
configFile = json.generate "config.json" cfg.settings;
|
|
|
|
in
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.xmrig = {
|
|
|
|
enable = mkEnableOption (lib.mdDoc "XMRig Mining Software");
|
|
|
|
|
2023-11-27 01:19:27 +01:00
|
|
|
package = mkPackageOption pkgs "xmrig" {
|
|
|
|
example = "xmrig-mo";
|
2021-11-06 19:04:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
default = { };
|
|
|
|
type = json.type;
|
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
autosave = true;
|
|
|
|
cpu = true;
|
|
|
|
opencl = false;
|
|
|
|
cuda = false;
|
|
|
|
pools = [
|
|
|
|
{
|
|
|
|
url = "pool.supportxmr.com:443";
|
|
|
|
user = "your-wallet";
|
|
|
|
keepalive = true;
|
|
|
|
tls = true;
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
XMRig configuration. Refer to
|
|
|
|
<https://xmrig.com/docs/miner/config>
|
|
|
|
for details on supported values.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2023-10-16 21:41:58 +02:00
|
|
|
hardware.cpu.x86.msr.enable = true;
|
2021-11-17 20:08:38 +01:00
|
|
|
|
2021-11-06 19:04:14 +01:00
|
|
|
systemd.services.xmrig = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
description = "XMRig Mining Software Service";
|
|
|
|
serviceConfig = {
|
2023-10-28 02:24:20 +02:00
|
|
|
ExecStartPre = "${lib.getExe cfg.package} --config=${configFile} --dry-run";
|
|
|
|
ExecStart = "${lib.getExe cfg.package} --config=${configFile}";
|
2021-11-17 20:08:38 +01:00
|
|
|
# https://xmrig.com/docs/miner/randomx-optimization-guide/msr
|
|
|
|
# If you use recent XMRig with root privileges (Linux) or admin
|
|
|
|
# privileges (Windows) the miner configure all MSR registers
|
|
|
|
# automatically.
|
|
|
|
DynamicUser = lib.mkDefault false;
|
2021-11-06 19:04:14 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
maintainers = with maintainers; [ ratsclub ];
|
|
|
|
};
|
|
|
|
}
|