Closed benwis closed 1 year ago
Hi @benwis thanks for the detailed report and config!
The limitation here is (soon to be was!) that the standard library has its own Cargo.lock
file which specifies the crates it consumes, but the crates cannot be downloaded while running in the builder sandbox unless they are vendored ahead of time.
I've opened https://github.com/ipetkov/crane/pull/287 which should address this! It adds vendorMultipleCargoDeps
which allows specifying any number of Cargo.lock
files (or their read/parsed equivalents), including the Cargo.lock
file associated with the toolchain. Check out the added example for how to get things working once the PR lands!
Awesome!
Makes me feel better knowing I wasn't doing something dumb. Thanks for working on this and the example, looking forward to the PR!
------- Original Message ------- On Sunday, April 2nd, 2023 at 10:22 AM, Ivan Petkov @.***> wrote:
Hi @.***(https://github.com/benwis) thanks for the detailed report and config!
The limitation here is (soon to be was!) that the standard library has its own Cargo.lock file which specifies the crates it consumes, but the crates cannot be downloaded while running in the builder sandbox unless they are vendored ahead of time.
I've opened #287 which should address this! It adds vendorMultipleCargoDeps which allows specifying any number of Cargo.lock files (or their read/parsed equivalents), including the Cargo.lock file associated with the toolchain. Check out the added example for how to get things working once the PR lands!
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Closer, now I have a new error to chase down
nix build .
error: builder for '/nix/store/s688mf6mrkqyg6h1ycfmcaz8l444cc9y-vendor-registry.drv' failed with exit code 1;
last 1 log lines:
> ln: failed to create symbolic link '/nix/store/qkgigprai39h404v4qch5p549aawjafj-vendor-registry/adler-1.0.2/jgzk2hdvph1ljkpyrb1kvpzz35999s7j-cargo-package-adler-1.0.2': Permission denied
For full logs, run 'nix log /nix/store/s688mf6mrkqyg6h1ycfmcaz8l444cc9y-vendor-registry.drv'.
error: 1 dependencies of derivation '/nix/store/i169a57m8v30b1nj5gp3h0ak2ashzg1k-vendor-cargo-deps.drv' failed to build
error: 1 dependencies of derivation '/nix/store/p71n0sfnz38q4f65x7qwk9alm1z82ivp-benwis_leptos-0.1.0.drv' failed to build
@ipetkov It looks like adding any dependency, including to the example provided, causes it to fail with that error for me.
@benwis do you have a (ideally minimal) repro I can check out locally? Maybe there is something wrong with the package deduplication logic
@ipetkov Sure, here's the build-std example with the reqwest dep added to Cargo.toml. No other changes https://github.com/benwis/build-std-example-with-dep
Perfect, thanks for the repo!
As I suspected the dedup logic isn't actually deduplicating certain crates :thinking: Taking a closer look
nix show-derivation /nix/store/x5pc04h681al3s1b4nqwmx0s4d59fndl-vendor-registry | jq 'to_entries[0].value.env.buildCommand' -r | sort | uniq -c | rg -v '^\s+1'
2 ln -s '/nix/store/6xsxdzkaglm9jm909ks2z06yma7iclvx-cargo-package-indexmap-1.9.3' $out/'indexmap-1.9.3'
2 ln -s '/nix/store/88h5fhi5qxrc04xkw6h1wcjk70pdri96-cargo-package-wasi-0.11.0+wasi-snapshot-preview1' $out/'wasi-0.11.0+wasi-snapshot-preview1'
2 ln -s '/nix/store/gd8v69x2c4s6lnlhz0rny304rxz4cvkm-cargo-package-libc-0.2.140' $out/'libc-0.2.140'
2 ln -s '/nix/store/hfawbfg4wjaiflg3xksnaf6dcda1kjkz-cargo-package-hashbrown-0.12.3' $out/'hashbrown-0.12.3'
2 ln -s '/nix/store/hm24b0gcslpr9m8ni7m299zd0xmh26yy-cargo-package-cfg-if-1.0.0' $out/'cfg-if-1.0.0'
Thanks again for reporting the breakage, fix should be in #289!
I've got a web crate I'm trying to build with Crane, and it has been working great. But I was hoping to use the unstable feature build_std to compile the std crate, and chop off about 100kb in WASM size.
I'm having trouble getting it to work. If I try
cargo build --release --target=x86_64-linux-gnu
outside Nix in the dev shell it works fine, but if I try it inside Nix with Crane I getThis is my hacky flake.nix with Crane, any chance you might know how I can provide compiler_builtins or what I'm missing here. I realize this might be a bit outside your purview, but I've been stuck for quite a while. Thanks!
I have this in my cargo config, but as I said it works fine in the dev shell