2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.services.cpuminer-cryptonight;
|
|
|
|
|
|
|
|
json = builtins.toJSON (
|
|
|
|
cfg // {
|
|
|
|
enable = null;
|
|
|
|
threads =
|
|
|
|
if cfg.threads == 0 then null else toString cfg.threads;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
confFile = builtins.toFile "cpuminer.json" json;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.cpuminer-cryptonight = {
|
2024-09-19 14:19:46 +00:00
|
|
|
enable = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = false;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Whether to enable the cpuminer cryptonight miner.
|
|
|
|
'';
|
|
|
|
};
|
2024-09-19 14:19:46 +00:00
|
|
|
url = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "URL of mining server";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2024-09-19 14:19:46 +00:00
|
|
|
user = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Username for mining server";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2024-09-19 14:19:46 +00:00
|
|
|
pass = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = "x";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Password for mining server";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2024-09-19 14:19:46 +00:00
|
|
|
threads = lib.mkOption {
|
|
|
|
type = lib.types.int;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = 0;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Number of miner threads, defaults to available processors";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
config = lib.mkIf config.services.cpuminer-cryptonight.enable {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
systemd.services.cpuminer-cryptonight = {
|
|
|
|
description = "Cryptonight cpuminer";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.cpuminer-multi}/bin/minerd --syslog --config=${confFile}";
|
|
|
|
User = "nobody";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|