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 = {
|
2022-08-28 21:18:44 +02:00
|
|
|
enable = mkEnableOption (lib.mdDoc "XMRig Mining Software");
|
2021-11-06 19:04:14 +01:00
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.xmrig;
|
2021-11-26 01:16:05 +01:00
|
|
|
defaultText = literalExpression "pkgs.xmrig";
|
2021-11-06 19:04:14 +01:00
|
|
|
example = literalExpression "pkgs.xmrig-mo";
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "XMRig package to use.";
|
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;
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
'';
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc ''
|
2021-11-06 19:04:14 +01:00
|
|
|
XMRig configuration. Refer to
|
2022-07-28 23:19:15 +02:00
|
|
|
<https://xmrig.com/docs/miner/config>
|
2021-11-06 19:04:14 +01:00
|
|
|
for details on supported values.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-11-17 20:08:38 +01:00
|
|
|
boot.kernelModules = [ "msr" ];
|
|
|
|
|
2021-11-06 19:04:14 +01:00
|
|
|
systemd.services.xmrig = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
description = "XMRig Mining Software Service";
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStartPre = "${cfg.package}/bin/xmrig --config=${configFile} --dry-run";
|
|
|
|
ExecStart = "${cfg.package}/bin/xmrig --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 ];
|
|
|
|
};
|
|
|
|
}
|