-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitcoin.nix
93 lines (82 loc) · 2.41 KB
/
bitcoin.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{ lib
, stdenv
, autoreconfHook
, pkg-config
, util-linux
, hexdump
, autoSignDarwinBinariesHook
, wrapQtAppsHook ? null
, boost
, libevent
, miniupnpc
, zeromq
, zlib
, db48
, sqlite
, qrencode
, qtbase ? null
, qttools ? null
, python3
, withGui ? false
, withWallet ? true
, withTests ? true
, doCheck ? true
, parallelBuild ? true
}:
assert doCheck -> withTests;
stdenv.mkDerivation {
pname = if withGui then "bitcoin" else "bitcoind";
version = "dev";
# TODO: specify accurate source
# src = lib.sourceFilesBySuffices ./. [ ".ac" ".am" ".m4" ".in" ".include" ".mk" ".h" ".hpp" ".c" ".cc" ".cpp" ".inc" ".py" ".json" ".raw" ".sh" ".1" ".hex" ".csv" ".html" "Makefile" ];
src = lib.cleanSource (lib.cleanSourceWith {
filter = name: type:
let
baseName = baseNameOf (toString name);
in
!(lib.hasSuffix ".cache" baseName || lib.hasSuffix ".Po" baseName);
src = ./.;
});
nativeBuildInputs =
[ autoreconfHook pkg-config ]
++ lib.optionals stdenv.isLinux [ util-linux ]
++ lib.optionals stdenv.isDarwin [ hexdump ]
++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ autoSignDarwinBinariesHook ]
++ lib.optionals withGui [ wrapQtAppsHook ];
buildInputs = [ boost libevent miniupnpc zeromq zlib ]
++ lib.optionals withWallet [ db48 sqlite ]
++ lib.optionals withGui [ qrencode qtbase qttools ];
configureFlags = [
"--with-boost-libdir=${boost.out}/lib"
"--disable-bench"
] ++ lib.optionals (!withTests) [
"--disable-tests"
"--disable-gui-tests"
] ++ lib.optionals (!withWallet) [
"--disable-wallet"
] ++ lib.optionals withGui [
"--with-gui=qt5"
"--with-qt-bindir=${qtbase.dev}/bin:${qttools.dev}/bin"
];
enableParallelBuilding = parallelBuild;
makeFlags = [ "VERBOSE=true" ];
nativeCheckInputs = [ python3 ];
checkFlags = [
"LC_ALL=en_US.UTF-8"
] ++ lib.optionals withGui [
# QT_PLUGIN_PATH needs to be set when executing QT, which is needed when testing Bitcoin's GUI.
# See also https://github.com/NixOS/nixpkgs/issues/24256
"QT_PLUGIN_PATH=${qtbase}/${qtbase.qtPluginPrefix}"
];
testRunnerFlags = [ ] ++ lib.optionals parallelBuild [ "-j=$NIX_BUILD_CORES" ];
postCheck = if doCheck
then ''
patchShebangs test/functional
(cd test/functional && python3 test_runner.py $testRunnerFlags)
''
else "";
meta = with lib; {
license = licenses.mit;
platforms = platforms.unix;
};
}