Files
Ihar HrachyshkaandWolfgang Walther 567e8dfd8e treewide: clean up 'meta = with' pattern
This commit was created by a combination of scripts and tools:
- an ast-grep script to prefix things in meta with `lib.`,
- a modified nixf-diagnose / nixf combination to remove unused `with
lib;`, and
- regular nixfmt.

Co-authored-by: Wolfgang Walther <walther@technowledgy.de>
2025-12-10 18:09:49 +01:00

72 lines
1.8 KiB
Nix

{
config,
pkgs,
lib,
...
}:
let
cfg = config.services.xmrig;
json = pkgs.formats.json { };
configFile = json.generate "config.json" cfg.settings;
in
{
options = {
services.xmrig = {
enable = lib.mkEnableOption "XMRig Mining Software";
package = lib.mkPackageOption pkgs "xmrig" {
example = "xmrig-mo";
};
settings = lib.mkOption {
default = { };
type = json.type;
example = lib.literalExpression ''
{
autosave = true;
cpu = true;
opencl = false;
cuda = false;
pools = [
{
url = "pool.supportxmr.com:443";
user = "your-wallet";
keepalive = true;
tls = true;
}
]
}
'';
description = ''
XMRig configuration. Refer to
<https://xmrig.com/docs/miner/config>
for details on supported values.
'';
};
};
};
config = lib.mkIf cfg.enable {
hardware.cpu.x86.msr.enable = true;
systemd.services.xmrig = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
description = "XMRig Mining Software Service";
serviceConfig = {
ExecStartPre = "${lib.getExe cfg.package} --config=${configFile} --dry-run";
ExecStart = "${lib.getExe cfg.package} --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 = {
maintainers = with lib.maintainers; [ ratsclub ];
};
}