diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 82e3dfe4525d..ea87c48705ec 100755 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -158,6 +158,7 @@ ./services/mail/postfix.nix ./services/mail/spamassassin.nix #./services/misc/autofs.nix + ./services/misc/cpuminer-cryptonight.nix ./services/misc/cgminer.nix ./services/misc/dictd.nix ./services/misc/disnix.nix diff --git a/nixos/modules/services/misc/cpuminer-cryptonight.nix b/nixos/modules/services/misc/cpuminer-cryptonight.nix new file mode 100644 index 000000000000..f31526f8d107 --- /dev/null +++ b/nixos/modules/services/misc/cpuminer-cryptonight.nix @@ -0,0 +1,66 @@ +{ config, lib, pkgs, ... }: + +with lib; + +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 = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to enable the cpuminer cryptonight miner. + ''; + }; + url = mkOption { + type = types.string; + description = "URL of mining server"; + }; + user = mkOption { + type = types.string; + description = "Username for mining server"; + }; + pass = mkOption { + type = types.string; + default = "x"; + description = "Password for mining server"; + }; + threads = mkOption { + type = types.int; + default = 0; + description = "Number of miner threads, defaults to available processors"; + }; + }; + + }; + + config = mkIf config.services.cpuminer-cryptonight.enable { + + 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"; + }; + }; + + }; + +} \ No newline at end of file diff --git a/pkgs/tools/misc/cpuminer-multi/default.nix b/pkgs/tools/misc/cpuminer-multi/default.nix index c61e0ff00b3f..220063107803 100644 --- a/pkgs/tools/misc/cpuminer-multi/default.nix +++ b/pkgs/tools/misc/cpuminer-multi/default.nix @@ -1,9 +1,9 @@ -{ stdenv, fetchgit, curl, jansson, autoconf, automake, openssl +{ stdenv, fetchgit, curl, jansson, autoconf, automake , aesni ? true }: let - rev = "4230012da5d1cc491976c6f5e45da36db6d9f576"; - date = "20140619"; + rev = "977dad27e18627e5b723800f5f4201e385fe0d2e"; + date = "20140723"; in stdenv.mkDerivation rec { name = "cpuminer-multi-${date}-${stdenv.lib.strings.substring 0 7 rev}"; @@ -11,16 +11,16 @@ stdenv.mkDerivation rec { src = fetchgit { inherit rev; url = https://github.com/wolf9466/cpuminer-multi.git; - sha256 = "c19a5dd1bfdbbaec3729f61248e858a5d8701424fffe67fdabf8179ced9c110b"; + sha256 = "9c438c6cd9f40273822f3d3103a370e43e8a40368695ed5e01ae87297dce7843"; }; - buildInputs = [ autoconf automake curl jansson openssl ]; + buildInputs = [ autoconf automake curl jansson ]; preConfigure = '' ./autogen.sh ''; - configureFlags = if aesni then [ "--disable-aes-ni" ] else [ ]; + configureFlags = [ (if aesni then "--enable-aes-ni" else "--disable-aes-ni") ]; meta = with stdenv.lib; { description = "Multi-algo CPUMiner";