forked from ark-bitcoin/bark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
166 lines (152 loc) · 5.23 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
{
description = "ark";
inputs = {
nixpkgs.url = "nixpkgs/nixos-24.11";
nixpkgs-master.url = "github:NixOS/nixpkgs/master";
flake-utils = {
url = "github:numtide/flake-utils";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, nixpkgs-master, flake-utils, rust-overlay }:
flake-utils.lib.eachDefaultSystem (system:
let
rustVersion = "1.75.0";
bitcoinVersion = "29.0";
lightningVersion = "25.02";
electrsRevision = "9a4175d68ff8a098a05676e774c46aba0c9e558d";
lib = nixpkgs.lib;
isDarwin = pkgs.stdenv.hostPlatform.isDarwin;
overlays = [ rust-overlay.overlays.default ];
target = lib.strings.replaceStrings [ "-" ] [ "_" ] pkgs.stdenv.buildPlatform.config;
pkgs = import nixpkgs {
inherit system overlays;
};
masterPkgs = import nixpkgs-master {
inherit system;
};
rust = pkgs.rust-bin.stable.${rustVersion}.default.override {
extensions = [ "rust-src" "rust-analyzer" ];
};
bitcoin = masterPkgs.bitcoind.overrideAttrs (old: {
version = bitcoinVersion;
src = pkgs.fetchurl {
urls = [ "https://bitcoincore.org/bin/bitcoin-core-${bitcoinVersion}/bitcoin-${bitcoinVersion}.tar.gz" ];
sha256 = "sha256-iCx4LDSjvy6s0frlzcWLNbhpiDUS8Zf31tyPGV3s/ao=";
};
doCheck = false;
});
hal = pkgs.rustPlatform.buildRustPackage rec {
pname = "hal";
version = "0.9.5";
src = pkgs.fetchCrate {
inherit pname version;
sha256 = "sha256-rwVny9i0vFycoeAesy2iP7sA16fECLu1UPbqrOJa1is=";
};
cargoSha256 = "sha256-dATviea1btnIVYKKgU1fMtZxKJitp/wXAuoIsxCSgf4=";
};
electrs = pkgs.rustPlatform.buildRustPackage rec {
pname = "esplora-electrs";
version = "99.99.99";
src = pkgs.fetchFromGitHub {
owner = "stevenroose";
repo = "electrs";
rev = electrsRevision;
hash = "sha256-3/0dl+HhUQdCX66ALj+gMndhQAx3AoPJMCqQyq/PK+g=";
};
ROCKSDB_LIB_DIR = "${pkgs.rocksdb}/lib/";
"ROCKSDB_${target}_LIB_DIR" = "${pkgs.rocksdb}/lib/";
nativeBuildInputs = [ pkgs.rustPlatform.bindgenHook ];
buildInputs = [
pkgs.llvmPackages.clang
];
doCheck = false;
cargoLock.lockFile = "${src}/Cargo.lock";
cargoLock.outputHashes = {
"electrum-client-0.8.0" = "sha256-HDRdGS7CwWsPXkA1HdurwrVu4lhEx0Ay8vHi08urjZ0=";
"electrumd-0.1.0" = "sha256-QsoMD2uVDEITuYmYItfP6BJCq7ApoRztOCs7kdeRL9Y=";
"jsonrpc-0.12.0" = "sha256-lSNkkQttb8LnJej4Vfe7MrjiNPOuJ5A6w5iLstl9O1k=";
};
};
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-00cG/DkRAwR/fMuuKXml2QAiE0yC6TlQUqXELbbDPRE=";
};
makeFlags = [ "VERSION=v${lightningVersion}" ];
# some makefile bug: https://github.com/ElementsProject/lightning/issues/8141
preInstall = ''
mkdir -p $out/libexec/c-lightning/plugins/
touch $out/libexec/c-lightning/plugins/clnrest
'';
}));
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-Xkh4ggUSX2xLJQes8cE5jyu2DZut/YRcQq5vsDH7S+k=";
};
buildAndTestSubdir = "plugins/grpc-plugin";
nativeBuildInputs = [ pkgs.protobuf ];
buildInputs = (if isDarwin then [ pkgs.darwin.apple_sdk.frameworks.Security ] else []);
cargoDeps = pkgs.rustPlatform.importCargoLock {
lockFile = "${src}/Cargo.lock";
};
cargoHash = "sha256-UOhoqVs7nxZ98v2lJrAOc/qT8bcSPHekloUObI7wuJc=";
# Avoid doing the configure step of the clightning C project
postUnpack = ''
rm ${src.name}/configure
'';
doCheck = false; # tests are broken
};
in
{
devShells.default = pkgs.mkShell {
nativeBuildInput = [ ];
buildInputs = [
# For CI image
pkgs.coreutils
pkgs.which
pkgs.git
pkgs.gnugrep
# For building
pkgs.llvmPackages.clang
pkgs.rustPlatform.bindgenHook
rust
pkgs.pkg-config
pkgs.protobuf
pkgs.sqlite
# For development & testing
pkgs.just
hal
pkgs.jq
pkgs.python3 # for clightning
bitcoin
clightning
electrs
pkgs.glibcLocales
pkgs.postgresql
] ++ (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/";
BITCOIND_EXEC = "${bitcoin}/bin/bitcoind";
ELECTRS_EXEC = "${electrs}/bin/electrs";
# 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/";
POSTGRES_BINS = "${pkgs.postgresql}/bin";
};
}
);
}