From bc2d49c555520c53929251d81a677ee9c75c6871 Mon Sep 17 00:00:00 2001 From: Malik Date: Fri, 28 Mar 2025 11:25:48 +0100 Subject: [PATCH 1/5] Nix: provide stacks-common --- contrib/nix/flake.nix | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/contrib/nix/flake.nix b/contrib/nix/flake.nix index afd88e8a61..27db591bc7 100644 --- a/contrib/nix/flake.nix +++ b/contrib/nix/flake.nix @@ -126,6 +126,17 @@ } ); + stacks-common = craneLib.buildPackage ( + individualCrateArgs + // rec { + version = (builtins.fromTOML (builtins.readFile ../../stacks-common/Cargo.toml)).package.version; + pname = "stacks-common"; + cargoFeatures = "--features slog_json"; + cargoExtraArgs = "${cargoFeatures} -p ${pname}"; + src = fileSetForCrate ../../stacks-common; + } + ); + # Build the actual crate itself, reusing the dependency # artifacts from above. stacks-core = craneLib.buildPackage ( @@ -143,7 +154,7 @@ with pkgs; { packages = { - inherit stacks-signer; + inherit stacks-signer stacks-common; default = stacks-core; }; From 3fc2f994218de5bb08364abd515ada2470400fdf Mon Sep 17 00:00:00 2001 From: Malik Date: Wed, 2 Apr 2025 08:42:56 +0200 Subject: [PATCH 2/5] Apply suggestions from aldur https://github.com/stacks-network/stacks-core/pull/5973 --- contrib/nix/flake.nix | 44 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/contrib/nix/flake.nix b/contrib/nix/flake.nix index 27db591bc7..0f609982e9 100644 --- a/contrib/nix/flake.nix +++ b/contrib/nix/flake.nix @@ -48,7 +48,7 @@ version = versions.stacks_node_version; # Common arguments can be set here to avoid repeating them later - commonArgs = { + baseArgs = { strictDeps = true; buildInputs = @@ -59,6 +59,39 @@ # Darwin specific inputs pkgs.darwin.apple_sdk.frameworks.SystemConfiguration ]; + + src = fileSetForCrate ../..; + inherit version; + }; + + isClarityWASM = p: lib.hasPrefix "git+https://github.com/stacks-network/clarity-wasm.git" p.source; + + cargoVendorDir = craneLib.vendorCargoDeps ( + baseArgs + // { + # Use this function to override crates coming from git dependencies + overrideVendorGitCheckout = + ps: drv: + if lib.any (p: isClarityWASM p) ps then + drv.overrideAttrs (_old: { + patches = [ + (builtins.fetchurl { + url = "https://github.com/stacks-network/clarity-wasm/pull/627.patch"; + sha256 = "sha256:161mx1m21770lrsc2lfqlwzyydhy8f9bc7pmqb26rcki7s2ar31r"; + }) + ]; + }) + else + # Nothing to change, leave the derivations as is + drv; + + # Use this function to override crates coming from any registry checkout + overrideVendorCargoPackage = p: drv: drv; + } + ); + + commonArgs = baseArgs // { + inherit cargoVendorDir; }; # Build *just* the cargo dependencies, so we can reuse @@ -66,9 +99,8 @@ cargoArtifacts = craneLib.buildDepsOnly ( commonArgs // { - inherit version; pname = name; - src = fileSetForCrate ../..; + dummySrc = commonArgs.src; } ); @@ -85,8 +117,8 @@ lib.fileset.toSource { root = ../..; fileset = lib.fileset.unions [ - ../../Cargo.toml - ../../Cargo.lock + (craneLib.fileset.commonCargoSources ../..) + (craneLib.fileset.configToml ../..) # ../../versions.toml # @@ -154,7 +186,7 @@ with pkgs; { packages = { - inherit stacks-signer stacks-common; + inherit stacks-signer stacks-common cargoArtifacts stacks-core; default = stacks-core; }; From 8733349ca352b41ef63c10fd2c4d88e86f05800e Mon Sep 17 00:00:00 2001 From: Malik Date: Wed, 2 Apr 2025 10:20:47 +0200 Subject: [PATCH 3/5] Nix: checks: add all packages --- contrib/nix/flake.nix | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/contrib/nix/flake.nix b/contrib/nix/flake.nix index 0f609982e9..ad0ba8b1b2 100644 --- a/contrib/nix/flake.nix +++ b/contrib/nix/flake.nix @@ -18,11 +18,10 @@ crane = { url = "github:ipetkov/crane"; }; - }; outputs = - { + { self, nixpkgs, flake-utils, rust-overlay, @@ -202,9 +201,7 @@ default = stacks-node; }; - checks = { - inherit stacks-core; - }; + checks = self.packages."${system}"; devShells.default = craneLib.devShell { RUSTFMT = "${toolchain}/bin/rustfmt"; From 537dda68eb8313d81d295933a89752074afb09e7 Mon Sep 17 00:00:00 2001 From: Malik Date: Wed, 2 Apr 2025 11:57:59 +0200 Subject: [PATCH 4/5] Chore: Nix: bump flake.lock --- contrib/nix/flake.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/contrib/nix/flake.lock b/contrib/nix/flake.lock index 69951ab296..33075550d3 100644 --- a/contrib/nix/flake.lock +++ b/contrib/nix/flake.lock @@ -2,11 +2,11 @@ "nodes": { "crane": { "locked": { - "lastModified": 1739936662, - "narHash": "sha256-x4syUjNUuRblR07nDPeLDP7DpphaBVbUaSoeZkFbGSk=", + "lastModified": 1742394900, + "narHash": "sha256-vVOAp9ahvnU+fQoKd4SEXB2JG2wbENkpqcwlkIXgUC0=", "owner": "ipetkov", "repo": "crane", - "rev": "19de14aaeb869287647d9461cbd389187d8ecdb7", + "rev": "70947c1908108c0c551ddfd73d4f750ff2ea67cd", "type": "github" }, "original": { @@ -37,11 +37,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1740547748, - "narHash": "sha256-Ly2fBL1LscV+KyCqPRufUBuiw+zmWrlJzpWOWbahplg=", + "lastModified": 1743538100, + "narHash": "sha256-Bl/ynRPIb4CdtbEw3gfJYpKiHmRmrKltXc8zipqpO0o=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3a05eebede89661660945da1f151959900903b6a", + "rev": "b9d43b3fe5152d1dc5783a2ba865b2a03388b741", "type": "github" }, "original": { @@ -67,11 +67,11 @@ ] }, "locked": { - "lastModified": 1740709839, - "narHash": "sha256-4dF++MXIXna/AwlZWDKr7bgUmY4xoEwvkF1GewjNrt0=", + "lastModified": 1743561237, + "narHash": "sha256-dd97LXek202OWmUXvKYFdYWj0jHrn3p+L5Ojh1SEOqs=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "b4270835bf43c6f80285adac6f66a26d83f0f277", + "rev": "1de27ae43712a971c1da100dcd84386356f03ec7", "type": "github" }, "original": { From 55c98fe7b8ecd3795eeef6b260f97be7bb632ea1 Mon Sep 17 00:00:00 2001 From: Malik Date: Wed, 2 Apr 2025 12:01:15 +0200 Subject: [PATCH 5/5] Nix: less packages --- contrib/nix/flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/nix/flake.nix b/contrib/nix/flake.nix index ad0ba8b1b2..3e5ef883a4 100644 --- a/contrib/nix/flake.nix +++ b/contrib/nix/flake.nix @@ -185,7 +185,7 @@ with pkgs; { packages = { - inherit stacks-signer stacks-common cargoArtifacts stacks-core; + inherit stacks-signer stacks-common; default = stacks-core; };