generatedCargoNix: allow selected toolchain #390
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rust projects can use newer or custom toolchains that are not available in nixpkgs, even more so now that Rust Edition 2024 is upon us.
Attempting to generate
Cargo.nix
via IFD for a project with edition 2024 currently fails, no matter which version ofcargo
would be found on the$PATH
first.Logs from build failure
The reason for this is that
crate2nix
usespkgs.cargo
by default, andpkgs
is already bound to whatflake.nix
is locked to, which yields a Cargo 1.82 currently, which does not support edition 2024.This CAN be overridden as per this guide, which requires setting
cargo
in an overlay prior thereto.While functional, this approach is quite blunt, requiring a flake-wide override just to satisfy a tool that is not used to build the actual project.
My proposed solution is to simply pass a
cargo
argument togeneratedCargoNix
function. If it is omitted, then we fallback topkgs.cargo
, thereby retaining existing behavior.This is particularly handy in combination with rust-overlay, and likely fenix (I've only tested this change with the former).