1{ lib
2, stdenv
3, fetchFromGitHub
4, autoreconfHook
5, pkg-config
6, util-linux
7, hexdump
8, autoSignDarwinBinariesHook
9, wrapQtAppsHook ? null
10, boost
11, libevent
12, miniupnpc
13, zeromq
14, zlib
15, db48
16, sqlite
17, qrencode
18, qtbase ? null
19, qttools ? null
20, python3
21, withGui
22, withWallet ? true
23}:
24
25stdenv.mkDerivation rec {
26 pname = if withGui then "elements" else "elementsd";
27 version = "22.1.1";
28
29 src = fetchFromGitHub {
30 owner = "ElementsProject";
31 repo = "elements";
32 rev = "elements-${version}";
33 sha256 = "sha256-V8Ym4dGshf2E6KsboALXn1DJ5nL3QQvMmVMNdjSw7B8=";
34 };
35
36 nativeBuildInputs =
37 [ autoreconfHook pkg-config ]
38 ++ lib.optionals stdenv.isLinux [ util-linux ]
39 ++ lib.optionals stdenv.isDarwin [ hexdump ]
40 ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ autoSignDarwinBinariesHook ]
41 ++ lib.optionals withGui [ wrapQtAppsHook ];
42
43 buildInputs = [ boost libevent miniupnpc zeromq zlib ]
44 ++ lib.optionals withWallet [ db48 sqlite ]
45 ++ lib.optionals withGui [ qrencode qtbase qttools ];
46
47 configureFlags = [
48 "--with-boost-libdir=${boost.out}/lib"
49 "--disable-bench"
50 ] ++ lib.optionals (!doCheck) [
51 "--disable-tests"
52 "--disable-gui-tests"
53 ] ++ lib.optionals (!withWallet) [
54 "--disable-wallet"
55 ] ++ lib.optionals withGui [
56 "--with-gui=qt5"
57 "--with-qt-bindir=${qtbase.dev}/bin:${qttools.dev}/bin"
58 ];
59
60 # fix "Killed: 9 test/test_bitcoin"
61 # https://github.com/NixOS/nixpkgs/issues/179474
62 hardeningDisable = lib.optionals (stdenv.isAarch64 && stdenv.isDarwin) [ "fortify" "stackprotector" ];
63
64 nativeCheckInputs = [ python3 ];
65
66 doCheck = true;
67
68 checkFlags =
69 [ "LC_ALL=en_US.UTF-8" ]
70 # QT_PLUGIN_PATH needs to be set when executing QT, which is needed when testing Bitcoin's GUI.
71 # See also https://github.com/NixOS/nixpkgs/issues/24256
72 ++ lib.optional withGui "QT_PLUGIN_PATH=${qtbase}/${qtbase.qtPluginPrefix}";
73
74 enableParallelBuilding = true;
75
76 meta = with lib; {
77 description = "Open Source implementation of advanced blockchain features extending the Bitcoin protocol";
78 longDescription= ''
79 The Elements blockchain platform is a collection of feature experiments and extensions to the
80 Bitcoin protocol. This platform enables anyone to build their own businesses or networks
81 pegged to Bitcoin as a sidechain or run as a standalone blockchain with arbitrary asset
82 tokens.
83 '';
84 homepage = "https://www.github.com/ElementsProject/elements";
85 maintainers = with maintainers; [ prusnak ];
86 license = licenses.mit;
87 platforms = platforms.unix;
88 };
89}