From 595c7b203dac54b9fef1e4abd505b85ef7b19fd0 Mon Sep 17 00:00:00 2001 From: Alexander Wiederin Date: Fri, 15 May 2026 15:13:07 +0200 Subject: [PATCH 1/2] chore(nix): format flake.nix with nixfmt Formats flake.nix with nixfmt and adds a nixfmt check to the ci. --- .github/workflows/ci.yml | 3 + flake.nix | 146 +++++++++++++++++++++------------------ 2 files changed, 80 insertions(+), 69 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b869d62e..fb1aa7ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,6 +74,9 @@ jobs: - name: Check flake run: nix flake check + - name: Check Nix formatting (nixfmt) + run: nix run nixpkgs#nixfmt -- --check flake.nix + - name: Set Cargo.lock run: cp Cargo-minimal.lock Cargo.lock diff --git a/flake.nix b/flake.nix index c3853bdd..acc4c365 100644 --- a/flake.nix +++ b/flake.nix @@ -1,82 +1,90 @@ { - description = "rust-bitcoinkernel"; + description = "rust-bitcoinkernel"; - inputs = { - nixpkgs.url = "nixpkgs/nixos-25.05"; - flake-utils.url = "github:numtide/flake-utils"; - fenix = { - url = "github:nix-community/fenix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - }; + inputs = { + nixpkgs.url = "nixpkgs/nixos-25.05"; + flake-utils.url = "github:numtide/flake-utils"; + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; - outputs = { self, nixpkgs, flake-utils, fenix }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { - inherit system; - }; + outputs = + { + self, + nixpkgs, + flake-utils, + fenix, + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { + inherit system; + }; - rustVersion = "1.71.0"; - rustToolchain = fenix.packages.${system}.fromToolchainName { - name = rustVersion; - sha256 = "sha256-ks0nMEGGXKrHnfv4Fku+vhQ7gx76ruv6Ij4fKZR3l78="; - }; - rustBuildToolchain = fenix.packages.${system}.combine [ - rustToolchain.rustc - rustToolchain.cargo - rustToolchain.rust-src - rustToolchain.rust-std - ]; + rustVersion = "1.71.0"; + rustToolchain = fenix.packages.${system}.fromToolchainName { + name = rustVersion; + sha256 = "sha256-ks0nMEGGXKrHnfv4Fku+vhQ7gx76ruv6Ij4fKZR3l78="; + }; + rustBuildToolchain = fenix.packages.${system}.combine [ + rustToolchain.rustc + rustToolchain.cargo + rustToolchain.rust-src + rustToolchain.rust-std + ]; - rustBuildToolchainNightly = fenix.packages.${system}.latest.toolchain; + rustBuildToolchainNightly = fenix.packages.${system}.latest.toolchain; - rustPlatformNightly = pkgs.makeRustPlatform { - cargo = rustBuildToolchainNightly; - rustc = rustBuildToolchainNightly; - }; - rustfilt = rustPlatformNightly.buildRustPackage rec { - pname = "rustfilt"; - version = "0.2.1"; - src = pkgs.fetchFromGitHub { - owner = "luser"; - repo = "rustfilt"; - rev = version; - hash = "sha256-zb1tkeWmeMq7aM8hWssS/UpvGzGbfsaVYCOKBnAKwiQ="; - }; - cargoLock.lockFile = "${src}/Cargo.lock"; - }; - in { - devShells.default = pkgs.mkShell { - packages = [ - rustBuildToolchain + rustPlatformNightly = pkgs.makeRustPlatform { + cargo = rustBuildToolchainNightly; + rustc = rustBuildToolchainNightly; + }; + rustfilt = rustPlatformNightly.buildRustPackage rec { + pname = "rustfilt"; + version = "0.2.1"; + src = pkgs.fetchFromGitHub { + owner = "luser"; + repo = "rustfilt"; + rev = version; + hash = "sha256-zb1tkeWmeMq7aM8hWssS/UpvGzGbfsaVYCOKBnAKwiQ="; + }; + cargoLock.lockFile = "${src}/Cargo.lock"; + }; + in + { + devShells.default = pkgs.mkShell { + packages = [ + rustBuildToolchain - pkgs.cmake - pkgs.boost.dev - pkgs.cargo-fuzz - ]; + pkgs.cmake + pkgs.boost.dev + pkgs.cargo-fuzz + ]; - LIBCLANG_PATH = "${pkgs.llvmPackages.clang-unwrapped.lib}/lib/"; - }; + LIBCLANG_PATH = "${pkgs.llvmPackages.clang-unwrapped.lib}/lib/"; + }; - devShells.nightly = pkgs.mkShell { - packages = [ - rustBuildToolchainNightly + devShells.nightly = pkgs.mkShell { + packages = [ + rustBuildToolchainNightly - pkgs.cmake - pkgs.boost.dev - pkgs.cargo-fuzz + pkgs.cmake + pkgs.boost.dev + pkgs.cargo-fuzz - pkgs.libllvm - pkgs.cargo-llvm-cov - rustfilt - ]; + pkgs.libllvm + pkgs.cargo-llvm-cov + rustfilt + ]; - LIBCLANG_PATH = "${pkgs.llvmPackages.clang-unwrapped.lib}/lib/"; - LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ - pkgs.gcc.cc.lib - ]; - }; - } - ); + LIBCLANG_PATH = "${pkgs.llvmPackages.clang-unwrapped.lib}/lib/"; + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ + pkgs.gcc.cc.lib + ]; + }; + } + ); } From c104e190435b2dbd1eeebffb60dc1c8a5050f886 Mon Sep 17 00:00:00 2001 From: Alexander Wiederin Date: Fri, 15 May 2026 15:37:59 +0200 Subject: [PATCH 2/2] chore(ci): add statix check for Nix files --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb1aa7ba..678161db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,6 +77,9 @@ jobs: - name: Check Nix formatting (nixfmt) run: nix run nixpkgs#nixfmt -- --check flake.nix + - name: Lint Nix files (statix) + run: nix run nixpkgs#statix -- check flake.nix + - name: Set Cargo.lock run: cp Cargo-minimal.lock Cargo.lock