at 24.11-pre 2.6 kB view raw
1{ lib, config, pkgs, ... }: 2 3with lib; 4 5let 6 7 cfg = config.services.xmr-stak; 8 9 pkg = pkgs.xmr-stak.override { 10 inherit (cfg) openclSupport; 11 }; 12 13in 14 15{ 16 options = { 17 services.xmr-stak = { 18 enable = mkEnableOption "xmr-stak miner"; 19 openclSupport = mkEnableOption "support for OpenCL (AMD/ATI graphics cards)"; 20 21 extraArgs = mkOption { 22 type = types.listOf types.str; 23 default = []; 24 example = [ "--noCPU" "--currency monero" ]; 25 description = "List of parameters to pass to xmr-stak."; 26 }; 27 28 configFiles = mkOption { 29 type = types.attrsOf types.str; 30 default = {}; 31 example = literalExpression '' 32 { 33 "config.txt" = ''' 34 "verbose_level" : 4, 35 "h_print_time" : 60, 36 "tls_secure_algo" : true, 37 '''; 38 "pools.txt" = ''' 39 "currency" : "monero7", 40 "pool_list" : 41 [ { "pool_address" : "pool.supportxmr.com:443", 42 "wallet_address" : "my-wallet-address", 43 "rig_id" : "", 44 "pool_password" : "nixos", 45 "use_nicehash" : false, 46 "use_tls" : true, 47 "tls_fingerprint" : "", 48 "pool_weight" : 23 49 }, 50 ], 51 '''; 52 } 53 ''; 54 description = '' 55 Content of config files like config.txt, pools.txt or cpu.txt. 56 ''; 57 }; 58 }; 59 }; 60 61 config = mkIf cfg.enable { 62 systemd.services.xmr-stak = { 63 wantedBy = [ "multi-user.target" ]; 64 bindsTo = [ "network-online.target" ]; 65 after = [ "network-online.target" ]; 66 67 preStart = concatStrings (flip mapAttrsToList cfg.configFiles (fn: content: '' 68 ln -sf '${pkgs.writeText "xmr-stak-${fn}" content}' '${fn}' 69 '')); 70 71 serviceConfig = let rootRequired = cfg.openclSupport; in { 72 ExecStart = "${pkg}/bin/xmr-stak ${concatStringsSep " " cfg.extraArgs}"; 73 # xmr-stak generates cpu and/or gpu configuration files 74 WorkingDirectory = "/tmp"; 75 PrivateTmp = true; 76 DynamicUser = !rootRequired; 77 LimitMEMLOCK = toString (1024*1024); 78 }; 79 }; 80 }; 81 82 imports = [ 83 (mkRemovedOptionModule ["services" "xmr-stak" "configText"] '' 84 This option was removed in favour of `services.xmr-stak.configFiles` 85 because the new config file `pools.txt` was introduced. You are 86 now able to define all other config files like cpu.txt or amd.txt. 87 '') 88 ]; 89}