1{
2 lib,
3 stdenv,
4 fetchurl,
5 autoreconfHook,
6 pkg-config,
7 util-linux,
8 hexdump,
9 autoSignDarwinBinariesHook,
10 wrapQtAppsHook ? null,
11 boost,
12 libevent,
13 miniupnpc,
14 zeromq,
15 zlib,
16 db48,
17 sqlite,
18 qrencode,
19 qtbase ? null,
20 qttools ? null,
21 python3,
22 withGui,
23 withWallet ? true,
24}:
25
26stdenv.mkDerivation rec {
27 pname = if withGui then "bitcoin-knots" else "bitcoind-knots";
28 version = "28.1.knots20250305";
29
30 src = fetchurl {
31 url = "https://bitcoinknots.org/files/28.x/${version}/bitcoin-${version}.tar.gz";
32 hash = "sha256-DKO3+43Tn/BTKQVrLrCkeMtzm8SfbaJD8rPlb6lDA8A=";
33 };
34
35 nativeBuildInputs = [
36 autoreconfHook
37 pkg-config
38 ]
39 ++ lib.optionals stdenv.hostPlatform.isLinux [ util-linux ]
40 ++ lib.optionals stdenv.hostPlatform.isDarwin [ hexdump ]
41 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
42 autoSignDarwinBinariesHook
43 ]
44 ++ lib.optionals withGui [ wrapQtAppsHook ];
45
46 buildInputs = [
47 boost
48 libevent
49 miniupnpc
50 zeromq
51 zlib
52 ]
53 ++ lib.optionals withWallet [ sqlite ]
54 ++ lib.optionals (withWallet && !stdenv.hostPlatform.isDarwin) [ db48 ]
55 ++ lib.optionals withGui [
56 qrencode
57 qtbase
58 qttools
59 ];
60
61 configureFlags = [
62 "--with-boost-libdir=${boost.out}/lib"
63 "--disable-bench"
64 ]
65 ++ lib.optionals (!doCheck) [
66 "--disable-tests"
67 "--disable-gui-tests"
68 ]
69 ++ lib.optionals (!withWallet) [
70 "--disable-wallet"
71 ]
72 ++ lib.optionals withGui [
73 "--with-gui=qt5"
74 "--with-qt-bindir=${qtbase.dev}/bin:${qttools.dev}/bin"
75 ];
76
77 nativeCheckInputs = [ python3 ];
78
79 doCheck = true;
80
81 checkFlags = [
82 "LC_ALL=en_US.UTF-8"
83 ]
84 # QT_PLUGIN_PATH needs to be set when executing QT, which is needed when testing Bitcoin's GUI.
85 # See also https://github.com/NixOS/nixpkgs/issues/24256
86 ++ lib.optional withGui "QT_PLUGIN_PATH=${qtbase}/${qtbase.qtPluginPrefix}";
87
88 enableParallelBuilding = true;
89
90 meta = {
91 description = "Derivative of Bitcoin Core with a collection of improvements";
92 homepage = "https://bitcoinknots.org/";
93 changelog = "https://github.com/bitcoinknots/bitcoin/blob/v${version}/doc/release-notes.md";
94 maintainers = with lib.maintainers; [
95 prusnak
96 mmahut
97 ];
98 license = lib.licenses.mit;
99 platforms = lib.platforms.unix;
100 };
101}