From 08ec3c079ddb93d60757ae9e3348876752f30093 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Sun, 2 May 2021 05:11:07 +0200 Subject: [PATCH] working on ethminer --- configs/workhorse/configuration.nix | 1 + configs/workhorse/mining.nix | 57 +++++++++++++++++++++++++ images/yubikey-image.nix | 1 - pkgs/default.nix | 2 + pkgs/ethminer/default.nix | 64 +++++++++++++++++++++++++++++ system/server/default.nix | 2 + 6 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 configs/workhorse/mining.nix create mode 100644 pkgs/ethminer/default.nix diff --git a/configs/workhorse/configuration.nix b/configs/workhorse/configuration.nix index e85db26..a1951f8 100644 --- a/configs/workhorse/configuration.nix +++ b/configs/workhorse/configuration.nix @@ -30,6 +30,7 @@ ./mysql.nix ./property.nix ./finance.nix + #./mining.nix ]; nixpkgs.config.permittedInsecurePackages = diff --git a/configs/workhorse/mining.nix b/configs/workhorse/mining.nix new file mode 100644 index 0000000..ddedbc2 --- /dev/null +++ b/configs/workhorse/mining.nix @@ -0,0 +1,57 @@ +{ pkgs, config, ... }: +let + maxPower = 90; + pool = "eu1.ethermine.org"; + toolkit = "opencl"; + wallet = ""; + rig = config.networking.hostName; + recheckInterval = 2000; + package = pkgs.ethminer; +in { + + systemd.services.ethminer = { + description = "ethminer ethereum mining service"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + + serviceConfig = { + DynamicUser = true; + ExecStartPre = "${package}/bin/.ethminer-wrapped --list-devices"; + Restart = "always"; + }; + + script = '' + ${package}/bin/.ethminer-wrapped \ + --farm-recheck ${toString recheckInterval} \ + --report-hashrate \ + --${toolkit} \ + --pool stratum1+tcp://${wallet}.${rig}@${pool}:4444 + ''; + + }; + + #nixpkgs.config.allowBroken = true; + + hardware.opengl = { + enable = true; + extraPackages = with pkgs; [ + vaapiIntel + libvdpau-va-gl + vaapiVdpau + intel-ocl + ]; + driSupport = true; + driSupport32Bit = true; + }; + + environment.systemPackages = with pkgs; [ + package + # go-ethereum + go-ethereum + # to check opencl config + clinfo + # check temperature + i7z + ]; + +} diff --git a/images/yubikey-image.nix b/images/yubikey-image.nix index 0db5a9d..6af2be4 100644 --- a/images/yubikey-image.nix +++ b/images/yubikey-image.nix @@ -24,7 +24,6 @@ midori paperkey gnupg - #haskellPackages.hopenpgp-tools ctmg ]; diff --git a/pkgs/default.nix b/pkgs/default.nix index 7867165..6bd362a 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -65,4 +65,6 @@ in { sha256 = "04j6gcb6ayrcf7rxr0bkgd48zppiryhdyv7mvp0q12ngdkf2yagd"; }) { }; + ethminer = callPackage ./ethminer { cudaSupport = false; }; + } diff --git a/pkgs/ethminer/default.nix b/pkgs/ethminer/default.nix new file mode 100644 index 0000000..78b1d4f --- /dev/null +++ b/pkgs/ethminer/default.nix @@ -0,0 +1,64 @@ +{ lib, stdenv, clangStdenv, fetchFromGitHub, opencl-headers, cmake, jsoncpp +, boost, makeWrapper, cudatoolkit, cudaSupport, mesa, ethash, opencl-info +, ocl-icd, openssl, pkg-config, cli11 }@args: + +# Note that this requires clang < 9.0 to build, and currently +# clangStdenv provides clang 7.1 which satisfies the requirement. +let stdenv = if cudaSupport then clangStdenv else args.stdenv; + +in stdenv.mkDerivation rec { + pname = "ethminer"; + version = "0.19.0"; + + src = fetchFromGitHub { + owner = "ethereum-mining"; + repo = "ethminer"; + rev = "v${version}"; + sha256 = "1kyff3vx2r4hjpqah9qk99z6dwz7nsnbnhhl6a76mdhjmgp1q646"; + fetchSubmodules = true; + }; + + # NOTE: dbus is broken + cmakeFlags = [ + "-DHUNTER_ENABLED=OFF" + "-DETHASHCUDA=ON" + "-DAPICORE=ON" + "-DETHDBUS=OFF" + "-DCMAKE_BUILD_TYPE=Release" + ] ++ lib.optionals (!cudaSupport) [ + "-DETHASHCUDA=OFF" # on by default + ]; + + nativeBuildInputs = [ cmake pkg-config makeWrapper ]; + + buildInputs = [ + cli11 + boost + opencl-headers + mesa + ethash + opencl-info + ocl-icd + openssl + jsoncpp + ] ++ lib.optionals cudaSupport [ cudatoolkit ]; + + preConfigure = '' + sed -i 's/_lib_static//' libpoolprotocols/CMakeLists.txt + ''; + + postInstall = '' + wrapProgram $out/bin/ethminer --prefix LD_LIBRARY_PATH : /run/opengl-driver/lib + ''; + + meta = with lib; { + description = "Ethereum miner with OpenCL${ + lib.optionalString cudaSupport ", CUDA" + } and stratum support"; + homepage = "https://github.com/ethereum-mining/ethminer"; + platforms = [ "x86_64-linux" ]; + maintainers = with maintainers; [ nand0p atemu ]; + license = licenses.gpl3Only; + broken = cudaSupport; + }; +} diff --git a/system/server/default.nix b/system/server/default.nix index 95d9f05..9f5d543 100644 --- a/system/server/default.nix +++ b/system/server/default.nix @@ -18,5 +18,7 @@ # config vim programs.custom.vim.enable = true; + services.locate.enable = true; + }