From f836bb514a49712c06f240e65db4dce32a83f5f0 Mon Sep 17 00:00:00 2001 From: Adriano Di Luzio Date: Thu, 10 Jul 2025 10:03:00 +0200 Subject: [PATCH 1/2] fix: add missing `tools/config-docs-generator` to `nix` fileset --- contrib/nix/flake.lock | 18 +++---- contrib/nix/flake.nix | 105 +++++++++++++++-------------------------- 2 files changed, 46 insertions(+), 77 deletions(-) diff --git a/contrib/nix/flake.lock b/contrib/nix/flake.lock index 69951ab296..2a1995f03b 100644 --- a/contrib/nix/flake.lock +++ b/contrib/nix/flake.lock @@ -2,11 +2,11 @@ "nodes": { "crane": { "locked": { - "lastModified": 1739936662, - "narHash": "sha256-x4syUjNUuRblR07nDPeLDP7DpphaBVbUaSoeZkFbGSk=", + "lastModified": 1751562746, + "narHash": "sha256-smpugNIkmDeicNz301Ll1bD7nFOty97T79m4GUMUczA=", "owner": "ipetkov", "repo": "crane", - "rev": "19de14aaeb869287647d9461cbd389187d8ecdb7", + "rev": "aed2020fd3dc26e1e857d4107a5a67a33ab6c1fd", "type": "github" }, "original": { @@ -37,11 +37,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1740547748, - "narHash": "sha256-Ly2fBL1LscV+KyCqPRufUBuiw+zmWrlJzpWOWbahplg=", + "lastModified": 1751949589, + "narHash": "sha256-mgFxAPLWw0Kq+C8P3dRrZrOYEQXOtKuYVlo9xvPntt8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3a05eebede89661660945da1f151959900903b6a", + "rev": "9b008d60392981ad674e04016d25619281550a9d", "type": "github" }, "original": { @@ -67,11 +67,11 @@ ] }, "locked": { - "lastModified": 1740709839, - "narHash": "sha256-4dF++MXIXna/AwlZWDKr7bgUmY4xoEwvkF1GewjNrt0=", + "lastModified": 1752028888, + "narHash": "sha256-LRj3/PUpII6taWOrX1w/OeI6f1ncND02PP/kEHvPCqU=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "b4270835bf43c6f80285adac6f66a26d83f0f277", + "rev": "a0f1c656e053463b47639234b151a05e4441bb19", "type": "github" }, "original": { diff --git a/contrib/nix/flake.nix b/contrib/nix/flake.nix index a52bfe35fa..a5a06d1ebe 100644 --- a/contrib/nix/flake.nix +++ b/contrib/nix/flake.nix @@ -15,27 +15,15 @@ inputs.nixpkgs.follows = "nixpkgs"; }; - crane = { - url = "github:ipetkov/crane"; - }; + crane = { url = "github:ipetkov/crane"; }; }; - outputs = - { - nixpkgs, - flake-utils, - rust-overlay, - crane, - ... - }: - flake-utils.lib.eachDefaultSystem ( - system: + outputs = { nixpkgs, flake-utils, rust-overlay, crane, ... }: + flake-utils.lib.eachDefaultSystem (system: let overlays = [ (import rust-overlay) ]; - pkgs = import nixpkgs { - inherit system overlays; - }; + pkgs = import nixpkgs { inherit system overlays; }; inherit (pkgs) lib; @@ -51,26 +39,21 @@ commonArgs = { strictDeps = true; - buildInputs = - [ - # Add additional build inputs here - ] - ++ lib.optionals pkgs.stdenv.isDarwin [ - # Darwin specific inputs - pkgs.darwin.apple_sdk.frameworks.SystemConfiguration - ]; + buildInputs = [ + # Add additional build inputs here + ] ++ lib.optionals pkgs.stdenv.isDarwin [ + # Darwin specific inputs + pkgs.darwin.apple_sdk.frameworks.SystemConfiguration + ]; }; # Build *just* the cargo dependencies, so we can reuse # all of that work (e.g. via cachix) when running in CI - cargoArtifacts = craneLib.buildDepsOnly ( - commonArgs - // { - inherit version; - pname = name; - src = fileSetForCrate ../..; - } - ); + cargoArtifacts = craneLib.buildDepsOnly (commonArgs // { + inherit version; + pname = name; + src = fileSetForCrate ../..; + }); individualCrateArgs = commonArgs // { inherit cargoArtifacts; @@ -80,8 +63,7 @@ }; # TODO: Return minimum fileSets per each crate - fileSetForCrate = - crate: + fileSetForCrate = crate: lib.fileset.toSource { root = ../..; fileset = lib.fileset.unions [ @@ -111,36 +93,30 @@ (craneLib.fileset.commonCargoSources ../../stackslib) (craneLib.fileset.commonCargoSources ../../stx-genesis) (craneLib.fileset.commonCargoSources ../../testnet/stacks-node) + (craneLib.fileset.commonCargoSources + ../tools/config-docs-generator) ]; }; - stacks-signer = craneLib.buildPackage ( - individualCrateArgs - // rec { - version = versions.stacks_signer_version; - pname = "stacks-signer"; - cargoFeatures = "--features monitoring_prom"; - cargoExtraArgs = "${cargoFeatures} -p ${pname}"; - src = fileSetForCrate ../../stacks-signer; - } - ); + stacks-signer = craneLib.buildPackage (individualCrateArgs // rec { + version = versions.stacks_signer_version; + pname = "stacks-signer"; + cargoFeatures = "--features monitoring_prom"; + cargoExtraArgs = "${cargoFeatures} -p ${pname}"; + src = fileSetForCrate ../../stacks-signer; + }); # Build the actual crate itself, reusing the dependency # artifacts from above. - stacks-core = craneLib.buildPackage ( - commonArgs - // rec { - inherit version cargoArtifacts; - doCheck = false; - pname = name; - cargoFeatures = "--features monitoring_prom,slog_json"; - cargoExtraArgs = "${cargoFeatures}"; - src = fileSetForCrate ../..; - } - ); - in - with pkgs; - { + stacks-core = craneLib.buildPackage (commonArgs // rec { + inherit version cargoArtifacts; + doCheck = false; + pname = name; + cargoFeatures = "--features monitoring_prom,slog_json"; + cargoExtraArgs = "${cargoFeatures}"; + src = fileSetForCrate ../..; + }); + in with pkgs; { packages = { inherit stacks-signer; default = stacks-core; @@ -158,9 +134,7 @@ default = stacks-node; }; - checks = { - inherit stacks-core; - }; + checks = { inherit stacks-core; }; devShells.default = craneLib.devShell { RUSTFMT = "${toolchain}/bin/rustfmt"; @@ -174,16 +148,11 @@ set +x ''; - packages = - [ - rust-analyzer - bitcoind - ] + packages = [ rust-analyzer bitcoind ] ++ lib.optionals pkgs.stdenv.isDarwin [ pkgs.darwin.apple_sdk.frameworks.SystemConfiguration pkgs.darwin.apple_sdk.frameworks.CoreServices ]; }; - } - ); + }); } From 5fafb8f539e2a6ee4d736acf3c9931d379f5f078 Mon Sep 17 00:00:00 2001 From: Adriano Di Luzio Date: Thu, 10 Jul 2025 10:03:34 +0200 Subject: [PATCH 2/2] feat: Add CI action to build nix --- .github/workflows/nix-build.yml | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/nix-build.yml diff --git a/.github/workflows/nix-build.yml b/.github/workflows/nix-build.yml new file mode 100644 index 0000000000..be3fe7a781 --- /dev/null +++ b/.github/workflows/nix-build.yml @@ -0,0 +1,40 @@ +name: Build Nix + +on: + merge_group: + types: + - checks_requested + push: + branches: + - master + - develop + - next + paths-ignore: + - "**.md" + - "**.yml" + workflow_dispatch: + pull_request: + types: + - opened + - reopened + - synchronize + +concurrency: + group: ci-${{ github.head_ref || github.ref || github.run_id }} + ## Always cancel duplicate jobs + cancel-in-progress: true + +run-name: ${{ github.ref_name }} + +permissions: {} + +jobs: + build-pkg: + name: Build Nix package + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: DeterminateSystems/determinate-nix-action@d4b23d0b9eeeaeba3648c24d43bcb623dcf75336 # v3.7.0 + - uses: DeterminateSystems/magic-nix-cache-action@e1c1dae8e170ed20fd2e6aaf9979ca2d3905d636 # v12 + - run: nix build ./contrib/nix + - run: nix build ./contrib/nix#stacks-signer