|
| 1 | +# Copied from nixpkgs 9765893b19b7e121f327f3d2e0d6079386bebea2 |
| 2 | +{ lib |
| 3 | +, stdenv |
| 4 | +, fetchurl |
| 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 |
| 26 | +}: |
| 27 | + |
| 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 | + }; |
| 34 | +in |
| 35 | +stdenv.mkDerivation rec { |
| 36 | + pname = if withGui then "bitcoin" else "bitcoind"; |
| 37 | + version = "26.1"; |
| 38 | + |
| 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 = "9164ee5d717b4a20cb09f0496544d9d32f365734814fe399f5cdb4552a9b35ee"; |
| 45 | + }; |
| 46 | + |
| 47 | + nativeBuildInputs = |
| 48 | + [ autoreconfHook pkg-config installShellFiles ] |
| 49 | + ++ lib.optionals stdenv.isLinux [ util-linux ] |
| 50 | + ++ lib.optionals stdenv.isDarwin [ hexdump ] |
| 51 | + ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ autoSignDarwinBinariesHook ] |
| 52 | + ++ lib.optionals withGui [ wrapQtAppsHook ]; |
| 53 | + |
| 54 | + buildInputs = [ boost libevent miniupnpc zeromq zlib ] |
| 55 | + ++ lib.optionals withWallet [ db48 sqlite ] |
| 56 | + ++ lib.optionals withGui [ qrencode qtbase qttools ]; |
| 57 | + |
| 58 | + postInstall = '' |
| 59 | + installShellCompletion --bash contrib/completions/bash/bitcoin-cli.bash |
| 60 | + installShellCompletion --bash contrib/completions/bash/bitcoind.bash |
| 61 | + installShellCompletion --bash contrib/completions/bash/bitcoin-tx.bash |
| 62 | +
|
| 63 | + installShellCompletion --fish contrib/completions/fish/bitcoin-cli.fish |
| 64 | + installShellCompletion --fish contrib/completions/fish/bitcoind.fish |
| 65 | + installShellCompletion --fish contrib/completions/fish/bitcoin-tx.fish |
| 66 | + installShellCompletion --fish contrib/completions/fish/bitcoin-util.fish |
| 67 | + installShellCompletion --fish contrib/completions/fish/bitcoin-wallet.fish |
| 68 | + '' + lib.optionalString withGui '' |
| 69 | + installShellCompletion --fish contrib/completions/fish/bitcoin-qt.fish |
| 70 | +
|
| 71 | + install -Dm644 ${desktop} $out/share/applications/bitcoin-qt.desktop |
| 72 | + substituteInPlace $out/share/applications/bitcoin-qt.desktop --replace "Icon=bitcoin128" "Icon=bitcoin" |
| 73 | + install -Dm644 share/pixmaps/bitcoin256.png $out/share/pixmaps/bitcoin.png |
| 74 | + ''; |
| 75 | + |
| 76 | + preConfigure = lib.optionalString stdenv.isDarwin '' |
| 77 | + export MACOSX_DEPLOYMENT_TARGET=10.13 |
| 78 | + ''; |
| 79 | + |
| 80 | + configureFlags = [ |
| 81 | + "--with-boost-libdir=${boost.out}/lib" |
| 82 | + "--disable-bench" |
| 83 | + ] ++ lib.optionals (!doCheck) [ |
| 84 | + "--disable-tests" |
| 85 | + "--disable-gui-tests" |
| 86 | + ] ++ lib.optionals (!withWallet) [ |
| 87 | + "--disable-wallet" |
| 88 | + ] ++ lib.optionals withGui [ |
| 89 | + "--with-gui=qt5" |
| 90 | + "--with-qt-bindir=${qtbase.dev}/bin:${qttools.dev}/bin" |
| 91 | + ]; |
| 92 | + |
| 93 | + nativeCheckInputs = [ python3 ]; |
| 94 | + |
| 95 | + doCheck = true; |
| 96 | + |
| 97 | + checkFlags = |
| 98 | + [ "LC_ALL=en_US.UTF-8" ] |
| 99 | + # QT_PLUGIN_PATH needs to be set when executing QT, which is needed when testing Bitcoin's GUI. |
| 100 | + # See also https://github.com/NixOS/nixpkgs/issues/24256 |
| 101 | + ++ lib.optional withGui "QT_PLUGIN_PATH=${qtbase}/${qtbase.qtPluginPrefix}"; |
| 102 | + |
| 103 | + enableParallelBuilding = true; |
| 104 | + |
| 105 | + passthru.tests = { |
| 106 | + smoke-test = nixosTests.bitcoind; |
| 107 | + }; |
| 108 | + |
| 109 | + meta = with lib; { |
| 110 | + description = "Peer-to-peer electronic cash system"; |
| 111 | + longDescription = '' |
| 112 | + Bitcoin is a free open source peer-to-peer electronic cash system that is |
| 113 | + completely decentralized, without the need for a central server or trusted |
| 114 | + parties. Users hold the crypto keys to their own money and transact directly |
| 115 | + with each other, with the help of a P2P network to check for double-spending. |
| 116 | + ''; |
| 117 | + homepage = "https://bitcoin.org/en/"; |
| 118 | + downloadPage = "https://bitcoincore.org/bin/bitcoin-core-${version}/"; |
| 119 | + changelog = "https://bitcoincore.org/en/releases/${version}/"; |
| 120 | + maintainers = with maintainers; [ prusnak roconnor ]; |
| 121 | + license = licenses.mit; |
| 122 | + platforms = platforms.unix; |
| 123 | + }; |
| 124 | +} |
0 commit comments