ipetkov / crane

A Nix library for building cargo projects. Never build twice thanks to incremental artifact caching.
https://crane.dev
MIT License
961 stars 92 forks source link

Fix deeply nested registries #676

Closed szlend closed 4 months ago

szlend commented 4 months ago

Motivation

This allows building packages with crates from custom registries that reference other custom registries.

It works by scanning packages from Cargo.lock and adding any missing registries to crane's generated .cargo/config.toml. This matches Cargo's behavior where the top level project doesn't necessarily have to explicitly define all transitive registries.

Fixes #456

Checklist

szlend commented 4 months ago

Not sure what the best way would be to add a regression test. We already rely on alexandria for alt-registry tests, but we'd need another registry. In my reproduction example (https://github.com/szlend/crane-reg-test) I simply forked the alexandria index to have a second copy of the registry.

ipetkov commented 4 months ago

Is there anything you had to do to get cargo to mix and match the registries in the Cargo.lock file or did you manually edit one in to reproduce the issue?

ipetkov commented 4 months ago

Oh I see you published an actual crate to the upstream index

ipetkov commented 4 months ago

Not sure the best way to proceed tbh, seems like we'd need to push more versions of crane test crates to the alexandrie index to untangle but I'm not 100% sure if we want to have to rely on them that way. Perhaps at some point it may be worth looking into standing up a https://kellnr.io instance just for our own testing (maybe even an ephemeral one in a NixOS VM test?), but I definitely don't want to block on that. Happy to merge this as in and fix the issue and we can circle back if we ever have a regression