1{ lib, stdenv, fetchFromGitHub, fetchpatch
2, cmake, pkg-config
3, boost179, miniupnpc, openssl, unbound
4, zeromq, pcsclite, readline, libsodium, hidapi
5, randomx, rapidjson
6, easyloggingpp
7, CoreData, IOKit, PCSC
8, trezorSupport ? true, libusb1, protobuf, python3
9}:
10
11stdenv.mkDerivation rec {
12 pname = "haven-cli";
13 version = "3.0.7";
14
15 src = fetchFromGitHub {
16 owner = "haven-protocol-org";
17 repo = "haven-main";
18 rev = "v${version}";
19 sha256 = "sha256-HLZ9j75MtF7FkHA4uefkrYp07pVZe1Ac1wny7T0CMpA=";
20 fetchSubmodules = true;
21 };
22
23 patches = [
24 ./use-system-libraries.patch
25 ];
26
27 postPatch = ''
28 # remove vendored libraries
29 rm -r external/{miniupnp,randomx,rapidjson,unbound}
30 # export patched source for haven-gui
31 cp -r . $source
32 # fix build on aarch64-darwin
33 substituteInPlace CMakeLists.txt --replace "-march=x86-64" ""
34 '';
35
36 nativeBuildInputs = [ cmake pkg-config ];
37
38 buildInputs = [
39 boost179 miniupnpc openssl unbound
40 zeromq pcsclite readline
41 libsodium hidapi randomx rapidjson
42 protobuf
43 readline easyloggingpp
44 ]
45 ++ lib.optionals trezorSupport [ libusb1 protobuf python3 ];
46
47 cmakeFlags = [
48 "-DUSE_DEVICE_TREZOR=ON"
49 "-DBUILD_GUI_DEPS=ON"
50 "-DReadline_ROOT_DIR=${readline.dev}"
51 "-DReadline_INCLUDE_DIR=${readline.dev}/include/readline"
52 "-DRandomX_ROOT_DIR=${randomx}"
53 ] ++ lib.optional stdenv.isDarwin "-DBoost_USE_MULTITHREADED=OFF";
54
55 outputs = [ "out" "source" ];
56
57 meta = with lib; {
58 description = "Haven Protocol is the world's only network of private stable asset";
59 homepage = "https://havenprotocol.org/";
60 license = licenses.bsd3;
61 platforms = platforms.all;
62 maintainers = with maintainers; [ kim0 ];
63 };
64}