Skip to content

Commit

Permalink
monero-{cli,gui}: 0.18.3.3 -> 0.18.3.4
Browse files Browse the repository at this point in the history
Also:

  - Remove unnecessary dependencies

  - Fix trezor support

  - Format using nixfmt

(cherry picked from commit 473b09f)
  • Loading branch information
rnhmjoj authored and prusnak committed Sep 9, 2024
1 parent c791687 commit 54d0213
Show file tree
Hide file tree
Showing 4 changed files with 212 additions and 100 deletions.
128 changes: 76 additions & 52 deletions pkgs/applications/blockchains/monero-cli/default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
{ lib, stdenv, fetchFromGitHub, fetchpatch2, cmake, ninja, pkg-config
, boost, miniupnpc, openssl, unbound
, zeromq, pcsclite, readline, libsodium, hidapi
, randomx, rapidjson
, CoreData, IOKit, PCSC
, trezorSupport ? true, libusb1, protobuf, python3
{
lib,
stdenv,
fetchFromGitHub,
cmake,
ninja,
pkg-config,
boost,
libsodium,
miniupnpc,
openssl,
python3,
randomx,
rapidjson,
readline,
unbound,
zeromq,

# darwin
CoreData,
IOKit,

trezorSupport ? true,
hidapi,
libusb1,
protobuf_21,
udev,
}:

let
Expand All @@ -25,40 +46,16 @@ in

stdenv.mkDerivation rec {
pname = "monero-cli";
version = "0.18.3.3";
version = "0.18.3.4";

src = fetchFromGitHub {
owner = "monero-project";
repo = "monero";
rev = "v${version}";
hash = "sha256-1LkKIrud317BEE+713t5wiJV6FcDlJdj4ypXPR0bKTs=";
hash = "sha256-nDiFJjhsISYM8kTgJUaPYL44iyccnz5+Pd5beBh+lsM=";
};

patches = [
# cmake: remove unused/extera cmake/FindMiniupnpc.cmake and only rely on external/miniupnpc
# https://github.com/monero-project/monero/pull/9366
(fetchpatch2 {
url = "https://github.com/monero-project/monero/commit/5074a543a49f7e23fb39b6462fd4c4c9741c3693.patch?full_index=1";
hash = "sha256-dS2hhEU6m2of0ULlsf+/tZMHUmq3vGGXJPGHvtnpQnY=";
})

# cmake: add different parameters to add_monero_library.
# https://github.com/monero-project/monero/pull/9367
(fetchpatch2 {
url = "https://github.com/monero-project/monero/commit/b91ead90254ac6d6daf908f689c38e372a44c615.patch?full_index=1";
hash = "sha256-DL2YqkvEONbeEDqLOAo2eSF5JF5gOzKcLKeNlUXBY1w=";
})

# external: update miniupnpc to 2.2.8
# https://github.com/monero-project/monero/pull/9367
(fetchpatch2 {
url = "https://github.com/monero-project/monero/commit/d81da086ec5088a04b3f7b34831e72910300e2f7.patch?full_index=1";
hash = "sha256-ZJGiDMk5DMmEXwzoUYPC+DIoebluFh54kMQtQU78ckI=";
excludes = [ "external/miniupnp" ];
})

./use-system-libraries.patch
];
patches = [ ./use-system-libraries.patch ];

postPatch = ''
# manually install submodules
Expand All @@ -69,31 +66,58 @@ stdenv.mkDerivation rec {
cp -r . $source
'';

nativeBuildInputs = [ cmake ninja pkg-config ];
nativeBuildInputs = [
cmake
pkg-config
];

buildInputs = [
boost miniupnpc openssl unbound
zeromq pcsclite readline
libsodium hidapi randomx rapidjson
protobuf
] ++ lib.optionals stdenv.isDarwin [ IOKit CoreData PCSC ]
++ lib.optionals trezorSupport [ libusb1 protobuf python3 ];
buildInputs =
[
boost
libsodium
miniupnpc
openssl
randomx
rapidjson
readline
unbound
zeromq
]
++ lib.optionals stdenv.isDarwin [
IOKit
CoreData
]
++ lib.optionals trezorSupport [
python3
hidapi
libusb1
protobuf_21
udev
];

cmakeFlags = [
"-DUSE_DEVICE_TREZOR=ON"
"-DBUILD_GUI_DEPS=ON"
"-DReadline_ROOT_DIR=${readline.dev}"
"-DRandomX_ROOT_DIR=${randomx}"
] ++ lib.optional stdenv.isDarwin "-DBoost_USE_MULTITHREADED=OFF";
cmakeFlags =
[
# skip submodules init
"-DMANUAL_SUBMODULES=ON"
# required by monero-gui
"-DBUILD_GUI_DEPS=ON"
"-DReadline_ROOT_DIR=${readline.dev}"
]
++ lib.optional stdenv.isDarwin "-DBoost_USE_MULTITHREADED=OFF"
++ lib.optional trezorSupport [
"-DUSE_DEVICE_TREZOR=ON"
# fix build on recent gcc versions
"-DCMAKE_CXX_FLAGS=-fpermissive"
];

outputs = [ "out" "source" ];

meta = with lib; {
meta = {
description = "Private, secure, untraceable currency";
homepage = "https://getmonero.org/";
license = licenses.bsd3;
platforms = platforms.all;
maintainers = with maintainers; [ rnhmjoj ];
homepage = "https://getmonero.org/";
license = lib.licenses.bsd3;
platforms = lib.platforms.all;
maintainers = with lib.maintainers; [ rnhmjoj ];
mainProgram = "monero-wallet-cli";
};
}
66 changes: 53 additions & 13 deletions pkgs/applications/blockchains/monero-cli/use-system-libraries.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt
index f8b834ac17...520e148428 100644
index 5b7f69a56..cc4b0a346 100644
--- a/external/CMakeLists.txt
+++ b/external/CMakeLists.txt
@@ -39,23 +39,12 @@
add_compile_options(-D_GNU_SOURCE)
endif()
@@ -35,25 +35,14 @@
# ...except for FreeBSD, because FreeBSD is a special case that doesn't play well with
# others.

-find_package(Miniupnpc REQUIRED)
-
-message(STATUS "Using in-tree miniupnpc")
-set(UPNPC_NO_INSTALL TRUE CACHE BOOL "Disable miniupnp installation" FORCE)
-set(UPNPC_BUILD_TESTS FALSE CACHE BOOL "Disable miniupnp internal tests." FORCE)
-add_subdirectory(miniupnp/miniupnpc)
-set_property(TARGET libminiupnpc-static PROPERTY FOLDER "external")
-set_property(TARGET libminiupnpc-static PROPERTY POSITION_INDEPENDENT_CODE ON)
Expand All @@ -20,19 +21,58 @@ index f8b834ac17...520e148428 100644
-if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
- set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -D_NETBSD_SOURCE")
-endif()
+include(FindPkgConfig)
+pkg_check_modules(MINIUPNPC REQUIRED IMPORTED_TARGET GLOBAL miniupnpc)
+get_target_property(MINIUPNPC_INCLUDE_DIR PkgConfig::MINIUPNPC INTERFACE_INCLUDE_DIRECTORIES)
+set_target_properties(PkgConfig::MINIUPNPC PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${MINIUPNPC_INCLUDE_DIR}/miniupnpc")
+set(UPNP_LIBRARIES PkgConfig::MINIUPNPC PARENT_SCOPE)

-set(UPNP_LIBRARIES "libminiupnpc-static" PARENT_SCOPE)
-
-set(UPNP_LIBRARIES "libminiupnpc-static" PARENT_SCOPE)
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(MINIUPNPC REQUIRED miniupnpc)
+link_libraries(${MINIUPNPC_LIBRARIES})
+include_directories(${MINIUPNPC_INCLUDE_DIRS})

+find_package(RapidJSON)
find_package(Unbound)
+find_library(RANDOMX_LIBRARY randomx)

if(NOT UNBOUND_INCLUDE_DIR)
@@ -72,4 +61,3 @@
die("Could not find libunbound")
@@ -69,4 +58,3 @@ endif()
add_subdirectory(db_drivers)
add_subdirectory(easylogging++)
add_subdirectory(qrcodegen)
-add_subdirectory(randomx EXCLUDE_FROM_ALL)
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index 71f5393e8..bb48083d0 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -60,9 +60,9 @@
#include "cryptonote_core/cryptonote_core.h"
#include "net/parse.h"

-#include <miniupnp/miniupnpc/miniupnpc.h>
-#include <miniupnp/miniupnpc/upnpcommands.h>
-#include <miniupnp/miniupnpc/upnperrors.h>
+#include <miniupnpc/miniupnpc.h>
+#include <miniupnpc/upnpcommands.h>
+#include <miniupnpc/upnperrors.h>

#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net.p2p"
@@ -2989,7 +2989,8 @@ namespace nodetool
UPNPUrls urls;
IGDdatas igdData;
char lanAddress[64];
- result = UPNP_GetValidIGD(deviceList, &urls, &igdData, lanAddress, sizeof lanAddress);
+ char wanAddress[64];
+ result = UPNP_GetValidIGD(deviceList, &urls, &igdData, lanAddress, sizeof lanAddress, wanAddress, sizeof wanAddress);
freeUPNPDevlist(deviceList);
if (result > 0) {
if (result == 1) {
@@ -3057,7 +3058,8 @@ namespace nodetool
UPNPUrls urls;
IGDdatas igdData;
char lanAddress[64];
- result = UPNP_GetValidIGD(deviceList, &urls, &igdData, lanAddress, sizeof lanAddress);
+ char wanAddress[64];
+ result = UPNP_GetValidIGD(deviceList, &urls, &igdData, lanAddress, sizeof lanAddress, wanAddress, sizeof wanAddress);
freeUPNPDevlist(deviceList);
if (result > 0) {
if (result == 1) {
Loading

0 comments on commit 54d0213

Please sign in to comment.