nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchpatch2,
6 cmake,
7 pkg-config,
8 boost186,
9 libsodium,
10 miniupnpc,
11 openssl,
12 python3,
13 randomx,
14 rapidjson,
15 readline,
16 unbound,
17 zeromq,
18
19 trezorSupport ? true,
20 hidapi,
21 libusb1,
22 protobuf_21,
23 udev,
24}:
25
26let
27 # submodules; revs are taken from monero repo's `/external` at the given monero version tag.
28 supercop = fetchFromGitHub {
29 owner = "monero-project";
30 repo = "supercop";
31 rev = "633500ad8c8759995049ccd022107d1fa8a1bbc9";
32 hash = "sha256-26UmESotSWnQ21VbAYEappLpkEMyl0jiuCaezRYd/sE=";
33 };
34 trezor-common = fetchFromGitHub {
35 owner = "trezor";
36 repo = "trezor-common";
37 rev = "bff7fdfe436c727982cc553bdfb29a9021b423b0";
38 hash = "sha256-VNypeEz9AV0ts8X3vINwYMOgO8VpNmyUPC4iY3OOuZI=";
39 };
40in
41stdenv.mkDerivation rec {
42 pname = "monero-cli";
43 version = "0.18.4.4";
44
45 src = fetchFromGitHub {
46 owner = "monero-project";
47 repo = "monero";
48 rev = "v${version}";
49 hash = "sha256-NH15PKlkm9Hpt25iIuUQmhDg+X3Qo+yUAbDY4LNnZdM=";
50 };
51
52 patches = [
53 ./use-system-libraries.patch
54 ];
55
56 postPatch = ''
57 # manually install submodules
58 rmdir external/{supercop,trezor-common}
59 ln -sf ${supercop} external/supercop
60 ln -sf ${trezor-common} external/trezor-common
61 # export patched source for monero-gui
62 cp -r . $source
63 '';
64
65 nativeBuildInputs = [
66 cmake
67 pkg-config
68 ];
69
70 buildInputs = [
71 boost186 # uses boost/asio/io_service.hpp
72 libsodium
73 miniupnpc
74 openssl
75 randomx
76 rapidjson
77 readline
78 unbound
79 zeromq
80 ]
81 ++ lib.optionals trezorSupport [
82 python3
83 hidapi
84 libusb1
85 protobuf_21
86 ]
87 ++ lib.optionals (trezorSupport && stdenv.hostPlatform.isLinux) [ udev ];
88
89 cmakeFlags = [
90 # skip submodules init
91 "-DMANUAL_SUBMODULES=ON"
92 # required by monero-gui
93 "-DBUILD_GUI_DEPS=ON"
94 "-DReadline_ROOT_DIR=${readline.dev}"
95 "-Wno-dev"
96 ]
97 ++ lib.optional stdenv.hostPlatform.isDarwin "-DBoost_USE_MULTITHREADED=OFF"
98 ++ lib.optional trezorSupport [
99 "-DUSE_DEVICE_TREZOR=ON"
100 ];
101
102 outputs = [
103 "out"
104 "source"
105 ];
106
107 meta = {
108 description = "Private, secure, untraceable currency";
109 homepage = "https://getmonero.org/";
110 license = lib.licenses.bsd3;
111
112 platforms = with lib.platforms; linux;
113
114 # macOS/ARM has a working `monerod` (at least), but `monero-wallet-cli`
115 # segfaults on start after entering the wallet password, when built in release mode.
116 # Building the same revision in debug mode to root-cause the above problem doesn't work
117 # because of https://github.com/monero-project/monero/issues/9486
118 badPlatforms = [ "aarch64-darwin" ];
119
120 maintainers = with lib.maintainers; [
121 pmw
122 rnhmjoj
123 ];
124 mainProgram = "monero-wallet-cli";
125 # internal build tool generate_translations_header is tricky to compile for the build platform
126 broken = !stdenv.buildPlatform.canExecute stdenv.hostPlatform;
127 };
128}