From 69d5289a2b95ee75ec5da43a0ef2821594486b6b Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Fri, 7 Nov 2025 00:07:08 -0300 Subject: [PATCH] add Nix dev shell Make it easier to get all the dependencies on Nix system. --- README.md | 4 +++- flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 41 ++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/README.md b/README.md index 838232c..7ca06e0 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ cd go-bitcoinkernel ### Step 2: Build the Native Library +On Nix: `nix develop` to get all the build and runtime dependencies. + ```bash make build-kernel ``` @@ -96,4 +98,4 @@ The library uses structured error types for better error handling (see [errors.g ### Runtime Dependencies -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. \ No newline at end of file +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. diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ee10cae --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1762111121, + "narHash": "sha256-4vhDuZ7OZaZmKKrnDpxLZZpGIJvAeMtK6FKLJYUtAdw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b3d51a0365f6695e7dd5cdf3e180604530ed33b4", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b3d51a0365f6695e7dd5cdf3e180604530ed33b4", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b6cb56a --- /dev/null +++ b/flake.nix @@ -0,0 +1,41 @@ +{ + description = "Development shell for go-bitcoinkernel"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/b3d51a0365f6695e7dd5cdf3e180604530ed33b4"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + }; + nativeDeps = with pkgs; [ + cmake + ninja + pkg-config + go + python3 + git + ]; + runtimeDeps = with pkgs; [ + boost + libevent + zlib + ]; + in + { + devShells.default = pkgs.mkShell { + nativeBuildInputs = nativeDeps; + buildInputs = runtimeDeps; + shellHook = '' + export PKG_CONFIG_PATH=${pkgs.lib.makeSearchPath "lib/pkgconfig" runtimeDeps}''${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH} + export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath runtimeDeps}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} + export CGO_CFLAGS="-I${pkgs.lib.makeIncludePath runtimeDeps}''${CGO_CFLAGS:+ ''${CGO_CFLAGS}}" + export CGO_LDFLAGS="-L${pkgs.lib.makeLibraryPath runtimeDeps}''${CGO_LDFLAGS:+ ''${CGO_LDFLAGS}}" + ''; + }; + }); +}