diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6057dd6..d7be0f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ on: jobs: ubuntu: - name: Build, Test, and Lint on Ubuntu + name: Build and Test on Ubuntu runs-on: ubuntu-latest steps: @@ -31,11 +31,6 @@ jobs: - name: Run tests run: make test - - name: Run linter - uses: golangci/golangci-lint-action@v9 - with: - version: v2.6.1 - macos: name: Build and Test on macOS runs-on: macos-latest @@ -46,7 +41,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.23.3' + go-version: '1.23' - name: Install Boost library run: | @@ -86,7 +81,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.23.3' + go-version: '1.23' - name: Build Kernel run: make build-kernel @@ -96,3 +91,31 @@ jobs: - name: Run tests run: make test + + nix: + name: Build, Test, and Lint with Nix (Ubuntu) + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@main + + - name: Setup Nix Cache + uses: DeterminateSystems/magic-nix-cache-action@main + + - name: Check flake + run: nix flake check --show-trace + + - name: Build Kernel + run: nix develop --command make build-kernel + + - name: Build + run: nix develop --command make build + + - name: Run tests + run: nix develop --command make test + + - name: Run linter + run: nix develop --command make lint \ No newline at end of file diff --git a/Makefile b/Makefile index 5fc28bd..7cdf9dd 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ lint: golangci-lint run ./... deps: - go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.1 + go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 update-kernel: git subtree pull --prefix=depend/bitcoin https://github.com/bitcoin/bitcoin.git master --squash diff --git a/README.md b/README.md index 22dc83d..6e03bac 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,9 @@ This command will configure Bitcoin Core's CMake build system and statically com [macOS](./depend/bitcoin/doc/build-osx.md), [Windows](./depend/bitcoin/doc/build-windows.md)) -**Addtional note for Windows:** MinGW toolchain is required. CGo uses GCC on Windows, so static linking requires the library to be compiled with GCC/MinGW rather than MSVC for ABI compatibility. +**Additional notes:** +- **For Windows:** MinGW toolchain is required. CGo uses GCC on Windows, so static linking requires the library to be compiled with GCC/MinGW rather than MSVC for ABI compatibility. +- **For Nix users:** Run `nix develop` to automatically get all the build and runtime dependencies, then run `make build-kernel` and continue with the remaining steps in the Nix dev shell. ### Step 3: Run Tests diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..be2978e --- /dev/null +++ b/flake.lock @@ -0,0 +1,60 @@ +{ + "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": 1762756533, + "narHash": "sha256-HiRDeUOD1VLklHeOmaKDzf+8Hb7vSWPVFcWwaTrpm+U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c2448301fb856e351aab33e64c33a3fc8bcf637d", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-25.05", + "type": "indirect" + } + }, + "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..6838c13 --- /dev/null +++ b/flake.nix @@ -0,0 +1,30 @@ +{ + description = "go-bitcoinkernel"; + + inputs = { + nixpkgs.url = "nixpkgs/nixos-25.05"; + 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 + go_1_23 + golangci-lint + ]; + runtimeDeps = with pkgs; [ + boost + ]; + in + { + devShells.default = pkgs.mkShell { + nativeBuildInputs = nativeDeps; + buildInputs = runtimeDeps; + }; + }); +} diff --git a/go.mod b/go.mod index 7f25c34..5df24f1 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/stringintech/go-bitcoinkernel -go 1.23.3 +go 1.23