@@ -1,15 +1,23 @@
11{ stdenv, wrapQtAppsHook, makeDesktopItem
2−, fetchFromGitHub, qmake, qttools, pkgconfig
2+, fetchFromGitHub
3+, cmake, qttools, pkgconfig
34, qtbase, qtdeclarative, qtgraphicaleffects
45, qtmultimedia, qtxmlpatterns
56, qtquickcontrols, qtquickcontrols2
6−, monero, unbound, readline, boost, libunwind
7−, libsodium, pcsclite, zeromq, libgcrypt, libgpgerror
8−, hidapi, libusb-compat-0_1, protobuf, randomx
7+, monero, miniupnpc, unbound, readline
8+, boost, libunwind, libsodium, pcsclite
9+, randomx, zeromq, libgcrypt, libgpgerror
10+, hidapi, rapidjson
11+, trezorSupport ? true
12+, libusb1 ? null
13+, protobuf ? null
14+, python3 ? null
915}:
1016
1117with stdenv.lib;
1218
19+assert trezorSupport -> all (x: x!=null) [ libusb1 protobuf python3 ];
20+
1321stdenv.mkDerivation rec {
1422 pname = "monero-gui";
1523 version = "0.17.0.1";
@@ -21,43 +29,49 @@ stdenv.mkDerivation rec {
2129 sha256 = "1i9a3ampppyzsl4sllbqlr3w43sjpb3fdfxhb1j4n49p8g0jzmf3";
2230 };
2331
24− nativeBuildInputs = [ qmake pkgconfig wrapQtAppsHook ];
32+ nativeBuildInputs = [
33+ cmake pkgconfig wrapQtAppsHook
34+ (getDev qttools)
35+ ];
2536
2637 buildInputs = [
2738 qtbase qtdeclarative qtgraphicaleffects
2839 qtmultimedia qtquickcontrols qtquickcontrols2
2940 qtxmlpatterns
30− monero unbound readline libgcrypt libgpgerror
31− boost libunwind libsodium pcsclite zeromq
32− hidapi libusb-compat-0_1 protobuf randomx
33− ];
41+ monero miniupnpc unbound readline
42+ randomx libgcrypt libgpgerror
43+ boost libunwind libsodium pcsclite
44+ zeromq hidapi rapidjson
45+ ] ++ optionals trezorSupport [ libusb1 protobuf python3 ];
3446
35− NIX_CFLAGS_COMPILE = [ "-Wno-error=format-security" ];
47+ postUnpack = ''
48+ # copy monero sources here
49+ # (needs to be writable)
50+ cp -r ${monero.source}/* source/monero
51+ chmod -R +w source/monero
52+ '';
3653
3754 patches = [ ./move-log-file.patch ];
3855
3956 postPatch = ''
40− echo '
41− var GUI_VERSION = "${version}";
42− var GUI_MONERO_VERSION = "${getVersion monero}";
43− ' > version.js
44− substituteInPlace monero-wallet-gui.pro \
45− --replace '$$[QT_INSTALL_BINS]/lrelease' '${getDev qttools}/bin/lrelease'
57+ # set monero-gui version
58+ substituteInPlace src/version.js.in \
59+ --replace '@VERSION_TAG_GUI@' '${version}'
60+ substituteInPlace monero/src/version.cpp.in \
61+ --replace '@VERSION_IS_RELEASE@' 'true'
62+
63+ # use monerod from the monero package
4664 substituteInPlace src/daemon/DaemonManager.cpp \
4765 --replace 'QApplication::applicationDirPath() + "' '"${monero}/bin'
48− '';
49−
50− makeFlags = [ "INSTALL_ROOT=$(out)" ];
5166
52− preBuild = ''
53− sed -i s#/opt/monero-wallet-gui##g Makefile
54− make -C src/zxcvbn-c
55−
56− # use nixpkgs monero sources
57− rmdir monero
58− ln -s "${monero.src}" monero
67+ # only build external deps, *not* the full monero
68+ substituteInPlace CMakeLists.txt \
69+ --replace 'add_subdirectory(monero)' \
70+ 'add_subdirectory(monero EXCLUDE_FROM_ALL)'
5971 '';
6072
73+ cmakeFlags = [ "-DCMAKE_INSTALL_PREFIX=$out/bin" ];
74+
6175 desktopItem = makeDesktopItem {
6276 name = "monero-wallet-gui";
6377 exec = "monero-wallet-gui";
@@ -69,15 +83,15 @@ stdenv.mkDerivation rec {
6983
7084 postInstall = ''
7185 # install desktop entry
72− mkdir -p $out/share/applications
73− cp ${desktopItem}/share/applications/* $out/share/applications
86+ install -Dm644 -t $out/share/applications \
87+ ${desktopItem}/share/applications/*
7488
7589 # install icons
7690 for n in 16 24 32 48 64 96 128 256; do
7791 size=$n"x"$n
78− mkdir -p $out/share/icons/hicolor/$size/apps
79− cp $src/images/appicons/$size.png \
80− $out/share/icons/hicolor/$size/apps/monero.png
92+ install -Dm644 \
93+ -t $out/share/icons/hicolor/$size/apps/monero.png \
94+ $src/images/appicons/$size.png
8195 done;
8296 '';
8397