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": { diff --git a/contrib/nix/flake.nix b/contrib/nix/flake.nix index afd88e8a61..3e5ef883a4 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, @@ -48,7 +47,7 @@ version = versions.stacks_node_version; # Common arguments can be set here to avoid repeating them later - commonArgs = { + baseArgs = { strictDeps = true; buildInputs = @@ -59,6 +58,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 +98,8 @@ cargoArtifacts = craneLib.buildDepsOnly ( commonArgs // { - inherit version; pname = name; - src = fileSetForCrate ../..; + dummySrc = commonArgs.src; } ); @@ -85,8 +116,8 @@ lib.fileset.toSource { root = ../..; fileset = lib.fileset.unions [ - ../../Cargo.toml - ../../Cargo.lock + (craneLib.fileset.commonCargoSources ../..) + (craneLib.fileset.configToml ../..) # ../../versions.toml # @@ -126,6 +157,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 +185,7 @@ with pkgs; { packages = { - inherit stacks-signer; + inherit stacks-signer stacks-common; default = stacks-core; }; @@ -159,9 +201,7 @@ default = stacks-node; }; - checks = { - inherit stacks-core; - }; + checks = self.packages."${system}"; devShells.default = craneLib.devShell { RUSTFMT = "${toolchain}/bin/rustfmt";