nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildGoModule,
4 bzip2,
5 fetchFromGitHub,
6 lz4,
7 nixosTests,
8 pkg-config,
9 rocksdb_9_10,
10 snappy,
11 stdenv,
12 zeromq,
13 zlib,
14}:
15
16let
17 rocksdb = rocksdb_9_10;
18in
19buildGoModule rec {
20 pname = "blockbook";
21 version = "0.5.0";
22 commit = "657cbcf";
23
24 src = fetchFromGitHub {
25 owner = "trezor";
26 repo = "blockbook";
27 rev = "v${version}";
28 hash = "sha256-8/tyqmZE9NJWGg7zYcdei0f1lpXfehy6LM6k5VHW33g=";
29 };
30
31 proxyVendor = true;
32
33 vendorHash = "sha256-W29AvzfleCYC2pgHj2OB00PWBTcD2UUDbDH/z5A3bQ4=";
34
35 nativeBuildInputs = [ pkg-config ];
36
37 buildInputs = [
38 bzip2
39 lz4
40 rocksdb
41 snappy
42 zeromq
43 zlib
44 ];
45
46 ldflags = [
47 "-X github.com/trezor/blockbook/common.version=${version}"
48 "-X github.com/trezor/blockbook/common.gitcommit=${commit}"
49 "-X github.com/trezor/blockbook/common.buildDate=unknown"
50 ];
51
52 CGO_LDFLAGS = [
53 "-L${lib.getLib stdenv.cc.cc}/lib"
54 "-lrocksdb"
55 "-lz"
56 "-lbz2"
57 "-lsnappy"
58 "-llz4"
59 "-lm"
60 "-lstdc++"
61 ];
62
63 preBuild = lib.optionalString stdenv.hostPlatform.isDarwin ''
64 ulimit -n 8192
65 '';
66
67 subPackages = [ "." ];
68
69 postInstall = ''
70 mkdir -p $out/share/
71 cp -r $src/static/templates/ $out/share/
72 cp -r $src/static/css/ $out/share/
73 '';
74
75 passthru.tests = {
76 smoke-test = nixosTests.blockbook-frontend;
77 };
78
79 meta = with lib; {
80 description = "Trezor address/account balance backend";
81 homepage = "https://github.com/trezor/blockbook";
82 license = licenses.agpl3Only;
83 maintainers = with maintainers; [
84 mmahut
85 ];
86 platforms = platforms.unix;
87 mainProgram = "blockbook";
88 };
89}