Skip to content

Commit 69d5289

Browse files
committed
add Nix dev shell
Make it easier to get all the dependencies on Nix system.
1 parent 4e19882 commit 69d5289

File tree

3 files changed

+105
-1
lines changed

3 files changed

+105
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ cd go-bitcoinkernel
3535

3636
### Step 2: Build the Native Library
3737

38+
On Nix: `nix develop` to get all the build and runtime dependencies.
39+
3840
```bash
3941
make build-kernel
4042
```
@@ -96,4 +98,4 @@ The library uses structured error types for better error handling (see [errors.g
9698

9799
### Runtime Dependencies
98100

99-
Your Go application will have a runtime dependency on the shared `libbitcoinkernel` library produced by `make build-kernel` in `/path/to/go-bitcoinkernel/depend/bitcoin/build`. Do not delete or move these built library files as your application needs them to run.
101+
Your Go application will have a runtime dependency on the shared `libbitcoinkernel` library produced by `make build-kernel` in `/path/to/go-bitcoinkernel/depend/bitcoin/build`. Do not delete or move these built library files as your application needs them to run.

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
description = "Development shell for go-bitcoinkernel";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/b3d51a0365f6695e7dd5cdf3e180604530ed33b4";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = { self, nixpkgs, flake-utils }:
10+
flake-utils.lib.eachDefaultSystem (system:
11+
let
12+
pkgs = import nixpkgs {
13+
inherit system;
14+
};
15+
nativeDeps = with pkgs; [
16+
cmake
17+
ninja
18+
pkg-config
19+
go
20+
python3
21+
git
22+
];
23+
runtimeDeps = with pkgs; [
24+
boost
25+
libevent
26+
zlib
27+
];
28+
in
29+
{
30+
devShells.default = pkgs.mkShell {
31+
nativeBuildInputs = nativeDeps;
32+
buildInputs = runtimeDeps;
33+
shellHook = ''
34+
export PKG_CONFIG_PATH=${pkgs.lib.makeSearchPath "lib/pkgconfig" runtimeDeps}''${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}
35+
export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath runtimeDeps}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
36+
export CGO_CFLAGS="-I${pkgs.lib.makeIncludePath runtimeDeps}''${CGO_CFLAGS:+ ''${CGO_CFLAGS}}"
37+
export CGO_LDFLAGS="-L${pkgs.lib.makeLibraryPath runtimeDeps}''${CGO_LDFLAGS:+ ''${CGO_LDFLAGS}}"
38+
'';
39+
};
40+
});
41+
}

0 commit comments

Comments
 (0)