forked from ark-bitcoin/bark
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
126 lines (114 loc) · 3.9 KB
/
flake.nix
File metadata and controls
126 lines (114 loc) · 3.9 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
{
description = "ark";
inputs = {
nixpkgs.url = "nixpkgs/nixos-24.05";
flake-utils = {
url = "github:numtide/flake-utils";
};
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";
bitcoinVersion = "28.0";
lightningVersion = "24.08.2";
protobufVersion = "3.12.4";
lib = nixpkgs.lib;
isDarwin = builtins.match ".*darwin.*" system != null;
overlays = [ rust-overlay.overlays.default ];
pkgs = import nixpkgs {
inherit system overlays;
};
rust = pkgs.rust-bin.stable.${rustVersion}.default.override {
extensions = [ "rust-src" "rust-analyzer" ];
};
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 = (if isDarwin then null else 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-U54HNOreulhvCYeULyBbl/WHQ7F9WQnSCSMGg5WUAdg=";
};
}));
cln-grpc = pkgs.rustPlatform.buildRustPackage rec {
pname = "cln-grpc";
version = "99.99.99";
src = pkgs.fetchFromGitHub {
owner = "ElementsProject";
repo = "lightning";
rev = "v${lightningVersion}";
hash = "sha256-MWU75e55Zt/P4aaIuMte7iRcrFGMw0P81b8VNHQBe2g=";
};
buildAndTestSubdir = "plugins/grpc-plugin";
nativeBuildInputs = [ protobuf ];
buildInputs = (if isDarwin then [ pkgs.darwin.apple_sdk.frameworks.Security ] else []);
cargoDeps = pkgs.rustPlatform.importCargoLock {
lockFile = ./Cargo.lock;
};
cargoHash = "sha256-6s1NtTx9LnRXaPVHosKRlU7NMeAHKC/EalRtS+bZXkU=";
# Avoid doing the configure step of the clightning C project
postUnpack = ''
rm ${src.name}/configure
'';
doCheck = false; # tests are broken
};
protobuf = pkgs.protobuf3_20.overrideAttrs (old: {
version = protobufVersion;
src = pkgs.fetchFromGitHub {
owner = "protocolbuffers";
repo = "protobuf";
rev = "v{protobufVersion}";
hash = "sha256-VyzFq1agobjvei4o/fQ8iMOLySf38DQsLb3C8kCz+78=";
};
});
target = lib.strings.replaceStrings [ "-" ] [ "_" ] pkgs.stdenv.buildPlatform.config;
in
{
devShells.default = pkgs.mkShell {
nativeBuildInput = [ ];
buildInputs = [ pkgs.llvmPackages.clang ] ++ [
# For CI image
pkgs.coreutils
pkgs.which
pkgs.git
pkgs.gnugrep
# For building
rust
pkgs.pkg-config
protobuf
pkgs.sqlite
# For development & testing
pkgs.just
pkgs.jq
pkgs.python3 # for clightning
bitcoin
clightning
] ++ (if isDarwin then [
pkgs.darwin.apple_sdk.frameworks.Security
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
pkgs.docker
] else []);
LIBCLANG_PATH = "${pkgs.llvmPackages.clang-unwrapped.lib}/lib/";
ROCKSDB_LIB_DIR = "${pkgs.rocksdb}/lib/";
"ROCKSDB_${target}_LIB_DIR" = "${pkgs.rocksdb}/lib/";
#ROCKSDB_STATIC = "true"; # NB do this for prod
#"ROCKSDB_${target}_STATIC" = "true"; # NB do this for prod
BITCOIND_EXEC = "${bitcoin}/bin/bitcoind";
# Use Docker for Core Lightning on macOS by default instead of a local daemon
LIGHTNINGD_EXEC = (if isDarwin then null else "${clightning}/bin/lightningd");
LIGHTNINGD_DOCKER_IMAGE = (if isDarwin then "elementsproject/lightningd:v${lightningVersion}" else null);
LIGHTNINGD_PLUGINS = "${cln-grpc}/bin/";
};
}
);
}