How to patch crate dependencies #714
Answered
by
eureka-cpu
eureka-cpu
asked this question in
Q&A
Replies: 2 comments 6 replies
-
I was reading this article: https://hadean.com/blog/managing-rust-dependencies-with-nix-part-i/ but I'm unsure if I want to go the route of packaging then injecting rust crates into the cargo dependency graph, and I'm not even sure if that's totally viable since I've never done it before. It would be super convenient if there way a way to just "patch" a dependency of the build. |
Beta Was this translation helpful? Give feedback.
6 replies
-
{
workspace = rec {
root = ./.;
src = craneLib.cleanCargoSource root;
canonicalizePath = crate: root + "/${crate}";
canonicalizePaths = crates: map (crate: canonicalizePath crate) crates;
};
# Check if the dependency requires the `risc0-circuit-recursion` as part of its build.
isRisc0CircuitRecursion = p: lib.hasPrefix
"git+https://github.com/anagrambuild/risc0?branch=v1.0.1-bonsai-fix#189829d0b84d57e8928a85aa4fac60dd6ce45ea9"
p.source;
cargoVendorDir = craneLib.vendorCargoDeps (workspace // {
overrideVendorGitCheckout = ps: drv:
if lib.any (p: (isRisc0CircuitRecursion p)) ps then
drv.overrideAttrs {
postPatch =
let
# see https://github.com/risc0/risc0/blob/v1.0.5/risc0/circuit/recursion/build.rs
sha256Hash = "4e8496469e1efa00efb3630d261abf345e6b2905fb64b4f3a297be88ebdf83d2";
recursionZkr = fetchurl {
name = "recursion_zkr.zip";
url = "https://risc0-artifacts.s3.us-west-2.amazonaws.com/zkr/${sha256Hash}.zip";
hash = "sha256-ToSWRp4e+gDvs2MNJhq/NF5rKQX7ZLTzope+iOvfg9I=";
};
in
''
ln -sf ${recursionZkr} ./risc0/circuit/recursion/src/recursion_zkr.zip
'';
}
else
drv;
});
# Common arguments can be set here to avoid repeating them later
commonArgs = {
inherit (workspace) src;
inherit cargoVendorDir;
# ...
};
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
eureka-cpu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a crate that's been giving me a bit of trouble:
risc0-circuit-recursion
. It seems to want to make some network calls to an aws s3 bucket, which is from a repo calledrisc0
. I've ran into this already before, while building their cargo extension plugincargo-risczero
and virtual machiner0vm
, and my code for packaging that works and is as follows:This is fine for
cargo-risczero
, but when I'm trying to build a package with crane from my workspace that relies on therisc0-circuit-recursion
dependency I'm getting this error since it's unable to fetch the.zip
file it needs in order to compile whatever it needs fromrisc0
.Is there a way to do the
postPatch
logic for the dependency so that it gets past the error?Beta Was this translation helpful? Give feedback.
All reactions