@@ -0,0 +1,57 @@
1+{lib, pkgs, stdenv, fetchFromGitHub, cmake, pkgconfig, boost, libGL, qtbase}:
2+
3+stdenv.mkDerivation rec {
4+
5+ name = "nano-wallet-${version}";
6+ version = "12.1";
7+
8+ src = fetchFromGitHub {
9+ owner = "nanocurrency";
10+ repo = "raiblocks";
11+ rev = "V${version}";
12+ sha256 = "10ng7qn6y31s2bjahmpivw2plx90ljjjzb87j3l7zmppsjd2iq03";
13+ fetchSubmodules = true;
14+ };
15+
16+ # Use a patch to force dynamic linking
17+ patches = [
18+ ./CMakeLists.txt.patch
19+ ];
20+
21+ cmakeFlags = let
22+ options = {
23+ BOOST_ROOT = "${boost}";
24+ Boost_USE_STATIC_LIBS = "OFF";
25+ RAIBLOCKS_GUI = "ON";
26+ RAIBLOCKS_TEST = "ON";
27+ Qt5_DIR = "${qtbase.dev}/lib/cmake/Qt5";
28+ Qt5Core_DIR = "${qtbase.dev}/lib/cmake/Qt5Core";
29+ Qt5Gui_INCLUDE_DIRS = "${qtbase.dev}/include/QtGui";
30+ Qt5Widgets_INCLUDE_DIRS = "${qtbase.dev}/include/QtWidgets";
31+ };
32+ optionToFlag = name: value: "-D${name}=${value}";
33+ in lib.mapAttrsToList optionToFlag options;
34+
35+ nativeBuildInputs = [ cmake pkgconfig ];
36+ buildInputs = [ boost libGL qtbase ];
37+
38+ buildPhase = ''
39+ make nano_wallet
40+ '';
41+
42+ checkPhase = ''
43+ ./core_test
44+ '';
45+
46+ meta = {
47+ inherit version;
48+ description = "Wallet for Nano cryptocurrency";
49+ homepage = https://nano.org/en/wallet/;
50+ license = lib.licenses.bsd2;
51+ # Fails on Darwin. See:
52+ # https://github.com/NixOS/nixpkgs/pull/39295#issuecomment-386800962
53+ platforms = lib.platforms.linux;
54+ maintainers = with lib.maintainers; [ jluttine ];
55+ };
56+
57+}