about summary refs log tree commit diff
path: root/pkgs/applications/blockchains/monero-gui/default.nix
blob: 7e8a5fe73dcd23c6e791088ad557d9700ad2ca03 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
{
  lib,
  fetchFromGitHub,
  makeDesktopItem,
  boost,
  cmake,
  libgcrypt,
  libgpg-error,
  libsodium,
  miniupnpc,
  monero-cli,
  pkg-config,
  qtbase,
  qtdeclarative,
  qtgraphicaleffects,
  qtmacextras,
  qtmultimedia,
  qtquickcontrols,
  qtquickcontrols2,
  qttools,
  qtxmlpatterns,
  quirc,
  randomx,
  rapidjson,
  stdenv,
  unbound,
  wrapQtAppsHook,
  zeromq,

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

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

  src = fetchFromGitHub {
    owner = "monero-project";
    repo = "monero-gui";
    rev = "v${version}";
    hash = "sha256-wnU24EmZig2W/psy4OhaQVy2WwR0CgljlyYwOg4bzwM=";
  };

  nativeBuildInputs = [
    cmake
    pkg-config
    wrapQtAppsHook
    (lib.getDev qttools)
  ];

  buildInputs =
    [
      boost
      libgcrypt
      libgpg-error
      libsodium
      miniupnpc
      qtbase
      qtdeclarative
      qtgraphicaleffects
      qtmultimedia
      qtquickcontrols
      qtquickcontrols2
      qtxmlpatterns
      quirc
      randomx
      rapidjson
      unbound
      zeromq
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [ qtmacextras ]
    ++ lib.optionals trezorSupport [
      hidapi
      libusb1
      protobuf_21
      python3
    ]
    ++ lib.optionals (trezorSupport && stdenv.hostPlatform.isLinux) [
      udev
    ];

  postUnpack = ''
    # copy monero sources here
    # (needs to be writable)
    cp -r ${monero-cli.source}/* source/monero
    chmod -R +w source/monero
  '';

  patches = [
    ./move-log-file.patch
    ./use-system-libquirc.patch
  ];

  postPatch = ''
    # set monero-gui version
    substituteInPlace src/version.js.in \
       --replace '@VERSION_TAG_GUI@' '${version}'

    # use monerod from the monero package
    substituteInPlace src/daemon/DaemonManager.cpp \
      --replace 'QApplication::applicationDirPath() + "' '"${monero-cli}/bin'

    # 1: only build external deps, *not* the full monero
    # 2: use nixpkgs libraries
    substituteInPlace CMakeLists.txt \
      --replace 'add_subdirectory(monero)' \
                'add_subdirectory(monero EXCLUDE_FROM_ALL)' \
      --replace 'add_subdirectory(external)' ""
  '';

  cmakeFlags =
    [ "-DARCH=default" ]
    ++ lib.optional trezorSupport [
      # fix build on recent gcc versions
      "-DCMAKE_CXX_FLAGS=-fpermissive"
    ];

  desktopItem = makeDesktopItem {
    name = "monero-wallet-gui";
    exec = "monero-wallet-gui";
    icon = "monero";
    desktopName = "Monero";
    genericName = "Wallet";
    categories = [ "Network" "Utility" ];
  };

  postInstall = ''
    # install desktop entry
    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
      install -Dm644 \
        $src/images/appicons/$size.png \
        $out/share/icons/hicolor/$size/apps/monero.png
    done;
  '';

  meta = {
    description = "Private, secure, untraceable currency";
    homepage = "https://getmonero.org/";
    license = lib.licenses.bsd3;
    platforms = lib.platforms.all;
    maintainers = with lib.maintainers; [ rnhmjoj ];
    mainProgram = "monero-wallet-gui";
  };
}