1{ stdenv
2, lib
3, fetchFromGitHub
4, cmake
5, libuv
6, libmicrohttpd
7, openssl
8, hwloc
9, donateLevel ? 0
10, darwin
11}:
12
13let
14 inherit (darwin.apple_sdk_11_0.frameworks) Carbon CoreServices OpenCL;
15in
16stdenv.mkDerivation rec {
17 pname = "xmrig";
18 version = "6.19.1";
19
20 src = fetchFromGitHub {
21 owner = "xmrig";
22 repo = "xmrig";
23 rev = "v${version}";
24 hash = "sha256-m8ot/IbpxdzHOyJymzZ7MWt4p78GTUuTjYZ9P1oGpWI=";
25 };
26
27 patches = [
28 ./donate-level.patch
29 ];
30
31 postPatch = ''
32 substituteAllInPlace src/donate.h
33 substituteInPlace cmake/OpenSSL.cmake \
34 --replace "set(OPENSSL_USE_STATIC_LIBS TRUE)" "set(OPENSSL_USE_STATIC_LIBS FALSE)"
35 '';
36
37 nativeBuildInputs = [
38 cmake
39 ];
40
41 buildInputs = [
42 libuv
43 libmicrohttpd
44 openssl
45 hwloc
46 ] ++ lib.optionals stdenv.isDarwin [
47 Carbon
48 CoreServices
49 OpenCL
50 ];
51
52 inherit donateLevel;
53
54 installPhase = ''
55 runHook preInstall
56
57 install -vD xmrig $out/bin/xmrig
58
59 runHook postInstall
60 '';
61
62 meta = with lib; {
63 description = "Monero (XMR) CPU miner";
64 homepage = "https://github.com/xmrig/xmrig";
65 license = licenses.gpl3Plus;
66 platforms = platforms.unix;
67 maintainers = with maintainers; [ kim0 ];
68 };
69}