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 (lib.mdDoc "XMRig Mining Software");
21 defaultText = literalExpression "pkgs.xmrig";
22 example = literalExpression "pkgs.xmrig-mo";
23 description = lib.mdDoc "XMRig package to use.";
29 example = literalExpression ''
37 url = "pool.supportxmr.com:443";
45 description = lib.mdDoc ''
46 XMRig configuration. Refer to
47 <https://xmrig.com/docs/miner/config>
48 for details on supported values.
54 config = mkIf cfg.enable {
55 boot.kernelModules = [ "msr" ];
57 systemd.services.xmrig = {
58 wantedBy = [ "multi-user.target" ];
59 after = [ "network.target" ];
60 description = "XMRig Mining Software Service";
62 ExecStartPre = "${cfg.package}/bin/xmrig --config=${configFile} --dry-run";
63 ExecStart = "${cfg.package}/bin/xmrig --config=${configFile}";
64 # https://xmrig.com/docs/miner/randomx-optimization-guide/msr
65 # If you use recent XMRig with root privileges (Linux) or admin
66 # privileges (Windows) the miner configure all MSR registers
68 DynamicUser = lib.mkDefault false;
74 maintainers = with maintainers; [ ratsclub ];