Skip to content

fix: nix build and CI #6274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/nix-build.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 9 additions & 9 deletions contrib/nix/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

105 changes: 37 additions & 68 deletions contrib/nix/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -80,8 +63,7 @@
};

# TODO: Return minimum fileSets per each crate
fileSetForCrate =
crate:
fileSetForCrate = crate:
lib.fileset.toSource {
root = ../..;
fileset = lib.fileset.unions [
Expand Down Expand Up @@ -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;
Expand All @@ -158,9 +134,7 @@
default = stacks-node;
};

checks = {
inherit stacks-core;
};
checks = { inherit stacks-core; };

devShells.default = craneLib.devShell {
RUSTFMT = "${toolchain}/bin/rustfmt";
Expand All @@ -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
];
};
}
);
});
}
Loading