forked from ark-bitcoin/bark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
110 lines (98 loc) · 3.39 KB
/
flake.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
{
description = "ark";
inputs = {
nixpkgs.url = "nixpkgs/nixos-24.05";
flake-utils = {
url = "github:numtide/flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
flake-utils.lib.eachDefaultSystem (system:
let
rustVersion = "1.77.1";
protobufVersion = "3.12.4";
bitcoinVersion = "28.0";
lightningVersion = "24.05";
lib = nixpkgs.lib;
overlays = [ rust-overlay.overlays.default ];
pkgs = import nixpkgs {
inherit system overlays;
};
bitcoin = pkgs.bitcoin.overrideAttrs (old: {
version = bitcoinVersion;
src = pkgs.fetchurl {
urls = [ "https://bitcoincore.org/bin/bitcoin-core-${bitcoinVersion}/bitcoin-${bitcoinVersion}.tar.gz" ];
sha256 = "sha256-cAri0eIEYC6wfyd5puZmmJO8lsDcopBZP4D/jhAv838=";
};
});
clightning = pkgs.clightning.overrideAttrs (old: {
version = lightningVersion;
src = pkgs.fetchurl {
url = "https://github.com/ElementsProject/lightning/releases/download/v${lightningVersion}/clightning-v${lightningVersion}.zip";
hash = "sha256-FD7JFM80wrruqBWjYnJHZh2f2GZJ6XDQmUQ0XetnWBg=";
};
});
protobuf = pkgs.protobuf3_20.overrideAttrs (old: {
version = protobufVersion;
src = pkgs.fetchFromGitHub {
owner = "protocolbuffers";
repo = "protobuf";
rev = "v{protobufVersion}";
hash = "sha256-VyzFq1agobjvei4o/fQ8iMOLySf38DQsLb3C8kCz+78=";
};
});
target = pkgs.stdenv.buildPlatform.config;
target_underscores = lib.strings.replaceStrings [ "-" ] [ "_" ] target;
target_underscores_upper = lib.strings.toUpper target_underscores;
# This is a bunch of stuff that is somehow necessary to build rocksdb.
targetLlvmConfigWrapper = { binClangPkg, libClangPkg }: pkgs.writeShellScriptBin "llvm-config" ''
if [ "$1" == "--bindir" ]; then
echo "${binClangPkg}/bin"
exit 0
fi
if [ "$1" == "--prefix" ]; then
echo "${libClangPkg}"
exit 0
fi
exec llvm-config "$@"
'';
llvmConfigPkg = targetLlvmConfigWrapper {
binClangPkg = pkgs.llvmPackages.clang;
libClangPkg = pkgs.llvmPackages.clang-unwrapped.lib;
};
clang = pkgs.llvmPackages.clang;
in
{
devShells.default = pkgs.mkShell {
nativeBuildInput = [ ];
buildInputs = [ clang ] ++ [
(pkgs.rust-bin.stable.${rustVersion}.default.override {
extensions = [ "rust-src" "rust-analyzer" ];
})
pkgs.pkg-config
protobuf
pkgs.sqlite
bitcoin
clightning
];
LLVM_CONFIG_PATH = "${llvmConfigPkg}/bin/llvm-config";
LLVM_CONFIG_PATH_native = "${llvmConfigPkg}/bin/llvm-config";
"LLVM_CONFIG_PATH_${target_underscores}" = "${llvmConfigPkg}/bin/llvm-config";
LIBCLANG_PATH = "${pkgs.llvmPackages.clang-unwrapped.lib}/lib/";
"CARGO_TARGET_${target_underscores_upper}_LINKER" = "${clang}/bin/clang";
PROTOC = "${protobuf}/bin/protoc";
ROCKSDB_LIB_DIR = "${pkgs.rocksdb}/lib/";
"ROCKSDB_${target_underscores}_LIB_DIR" = "${pkgs.rocksdb}/lib/";
#ROCKSDB_STATIC = "true"; # NB do this for prod
#"ROCKSDB_${target_underscores}_STATIC" = "true"; # NB do this for prod
BITCOIND_EXEC = "${bitcoin}/bin/bitcoind";
LIGHTNINGD_EXEC = "${clightning}/bin/lightningd";
};
}
);
}