Skip to content

Commit 3fc2f99

Browse files
committed
Apply suggestions from aldur
#5973
1 parent bc2d49c commit 3fc2f99

File tree

1 file changed

+38
-6
lines changed

1 file changed

+38
-6
lines changed

contrib/nix/flake.nix

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
version = versions.stacks_node_version;
4949

5050
# Common arguments can be set here to avoid repeating them later
51-
commonArgs = {
51+
baseArgs = {
5252
strictDeps = true;
5353

5454
buildInputs =
@@ -59,16 +59,48 @@
5959
# Darwin specific inputs
6060
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
6161
];
62+
63+
src = fileSetForCrate ../..;
64+
inherit version;
65+
};
66+
67+
isClarityWASM = p: lib.hasPrefix "git+https://github.com/stacks-network/clarity-wasm.git" p.source;
68+
69+
cargoVendorDir = craneLib.vendorCargoDeps (
70+
baseArgs
71+
// {
72+
# Use this function to override crates coming from git dependencies
73+
overrideVendorGitCheckout =
74+
ps: drv:
75+
if lib.any (p: isClarityWASM p) ps then
76+
drv.overrideAttrs (_old: {
77+
patches = [
78+
(builtins.fetchurl {
79+
url = "https://github.com/stacks-network/clarity-wasm/pull/627.patch";
80+
sha256 = "sha256:161mx1m21770lrsc2lfqlwzyydhy8f9bc7pmqb26rcki7s2ar31r";
81+
})
82+
];
83+
})
84+
else
85+
# Nothing to change, leave the derivations as is
86+
drv;
87+
88+
# Use this function to override crates coming from any registry checkout
89+
overrideVendorCargoPackage = p: drv: drv;
90+
}
91+
);
92+
93+
commonArgs = baseArgs // {
94+
inherit cargoVendorDir;
6295
};
6396

6497
# Build *just* the cargo dependencies, so we can reuse
6598
# all of that work (e.g. via cachix) when running in CI
6699
cargoArtifacts = craneLib.buildDepsOnly (
67100
commonArgs
68101
// {
69-
inherit version;
70102
pname = name;
71-
src = fileSetForCrate ../..;
103+
dummySrc = commonArgs.src;
72104
}
73105
);
74106

@@ -85,8 +117,8 @@
85117
lib.fileset.toSource {
86118
root = ../..;
87119
fileset = lib.fileset.unions [
88-
../../Cargo.toml
89-
../../Cargo.lock
120+
(craneLib.fileset.commonCargoSources ../..)
121+
(craneLib.fileset.configToml ../..)
90122
#
91123
../../versions.toml
92124
#
@@ -154,7 +186,7 @@
154186
with pkgs;
155187
{
156188
packages = {
157-
inherit stacks-signer stacks-common;
189+
inherit stacks-signer stacks-common cargoArtifacts stacks-core;
158190
default = stacks-core;
159191
};
160192

0 commit comments

Comments
 (0)