biome: 1.9.2 -> 1.9.3
[NixPkgs.git] / pkgs / applications / blockchains / bitcoin / default.nix
blobe56d332cf57594b51788437ad5a0be3089f19086
1 { lib
2 , stdenv
3 , fetchurl
4 , fetchpatch2
5 , autoreconfHook
6 , pkg-config
7 , installShellFiles
8 , util-linux
9 , hexdump
10 , autoSignDarwinBinariesHook
11 , wrapQtAppsHook ? null
12 , boost
13 , libevent
14 , miniupnpc
15 , zeromq
16 , zlib
17 , db48
18 , sqlite
19 , qrencode
20 , qtbase ? null
21 , qttools ? null
22 , python3
23 , nixosTests
24 , withGui
25 , withWallet ? true
28 let
29   desktop = fetchurl {
30     # c2e5f3e is the last commit when the debian/bitcoin-qt.desktop file was changed
31     url = "https://raw.githubusercontent.com/bitcoin-core/packaging/c2e5f3e20a8093ea02b73cbaf113bc0947b4140e/debian/bitcoin-qt.desktop";
32     sha256 = "0cpna0nxcd1dw3nnzli36nf9zj28d2g9jf5y0zl9j18lvanvniha";
33   };
35 stdenv.mkDerivation rec {
36   pname = if withGui then "bitcoin" else "bitcoind";
37   version = "28.0";
39   src = fetchurl {
40     urls = [
41       "https://bitcoincore.org/bin/bitcoin-core-${version}/bitcoin-${version}.tar.gz"
42     ];
43     # hash retrieved from signed SHA256SUMS
44     sha256 = "700ae2d1e204602eb07f2779a6e6669893bc96c0dca290593f80ff8e102ff37f";
45   };
47   nativeBuildInputs =
48     [ autoreconfHook pkg-config installShellFiles ]
49     ++ lib.optionals stdenv.hostPlatform.isLinux [ util-linux ]
50     ++ lib.optionals stdenv.hostPlatform.isDarwin [ hexdump ]
51     ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ autoSignDarwinBinariesHook ]
52     ++ lib.optionals withGui [ wrapQtAppsHook ];
54   buildInputs = [ boost libevent miniupnpc zeromq zlib ]
55     ++ lib.optionals withWallet [ sqlite ]
56     # building with db48 (for legacy descriptor wallet support) is broken on Darwin
57     ++ lib.optionals (withWallet && !stdenv.hostPlatform.isDarwin) [ db48 ]
58     ++ lib.optionals withGui [ qrencode qtbase qttools ];
60   postInstall = ''
61     installShellCompletion --bash contrib/completions/bash/bitcoin-cli.bash
62     installShellCompletion --bash contrib/completions/bash/bitcoind.bash
63     installShellCompletion --bash contrib/completions/bash/bitcoin-tx.bash
65     installShellCompletion --fish contrib/completions/fish/bitcoin-cli.fish
66     installShellCompletion --fish contrib/completions/fish/bitcoind.fish
67     installShellCompletion --fish contrib/completions/fish/bitcoin-tx.fish
68     installShellCompletion --fish contrib/completions/fish/bitcoin-util.fish
69     installShellCompletion --fish contrib/completions/fish/bitcoin-wallet.fish
70   '' + lib.optionalString withGui ''
71     installShellCompletion --fish contrib/completions/fish/bitcoin-qt.fish
73     install -Dm644 ${desktop} $out/share/applications/bitcoin-qt.desktop
74     substituteInPlace $out/share/applications/bitcoin-qt.desktop --replace "Icon=bitcoin128" "Icon=bitcoin"
75     install -Dm644 share/pixmaps/bitcoin256.png $out/share/pixmaps/bitcoin.png
76   '';
78   preConfigure = lib.optionalString stdenv.hostPlatform.isDarwin ''
79     export MACOSX_DEPLOYMENT_TARGET=10.13
80   '';
82   configureFlags = [
83     "--with-boost-libdir=${boost.out}/lib"
84     "--disable-bench"
85   ] ++ lib.optionals (!doCheck) [
86     "--disable-tests"
87     "--disable-gui-tests"
88   ] ++ lib.optionals (!withWallet) [
89     "--disable-wallet"
90   ] ++ lib.optionals withGui [
91     "--with-gui=qt5"
92     "--with-qt-bindir=${qtbase.dev}/bin:${qttools.dev}/bin"
93   ];
95   nativeCheckInputs = [ python3 ];
97   doCheck = true;
99   checkFlags =
100     [ "LC_ALL=en_US.UTF-8" ]
101     # QT_PLUGIN_PATH needs to be set when executing QT, which is needed when testing Bitcoin's GUI.
102     # See also https://github.com/NixOS/nixpkgs/issues/24256
103     ++ lib.optional withGui "QT_PLUGIN_PATH=${qtbase}/${qtbase.qtPluginPrefix}";
105   enableParallelBuilding = true;
107   passthru.tests = {
108     smoke-test = nixosTests.bitcoind;
109   };
111   meta = with lib; {
112     description = "Peer-to-peer electronic cash system";
113     longDescription = ''
114       Bitcoin is a free open source peer-to-peer electronic cash system that is
115       completely decentralized, without the need for a central server or trusted
116       parties. Users hold the crypto keys to their own money and transact directly
117       with each other, with the help of a P2P network to check for double-spending.
118     '';
119     homepage = "https://bitcoin.org/en/";
120     downloadPage = "https://bitcoincore.org/bin/bitcoin-core-${version}/";
121     changelog = "https://bitcoincore.org/en/releases/${version}/";
122     maintainers = with maintainers; [ prusnak roconnor ];
123     license = licenses.mit;
124     platforms = platforms.unix;
125   };