@@ -1,63 +1,88 @@
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+
21+let
22+ arch = if stdenv.isx86_64 then "x86-64"
23+ else if stdenv.isi686 then "i686"
24+ else if stdenv.isAarch64 then "armv8-a"
25+ else throw "unsupported architecture";
26+in
27+
1328stdenv.mkDerivation rec {
1429 pname = "monero-gui";
15− version = "0.16.0.3";
30+ version = "0.17.0.1";
1631
1732 src = fetchFromGitHub {
1833 owner = "monero-project";
1934 repo = "monero-gui";
2035 rev = "v${version}";
21− sha256 = "0iwjp8x5swy8i8pzrlm5v55awhm54cf48pm1vz98lcq361lhfzk6";
36+ sha256 = "1i9a3ampppyzsl4sllbqlr3w43sjpb3fdfxhb1j4n49p8g0jzmf3";
2237 };
2338
24− nativeBuildInputs = [ qmake pkgconfig wrapQtAppsHook ];
39+ nativeBuildInputs = [
40+ cmake pkgconfig wrapQtAppsHook
41+ (getDev qttools)
42+ ];
2543
2644 buildInputs = [
2745 qtbase qtdeclarative qtgraphicaleffects
2846 qtmultimedia qtquickcontrols qtquickcontrols2
2947 qtxmlpatterns
30− monero unbound readline libgcrypt libgpgerror
31− boost libunwind libsodium pcsclite zeromq
32− hidapi libusb-compat-0_1 protobuf randomx
33− ];
48+ monero miniupnpc unbound readline
49+ randomx libgcrypt libgpgerror
50+ boost libunwind libsodium pcsclite
51+ zeromq hidapi rapidjson
52+ ] ++ optionals trezorSupport [ libusb1 protobuf python3 ];
3453
35− NIX_CFLAGS_COMPILE = [ "-Wno-error=format-security" ];
54+ postUnpack = ''
55+ # copy monero sources here
56+ # (needs to be writable)
57+ cp -r ${monero.source}/* source/monero
58+ chmod -R +w source/monero
59+ '';
3660
3761 patches = [ ./move-log-file.patch ];
3862
3963 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'
46− substituteInPlace src/daemon/DaemonManager.cpp \
47− --replace 'QApplication::applicationDirPath() + "' '"${monero}/bin'
48− '';
64+ # set monero-gui version
65+ substituteInPlace src/version.js.in \
66+ --replace '@VERSION_TAG_GUI@' '${version}'
4967
50− makeFlags = [ "INSTALL_ROOT=$(out)" ];
68+ # remove this line on the next release
69+ rm cmake/Version.cmake
5170
52− preBuild = ''
53− sed -i s#/opt/monero-wallet-gui##g Makefile
54− make -C src/zxcvbn-c
71+ # use monerod from the monero package
72+ substituteInPlace src/daemon/DaemonManager.cpp \
73+ --replace 'QApplication::applicationDirPath() + "' '"${monero}/bin'
5574
56− # use nixpkgs monero sources
57− rmdir monero
58− ln -s "${monero.src}" monero
75+ # only build external deps, *not* the full monero
76+ substituteInPlace CMakeLists.txt \
77+ --replace 'add_subdirectory(monero)' \
78+ 'add_subdirectory(monero EXCLUDE_FROM_ALL)'
5979 '';
6080
81+ cmakeFlags = [
82+ "-DCMAKE_INSTALL_PREFIX=$out/bin"
83+ "-DARCH=${arch}"
84+ ];
85+
6186 desktopItem = makeDesktopItem {
6287 name = "monero-wallet-gui";
6388 exec = "monero-wallet-gui";
@@ -69,15 +94,15 @@ stdenv.mkDerivation rec {
6994
7095 postInstall = ''
7196 # install desktop entry
72− mkdir -p $out/share/applications
73− cp ${desktopItem}/share/applications/* $out/share/applications
97+ install -Dm644 -t $out/share/applications \
98+ ${desktopItem}/share/applications/*
7499
75100 # install icons
76101 for n in 16 24 32 48 64 96 128 256; do
77102 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
103+ install -Dm644 \
104+ -t $out/share/icons/hicolor/$size/apps/monero.png \
105+ $src/images/appicons/$size.png
81106 done;
82107 '';
83108