blob: a98b2292f559d1d94b37f0574fec32e052367dbb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
{ 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 "XMRig Mining Software";
package = mkOption {
type = types.package;
default = pkgs.xmrig;
defaultText = literalExpression "pkgs.xmrig";
example = literalExpression "pkgs.xmrig-mo";
description = lib.mdDoc "XMRig package to use.";
};
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 {
boot.kernelModules = [ "msr" ];
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}";
# 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;
};
};
};
meta = with lib; {
maintainers = with maintainers; [ ratsclub ];
};
}
|