From d6921aa4bf4b5750a0ad54623534d82fe5006126 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Wed, 30 Sep 2020 16:42:05 +0200 Subject: [PATCH 1/7] monero: 0.16.0.3 -> 0.17.0.1 --- pkgs/applications/blockchains/monero/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/blockchains/monero/default.nix b/pkgs/applications/blockchains/monero/default.nix index f1186564119f..02e781d271cf 100644 --- a/pkgs/applications/blockchains/monero/default.nix +++ b/pkgs/applications/blockchains/monero/default.nix @@ -10,13 +10,13 @@ assert stdenv.isDarwin -> IOKit != null; stdenv.mkDerivation rec { pname = "monero"; - version = "0.16.0.3"; + version = "0.17.0.1"; src = fetchFromGitHub { owner = "monero-project"; repo = "monero"; rev = "v${version}"; - sha256 = "1r9x3712vhb24dxxirfiwj5f9x0h4m7x0ngiiavf5983dfdlgz33"; + sha256 = "1v0phvg5ralli4dr09a60nq032xqlci5d6v4zfq8304vgrn1ffgp"; fetchSubmodules = true; }; From e40ede1821088f6e0ac5041907767aec5364308f Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 5 Oct 2020 23:12:18 +0200 Subject: [PATCH 2/7] monero-gui: 0.16.0.3 -> 0.17.0.1 --- pkgs/applications/blockchains/monero-gui/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/blockchains/monero-gui/default.nix b/pkgs/applications/blockchains/monero-gui/default.nix index 6ea075e2a369..6aa7befc5f0d 100644 --- a/pkgs/applications/blockchains/monero-gui/default.nix +++ b/pkgs/applications/blockchains/monero-gui/default.nix @@ -12,13 +12,13 @@ with stdenv.lib; stdenv.mkDerivation rec { pname = "monero-gui"; - version = "0.16.0.3"; + version = "0.17.0.1"; src = fetchFromGitHub { owner = "monero-project"; repo = "monero-gui"; rev = "v${version}"; - sha256 = "0iwjp8x5swy8i8pzrlm5v55awhm54cf48pm1vz98lcq361lhfzk6"; + sha256 = "1i9a3ampppyzsl4sllbqlr3w43sjpb3fdfxhb1j4n49p8g0jzmf3"; }; nativeBuildInputs = [ qmake pkgconfig wrapQtAppsHook ]; From cc90474581424f08ffed9abc3ed159eb96e60a12 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Wed, 7 Oct 2020 17:32:44 +0200 Subject: [PATCH 3/7] monero: force use of system libraries --- .../blockchains/monero/default.nix | 24 +++++-- .../monero/use-system-libraries.patch | 69 +++++++++++++++++++ 2 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 pkgs/applications/blockchains/monero/use-system-libraries.patch diff --git a/pkgs/applications/blockchains/monero/default.nix b/pkgs/applications/blockchains/monero/default.nix index 02e781d271cf..f424624cc298 100644 --- a/pkgs/applications/blockchains/monero/default.nix +++ b/pkgs/applications/blockchains/monero/default.nix @@ -2,11 +2,18 @@ , cmake, pkgconfig , boost, miniupnpc, openssl, unbound , zeromq, pcsclite, readline, libsodium, hidapi -, protobuf, randomx, rapidjson, libusb-compat-0_1 +, randomx, rapidjson , CoreData, IOKit, PCSC +, trezorSupport ? true + , libusb1 ? null + , protobuf ? null + , python3 ? null }: +with stdenv.lib; + assert stdenv.isDarwin -> IOKit != null; +assert trezorSupport -> all (x: x!=null) [ libusb1 protobuf python3 ]; stdenv.mkDerivation rec { pname = "monero"; @@ -20,21 +27,30 @@ stdenv.mkDerivation rec { fetchSubmodules = true; }; + patches = [ ./use-system-libraries.patch ]; + + postPatch = '' + # remove vendored libraries + rm -r external/{miniupnp,randomx,rapidjson,unbound} + ''; + nativeBuildInputs = [ cmake pkgconfig ]; buildInputs = [ boost miniupnpc openssl unbound zeromq pcsclite readline libsodium hidapi randomx rapidjson - protobuf libusb-compat-0_1 - ] ++ stdenv.lib.optionals stdenv.isDarwin [ IOKit CoreData PCSC ]; + protobuf + ] ++ optionals stdenv.isDarwin [ IOKit CoreData PCSC ] + ++ optionals trezorSupport [ libusb1 protobuf python3 ]; cmakeFlags = [ "-DCMAKE_BUILD_TYPE=Release" "-DUSE_DEVICE_TREZOR=ON" "-DBUILD_GUI_DEPS=ON" "-DReadline_ROOT_DIR=${readline.dev}" - ] ++ stdenv.lib.optional stdenv.isDarwin "-DBoost_USE_MULTITHREADED=OFF"; + "-DRandomX_ROOT_DIR=${randomx}" + ] ++ optional stdenv.isDarwin "-DBoost_USE_MULTITHREADED=OFF"; meta = with stdenv.lib; { description = "Private, secure, untraceable currency"; diff --git a/pkgs/applications/blockchains/monero/use-system-libraries.patch b/pkgs/applications/blockchains/monero/use-system-libraries.patch new file mode 100644 index 000000000000..57e2a2e9a696 --- /dev/null +++ b/pkgs/applications/blockchains/monero/use-system-libraries.patch @@ -0,0 +1,69 @@ +diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt +index a8916a7d0..39ec7747b 100644 +--- a/external/CMakeLists.txt ++++ b/external/CMakeLists.txt +@@ -37,34 +37,16 @@ + + find_package(Miniupnpc REQUIRED) + +-message(STATUS "Using in-tree miniupnpc") +-add_subdirectory(miniupnp/miniupnpc) +-set_property(TARGET libminiupnpc-static PROPERTY FOLDER "external") +-if(MSVC) +- set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -wd4244 -wd4267") +-elseif(NOT MSVC) +- set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value") +-endif() +-if(CMAKE_SYSTEM_NAME MATCHES "NetBSD") +- set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -D_NETBSD_SOURCE") +-endif() +- +-set(UPNP_LIBRARIES "libminiupnpc-static" PARENT_SCOPE) ++set(UPNP_STATIC false PARENT_SCOPE) ++set(UPNP_INCLUDE ${MINIUPNP_INCLUDE_DIR} PARENT_SCOPE) ++set(UPNP_LIBRARIES ${MINIUPNP_LIBRARY} PARENT_SCOPE) + + find_package(Unbound) + + if(NOT UNBOUND_INCLUDE_DIR OR STATIC) +- # NOTE: If STATIC is true, CMAKE_FIND_LIBRARY_SUFFIXES has been reordered. +- # unbound has config tests which used OpenSSL libraries, so -ldl may need to +- # be set in this case. +- # The unbound CMakeLists.txt can set it, since it's also needed for the +- # static OpenSSL libraries set up there after with target_link_libraries. +- add_subdirectory(unbound) +- +- set(UNBOUND_STATIC true PARENT_SCOPE) +- set(UNBOUND_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/unbound/libunbound" PARENT_SCOPE) +- set(UNBOUND_LIBRARY "unbound" PARENT_SCOPE) +- set(UNBOUND_LIBRARY_DIRS "${LIBEVENT2_LIBDIR}" PARENT_SCOPE) ++ set(UNBOUND_STATIC false PARENT_SCOPE) ++ set(UPNP_INCLUDE ${MINIUPNP_INCLUDE_DIR} PARENT_SCOPE) ++ set(UPNP_LIBRARIES ${MINIUPNP_LIBRARY} PARENT_SCOPE) + else() + message(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}") + if(UNBOUND_LIBRARIES) +@@ -81,4 +63,5 @@ endif() + add_subdirectory(db_drivers) + add_subdirectory(easylogging++) + add_subdirectory(qrcodegen) +-add_subdirectory(randomx EXCLUDE_FROM_ALL) ++ ++find_library(RANDOMX_LIBRARIES NAMES RandomX) +diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl +index 175741146..088b582f7 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 +-#include +-#include ++#include ++#include ++#include + + #undef MONERO_DEFAULT_LOG_CATEGORY + #define MONERO_DEFAULT_LOG_CATEGORY "net.p2p" From 59fe3e87c32e13f02e84924c3153e0bbd61a6fc6 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Thu, 8 Oct 2020 00:03:11 +0200 Subject: [PATCH 4/7] monero: export patched sources This is needed to build monero-gui without duplicating code. --- pkgs/applications/blockchains/monero/default.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/blockchains/monero/default.nix b/pkgs/applications/blockchains/monero/default.nix index f424624cc298..5b666e92ae8a 100644 --- a/pkgs/applications/blockchains/monero/default.nix +++ b/pkgs/applications/blockchains/monero/default.nix @@ -5,9 +5,9 @@ , randomx, rapidjson , CoreData, IOKit, PCSC , trezorSupport ? true - , libusb1 ? null - , protobuf ? null - , python3 ? null +, libusb1 ? null +, protobuf ? null +, python3 ? null }: with stdenv.lib; @@ -32,6 +32,8 @@ stdenv.mkDerivation rec { postPatch = '' # remove vendored libraries rm -r external/{miniupnp,randomx,rapidjson,unbound} + # export patched source for monero-gui + cp -r . $source ''; nativeBuildInputs = [ cmake pkgconfig ]; @@ -52,6 +54,8 @@ stdenv.mkDerivation rec { "-DRandomX_ROOT_DIR=${randomx}" ] ++ optional stdenv.isDarwin "-DBoost_USE_MULTITHREADED=OFF"; + outputs = [ "out" "source" ]; + meta = with stdenv.lib; { description = "Private, secure, untraceable currency"; homepage = "https://getmonero.org/"; From 059292cc64d241fd8196db82423d8d195b57904e Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Tue, 6 Oct 2020 21:14:52 +0200 Subject: [PATCH 5/7] monero-gui: use the cmake build system --- .../blockchains/monero-gui/default.nix | 76 +++++++++++-------- 1 file changed, 45 insertions(+), 31 deletions(-) diff --git a/pkgs/applications/blockchains/monero-gui/default.nix b/pkgs/applications/blockchains/monero-gui/default.nix index 6aa7befc5f0d..2f4edca7301c 100644 --- a/pkgs/applications/blockchains/monero-gui/default.nix +++ b/pkgs/applications/blockchains/monero-gui/default.nix @@ -1,15 +1,23 @@ { stdenv, wrapQtAppsHook, makeDesktopItem -, fetchFromGitHub, qmake, qttools, pkgconfig +, fetchFromGitHub +, cmake, qttools, pkgconfig , qtbase, qtdeclarative, qtgraphicaleffects , qtmultimedia, qtxmlpatterns , qtquickcontrols, qtquickcontrols2 -, monero, unbound, readline, boost, libunwind -, libsodium, pcsclite, zeromq, libgcrypt, libgpgerror -, hidapi, libusb-compat-0_1, protobuf, randomx +, monero, miniupnpc, unbound, readline +, boost, libunwind, libsodium, pcsclite +, randomx, zeromq, libgcrypt, libgpgerror +, hidapi, rapidjson +, trezorSupport ? true +, libusb1 ? null +, protobuf ? null +, python3 ? null }: with stdenv.lib; +assert trezorSupport -> all (x: x!=null) [ libusb1 protobuf python3 ]; + stdenv.mkDerivation rec { pname = "monero-gui"; version = "0.17.0.1"; @@ -21,42 +29,48 @@ stdenv.mkDerivation rec { sha256 = "1i9a3ampppyzsl4sllbqlr3w43sjpb3fdfxhb1j4n49p8g0jzmf3"; }; - nativeBuildInputs = [ qmake pkgconfig wrapQtAppsHook ]; + nativeBuildInputs = [ + cmake pkgconfig wrapQtAppsHook + (getDev qttools) + ]; buildInputs = [ qtbase qtdeclarative qtgraphicaleffects qtmultimedia qtquickcontrols qtquickcontrols2 qtxmlpatterns - monero unbound readline libgcrypt libgpgerror - boost libunwind libsodium pcsclite zeromq - hidapi libusb-compat-0_1 protobuf randomx - ]; + monero miniupnpc unbound readline + randomx libgcrypt libgpgerror + boost libunwind libsodium pcsclite + zeromq hidapi rapidjson + ] ++ optionals trezorSupport [ libusb1 protobuf python3 ]; - NIX_CFLAGS_COMPILE = [ "-Wno-error=format-security" ]; + postUnpack = '' + # copy monero sources here + # (needs to be writable) + cp -r ${monero.source}/* source/monero + chmod -R +w source/monero + ''; patches = [ ./move-log-file.patch ]; postPatch = '' - echo ' - var GUI_VERSION = "${version}"; - var GUI_MONERO_VERSION = "${getVersion monero}"; - ' > version.js - substituteInPlace monero-wallet-gui.pro \ - --replace '$$[QT_INSTALL_BINS]/lrelease' '${getDev qttools}/bin/lrelease' + # set monero-gui version + substituteInPlace src/version.js.in \ + --replace '@VERSION_TAG_GUI@' '${version}' + substituteInPlace monero/src/version.cpp.in \ + --replace '@VERSION_IS_RELEASE@' 'true' + + # use monerod from the monero package substituteInPlace src/daemon/DaemonManager.cpp \ --replace 'QApplication::applicationDirPath() + "' '"${monero}/bin' + + # only build external deps, *not* the full monero + substituteInPlace CMakeLists.txt \ + --replace 'add_subdirectory(monero)' \ + 'add_subdirectory(monero EXCLUDE_FROM_ALL)' ''; - makeFlags = [ "INSTALL_ROOT=$(out)" ]; - - preBuild = '' - sed -i s#/opt/monero-wallet-gui##g Makefile - make -C src/zxcvbn-c - - # use nixpkgs monero sources - rmdir monero - ln -s "${monero.src}" monero - ''; + cmakeFlags = [ "-DCMAKE_INSTALL_PREFIX=$out/bin" ]; desktopItem = makeDesktopItem { name = "monero-wallet-gui"; @@ -69,15 +83,15 @@ stdenv.mkDerivation rec { postInstall = '' # install desktop entry - mkdir -p $out/share/applications - cp ${desktopItem}/share/applications/* $out/share/applications + install -Dm644 -t $out/share/applications \ + ${desktopItem}/share/applications/* # install icons for n in 16 24 32 48 64 96 128 256; do size=$n"x"$n - mkdir -p $out/share/icons/hicolor/$size/apps - cp $src/images/appicons/$size.png \ - $out/share/icons/hicolor/$size/apps/monero.png + install -Dm644 \ + -t $out/share/icons/hicolor/$size/apps/monero.png \ + $src/images/appicons/$size.png done; ''; From b5ca332b1db0e3bfcb1bdc119b37e2500ec8259b Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Thu, 8 Oct 2020 01:12:31 +0200 Subject: [PATCH 6/7] monero: apply patch to fix monero-gui build This is a more appropriate solution to fix a build error in monero-gui. --- .../applications/blockchains/monero-gui/default.nix | 5 +++-- pkgs/applications/blockchains/monero/default.nix | 13 +++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/blockchains/monero-gui/default.nix b/pkgs/applications/blockchains/monero-gui/default.nix index 2f4edca7301c..f9e07e5c5e5a 100644 --- a/pkgs/applications/blockchains/monero-gui/default.nix +++ b/pkgs/applications/blockchains/monero-gui/default.nix @@ -57,8 +57,9 @@ stdenv.mkDerivation rec { # set monero-gui version substituteInPlace src/version.js.in \ --replace '@VERSION_TAG_GUI@' '${version}' - substituteInPlace monero/src/version.cpp.in \ - --replace '@VERSION_IS_RELEASE@' 'true' + + # remove this line on the next release + rm cmake/Version.cmake # use monerod from the monero package substituteInPlace src/daemon/DaemonManager.cpp \ diff --git a/pkgs/applications/blockchains/monero/default.nix b/pkgs/applications/blockchains/monero/default.nix index 5b666e92ae8a..935040bc7bb5 100644 --- a/pkgs/applications/blockchains/monero/default.nix +++ b/pkgs/applications/blockchains/monero/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchFromGitHub +{ stdenv, fetchFromGitHub, fetchpatch , cmake, pkgconfig , boost, miniupnpc, openssl, unbound , zeromq, pcsclite, readline, libsodium, hidapi @@ -27,7 +27,16 @@ stdenv.mkDerivation rec { fetchSubmodules = true; }; - patches = [ ./use-system-libraries.patch ]; + patches = [ + ./use-system-libraries.patch + + # This fixes a bug in the monero-gui build system, + # remove it once the PR has been merged + (fetchpatch { + url = "https://github.com/monero-project/monero/pull/6867.patch"; + sha256 = "0nxa6861df1fadrm9bmhqf2g6mljgr4jndsbxqp7g501hv9z51j3"; + }) + ]; postPatch = '' # remove vendored libraries From 843c5da500a0bf94473b134b53041fe4b1d63d13 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Thu, 8 Oct 2020 02:20:00 +0200 Subject: [PATCH 7/7] monero-gui: fix aarch64 build --- pkgs/applications/blockchains/monero-gui/default.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/blockchains/monero-gui/default.nix b/pkgs/applications/blockchains/monero-gui/default.nix index f9e07e5c5e5a..776d51ca6bd8 100644 --- a/pkgs/applications/blockchains/monero-gui/default.nix +++ b/pkgs/applications/blockchains/monero-gui/default.nix @@ -18,6 +18,13 @@ with stdenv.lib; assert trezorSupport -> all (x: x!=null) [ libusb1 protobuf python3 ]; +let + arch = if stdenv.isx86_64 then "x86-64" + else if stdenv.isi686 then "i686" + else if stdenv.isAarch64 then "armv8-a" + else throw "unsupported architecture"; +in + stdenv.mkDerivation rec { pname = "monero-gui"; version = "0.17.0.1"; @@ -71,7 +78,10 @@ stdenv.mkDerivation rec { 'add_subdirectory(monero EXCLUDE_FROM_ALL)' ''; - cmakeFlags = [ "-DCMAKE_INSTALL_PREFIX=$out/bin" ]; + cmakeFlags = [ + "-DCMAKE_INSTALL_PREFIX=$out/bin" + "-DARCH=${arch}" + ]; desktopItem = makeDesktopItem { name = "monero-wallet-gui";