1 { config, pkgs, lib, ... }:
5 cfg = config.services.xmrig;
7 json = pkgs.formats.json { };
8 configFile = json.generate "config.json" cfg.settings;
16 enable = mkEnableOption "XMRig Mining Software";
18 package = mkPackageOption pkgs "xmrig" {
25 example = literalExpression ''
33 url = "pool.supportxmr.com:443";
42 XMRig configuration. Refer to
43 <https://xmrig.com/docs/miner/config>
44 for details on supported values.
50 config = mkIf cfg.enable {
51 hardware.cpu.x86.msr.enable = true;
53 systemd.services.xmrig = {
54 wantedBy = [ "multi-user.target" ];
55 after = [ "network.target" ];
56 description = "XMRig Mining Software Service";
58 ExecStartPre = "${lib.getExe cfg.package} --config=${configFile} --dry-run";
59 ExecStart = "${lib.getExe cfg.package} --config=${configFile}";
60 # https://xmrig.com/docs/miner/randomx-optimization-guide/msr
61 # If you use recent XMRig with root privileges (Linux) or admin
62 # privileges (Windows) the miner configure all MSR registers
64 DynamicUser = lib.mkDefault false;
70 maintainers = with maintainers; [ ratsclub ];