1{ lib, stdenv, fetchFromGitHub, cmake, pkg-config
2, boost, miniupnpc, openssl, unbound
3, zeromq, pcsclite, readline, libsodium, hidapi
4, randomx, rapidjson
5, CoreData, IOKit, PCSC
6, trezorSupport ? true, libusb1, protobuf, python3
7}:
8
9let
10 # submodules
11 supercop = fetchFromGitHub {
12 owner = "monero-project";
13 repo = "supercop";
14 rev = "633500ad8c8759995049ccd022107d1fa8a1bbc9";
15 sha256 = "26UmESotSWnQ21VbAYEappLpkEMyl0jiuCaezRYd/sE=";
16 };
17 trezor-common = fetchFromGitHub {
18 owner = "trezor";
19 repo = "trezor-common";
20 rev = "bff7fdfe436c727982cc553bdfb29a9021b423b0";
21 sha256 = "VNypeEz9AV0ts8X3vINwYMOgO8VpNmyUPC4iY3OOuZI=";
22 };
23
24in
25
26stdenv.mkDerivation rec {
27 pname = "monero-cli";
28 version = "0.18.2.2";
29
30 src = fetchFromGitHub {
31 owner = "monero-project";
32 repo = "monero";
33 rev = "v${version}";
34 sha256 = "6VI5D3vP6NKdrEE5qOpKnv1wr6AWriixdOxkAa8HaCQ=";
35 };
36
37 patches = [
38 ./use-system-libraries.patch
39 ];
40
41 postPatch = ''
42 # manually install submodules
43 rmdir external/{supercop,trezor-common}
44 ln -sf ${supercop} external/supercop
45 ln -sf ${trezor-common} external/trezor-common
46 # export patched source for monero-gui
47 cp -r . $source
48 '';
49
50 nativeBuildInputs = [ cmake pkg-config ];
51
52 buildInputs = [
53 boost miniupnpc openssl unbound
54 zeromq pcsclite readline
55 libsodium hidapi randomx rapidjson
56 protobuf
57 ] ++ lib.optionals stdenv.isDarwin [ IOKit CoreData PCSC ]
58 ++ lib.optionals trezorSupport [ libusb1 protobuf python3 ];
59
60 cmakeFlags = [
61 "-DCMAKE_BUILD_TYPE=Release"
62 "-DUSE_DEVICE_TREZOR=ON"
63 "-DBUILD_GUI_DEPS=ON"
64 "-DReadline_ROOT_DIR=${readline.dev}"
65 "-DRandomX_ROOT_DIR=${randomx}"
66 ] ++ lib.optional stdenv.isDarwin "-DBoost_USE_MULTITHREADED=OFF";
67
68 outputs = [ "out" "source" ];
69
70 meta = with lib; {
71 description = "Private, secure, untraceable currency";
72 homepage = "https://getmonero.org/";
73 license = licenses.bsd3;
74 platforms = platforms.all;
75 maintainers = with maintainers; [ rnhmjoj ];
76 };
77}