1 { lib, config, pkgs, ... }:
7 cfg = config.services.xmr-stak;
9 pkg = pkgs.xmr-stak.override {
10 inherit (cfg) openclSupport cudaSupport;
18 enable = mkEnableOption (lib.mdDoc "xmr-stak miner");
19 openclSupport = mkEnableOption (lib.mdDoc "support for OpenCL (AMD/ATI graphics cards)");
20 cudaSupport = mkEnableOption (lib.mdDoc "support for CUDA (NVidia graphics cards)");
22 extraArgs = mkOption {
23 type = types.listOf types.str;
25 example = [ "--noCPU" "--currency monero" ];
26 description = lib.mdDoc "List of parameters to pass to xmr-stak.";
29 configFiles = mkOption {
30 type = types.attrsOf types.str;
32 example = literalExpression ''
37 "tls_secure_algo" : true,
40 "currency" : "monero7",
42 [ { "pool_address" : "pool.supportxmr.com:443",
43 "wallet_address" : "my-wallet-address",
45 "pool_password" : "nixos",
46 "use_nicehash" : false,
48 "tls_fingerprint" : "",
55 description = lib.mdDoc ''
56 Content of config files like config.txt, pools.txt or cpu.txt.
62 config = mkIf cfg.enable {
63 systemd.services.xmr-stak = {
64 wantedBy = [ "multi-user.target" ];
65 bindsTo = [ "network-online.target" ];
66 after = [ "network-online.target" ];
67 environment = mkIf cfg.cudaSupport {
68 LD_LIBRARY_PATH = "${pkgs.linuxPackages_latest.nvidia_x11}/lib";
71 preStart = concatStrings (flip mapAttrsToList cfg.configFiles (fn: content: ''
72 ln -sf '${pkgs.writeText "xmr-stak-${fn}" content}' '${fn}'
75 serviceConfig = let rootRequired = cfg.openclSupport || cfg.cudaSupport; in {
76 ExecStart = "${pkg}/bin/xmr-stak ${concatStringsSep " " cfg.extraArgs}";
77 # xmr-stak generates cpu and/or gpu configuration files
78 WorkingDirectory = "/tmp";
80 DynamicUser = !rootRequired;
81 LimitMEMLOCK = toString (1024*1024);
87 (mkRemovedOptionModule ["services" "xmr-stak" "configText"] ''
88 This option was removed in favour of `services.xmr-stak.configFiles`
89 because the new config file `pools.txt` was introduced. You are
90 now able to define all other config files like cpu.txt or amd.txt.