diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 56c44a43c6e..236842ecb0b 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -395,6 +395,7 @@ ./services/misc/emby.nix ./services/misc/errbot.nix ./services/misc/etcd.nix + ./services/misc/ethminer.nix ./services/misc/exhibitor.nix ./services/misc/felix.nix ./services/misc/folding-at-home.nix diff --git a/nixos/modules/services/misc/ethminer.nix b/nixos/modules/services/misc/ethminer.nix new file mode 100644 index 00000000000..2958cf21447 --- /dev/null +++ b/nixos/modules/services/misc/ethminer.nix @@ -0,0 +1,115 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.ethminer; + poolUrl = escapeShellArg "stratum1+tcp://${cfg.wallet}@${cfg.pool}:${toString cfg.stratumPort}/${cfg.rig}/${cfg.registerMail}"; +in + +{ + + ###### interface + + options = { + + services.ethminer = { + + enable = mkOption { + type = types.bool; + default = false; + description = "Enable ethminer ether mining."; + }; + + recheckInterval = mkOption { + type = types.int; + default = 2000; + description = "Interval in milliseconds between farm rechecks."; + }; + + toolkit = mkOption { + type = types.enum [ "cuda" "opencl" ]; + default = "cuda"; + description = "Cuda or opencl toolkit."; + }; + + apiPort = mkOption { + type = types.int; + default = -3333; + description = "Ethminer api port. minus sign puts api in read-only mode."; + }; + + wallet = mkOption { + type = types.str; + example = "0x0123456789abcdef0123456789abcdef01234567"; + description = "Ethereum wallet address."; + }; + + pool = mkOption { + type = types.str; + example = "eth-us-east1.nanopool.org"; + description = "Mining pool address."; + }; + + stratumPort = mkOption { + type = types.port; + default = 9999; + description = "Stratum protocol tcp port."; + }; + + rig = mkOption { + type = types.str; + default = "mining-rig-name"; + description = "Mining rig name."; + }; + + registerMail = mkOption { + type = types.str; + example = "email%40example.org"; + description = "Url encoded email address to register with pool."; + }; + + maxPower = mkOption { + type = types.int; + default = 115; + description = "Miner max watt usage."; + }; + + }; + + }; + + + ###### implementation + + config = mkIf cfg.enable { + + systemd.services.ethminer = { + path = [ pkgs.cudatoolkit ]; + description = "ethminer ethereum mining service"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + + serviceConfig = { + DynamicUser = true; + ExecStartPost = optional (cfg.toolkit == "cuda") "+${getBin config.boot.kernelPackages.nvidia_x11}/bin/nvidia-smi -pl ${toString cfg.maxPower}"; + }; + + environment = { + LD_LIBRARY_PATH = "${config.boot.kernelPackages.nvidia_x11}/lib"; + }; + + script = '' + ${pkgs.ethminer}/bin/.ethminer-wrapped \ + --farm-recheck ${toString cfg.recheckInterval} \ + --report-hashrate \ + --${cfg.toolkit} \ + --api-port ${toString cfg.apiPort} \ + --pool ${poolUrl} + ''; + + }; + + }; + +} diff --git a/pkgs/development/libraries/ethash/default.nix b/pkgs/development/libraries/ethash/default.nix new file mode 100644 index 00000000000..da2fd13465f --- /dev/null +++ b/pkgs/development/libraries/ethash/default.nix @@ -0,0 +1,58 @@ +{ stdenv, fetchFromGitHub, cmake, boost, cryptopp, opencl-headers, opencl-info, + openmpi, ocl-icd, mesa, gbenchmark, gtest }: + +stdenv.mkDerivation rec { + pname = "ethash"; + version = "0.4.2"; + + src = + fetchFromGitHub { + owner = "chfast"; + repo = "ethash"; + rev = "v${version}"; + sha256 = "0qiixvxbpl2gz7jh1qs8lmyk7wzv6ffnl7kckqgrpgm547nnn8zy"; + }; + + nativeBuildInputs = [ + cmake + ]; + + buildInputs = [ + boost + cryptopp + opencl-headers + opencl-info + openmpi + ocl-icd + mesa + ]; + + checkInputs = [ + gbenchmark + gtest + ]; + + #preConfigure = '' + # sed -i 's/GTest::main//' test/unittests/CMakeLists.txt + # cat test/unittests/CMakeLists.txt + # ln -sfv ${gtest.src}/googletest gtest + #''; + + # NOTE: disabling tests due to gtest issue + cmakeFlags = [ + "-DHUNTER_ENABLED=OFF" + "-DETHASH_BUILD_TESTS=OFF" + #"-Dbenchmark_DIR=${gbenchmark}/lib/cmake/benchmark" + #"-DGTest_DIR=${gtest.dev}/lib/cmake/GTest" + #"-DGTest_DIR=${gtest.src}/googletest" + #"-DCMAKE_PREFIX_PATH=${gtest.dev}/lib/cmake" + ]; + + meta = with stdenv.lib; { + description = "PoW algorithm for Ethereum 1.0 based on Dagger-Hashimoto"; + homepage = https://github.com/ethereum/ethash; + platforms = [ "x86_64-linux" ]; + maintainers = with maintainers; [ nand0p ]; + license = licenses.asl20; + }; +} diff --git a/pkgs/development/libraries/jsoncpp/default.nix b/pkgs/development/libraries/jsoncpp/default.nix index 1c62d79ed32..b543d47a050 100644 --- a/pkgs/development/libraries/jsoncpp/default.nix +++ b/pkgs/development/libraries/jsoncpp/default.nix @@ -1,10 +1,7 @@ -{ stdenv -, fetchFromGitHub -, cmake -, python -}: +{ stdenv , fetchFromGitHub , cmake , python }: + stdenv.mkDerivation rec { - name = "jsoncpp-${version}"; + pname = "jsoncpp"; version = "1.8.4"; src = fetchFromGitHub { @@ -36,13 +33,14 @@ stdenv.mkDerivation rec { cmakeFlags = [ "-DBUILD_SHARED_LIBS=ON" "-DBUILD_STATIC_LIBS=OFF" + "-DJSONCPP_WITH_CMAKE_PACKAGE=ON" ]; meta = with stdenv.lib; { inherit version; homepage = https://github.com/open-source-parsers/jsoncpp; description = "A C++ library for interacting with JSON."; - maintainers = with maintainers; [ ttuegel cpages ]; + maintainers = with maintainers; [ ttuegel cpages nand0p ]; license = licenses.mit; platforms = platforms.all; }; diff --git a/pkgs/development/tools/misc/cli11/default.nix b/pkgs/development/tools/misc/cli11/default.nix new file mode 100644 index 00000000000..904119bd6ae --- /dev/null +++ b/pkgs/development/tools/misc/cli11/default.nix @@ -0,0 +1,35 @@ +{ stdenv, fetchFromGitHub, cmake, gtest, python, boost }: + +stdenv.mkDerivation rec { + pname = "cli11"; + version = "1.7.1"; + + src = fetchFromGitHub { + owner = "CLIUtils"; + repo = "CLI11"; + rev = "v${version}"; + sha256 = "0wddck970pczk7c201i2g6s85mkv4f2f4zxy6mndh3pfz41wcs2d"; + }; + + nativeBuildInputs = [ cmake ]; + + checkInputs = [ boost python ]; + + doCheck = true; + + preConfigure = '' + rm -rfv extern/googletest + ln -sfv ${gtest.src} extern/googletest + ''; + + enableParallelBuilding = true; + + meta = with stdenv.lib; { + description = "CLI11 is a command line parser for C++11"; + homepage = https://github.com/CLIUtils/CLI11; + platforms = [ "x86_64-linux" ]; + maintainers = with maintainers; [ nand0p ]; + license = licenses.unfreeRedistributable; + }; + +} diff --git a/pkgs/tools/misc/ethminer/default.nix b/pkgs/tools/misc/ethminer/default.nix new file mode 100644 index 00000000000..8a270ed0fef --- /dev/null +++ b/pkgs/tools/misc/ethminer/default.nix @@ -0,0 +1,61 @@ +{ stdenv, fetchFromGitHub, opencl-headers, cmake, jsoncpp, boost, makeWrapper, + cudatoolkit, mesa, ethash, opencl-info, ocl-icd, openssl, pkg-config, cli11 }: + +stdenv.mkDerivation rec { + pname = "ethminer"; + version = "0.18.0-rc.0"; + + src = + fetchFromGitHub { + owner = "ethereum-mining"; + repo = "ethminer"; + rev = "v${version}"; + sha256 = "0gwnwxahjfwr4d2aci7y3w206nc5ifssl28ildva98ys0d24wy7z"; + fetchSubmodules = true; + }; + + # NOTE: dbus is broken + cmakeFlags = [ + "-DHUNTER_ENABLED=OFF" + "-DETHASHCUDA=ON" + "-DAPICORE=ON" + "-DETHDBUS=OFF" + "-DCMAKE_BUILD_TYPE=Release" + ]; + + nativeBuildInputs = [ + cmake + pkg-config + makeWrapper + ]; + + buildInputs = [ + cli11 + boost + opencl-headers + mesa + cudatoolkit + ethash + opencl-info + ocl-icd + openssl + jsoncpp + ]; + + preConfigure = '' + sed -i 's/_lib_static//' libpoolprotocols/CMakeLists.txt + ''; + + postInstall = '' + wrapProgram $out/bin/ethminer --prefix LD_LIBRARY_PATH : /run/opengl-driver/lib + ''; + + meta = with stdenv.lib; { + description = "Ethereum miner with OpenCL, CUDA and stratum support"; + homepage = https://github.com/ethereum-mining/ethminer; + platforms = [ "x86_64-linux" ]; + maintainers = with maintainers; [ nand0p ]; + license = licenses.gpl2; + }; + +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e8b58e09439..0d0c1d2744e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2103,10 +2103,14 @@ in colormake = callPackage ../development/tools/build-managers/colormake { }; + ethash = callPackage ../development/libraries/ethash { }; + cpuminer = callPackage ../tools/misc/cpuminer { }; cpuminer-multi = callPackage ../tools/misc/cpuminer-multi { }; + ethminer = callPackage ../tools/misc/ethminer { }; + cuetools = callPackage ../tools/cd-dvd/cuetools { }; u3-tool = callPackage ../tools/filesystems/u3-tool { }; @@ -8886,6 +8890,8 @@ in libsigrok4dsl = callPackage ../applications/science/electronics/dsview/libsigrok4dsl.nix { }; libsigrokdecode4dsl = callPackage ../applications/science/electronics/dsview/libsigrokdecode4dsl.nix { }; + cli11 = callPackage ../development/tools/misc/cli11 { }; + dcadec = callPackage ../development/tools/dcadec { }; dejagnu = callPackage ../development/tools/misc/dejagnu { };