oxalica / rust-overlay

Pure and reproducible nix overlay of binary distributed rust toolchains
MIT License
960 stars 57 forks source link

Maybe provide wrapper to strip out rustup commands #189

Open vringar opened 1 month ago

vringar commented 1 month ago

A project I'm contributing to unfortunately has all their scripts do things like

cargo +nightly fmt
cargo +nightly clippy

and while that's useful outside a nix managed environment it leads to me carrying a patchset just to be able to contribute.

Do you think a "fake rustup" that strips out and ignores these args before calling the real tools would be in scope for this project?

oxalica commented 1 month ago

I think it's a good idea but I'm not sure if we should do this by default. Ignoring the toolchain argument can be very surprising and can cause hidden incorrect behavior for scripts, when it's not clearly the user's intention.

vringar commented 1 month ago

Definitely shouldn't be the default! For rustup they note here and I think in some other blog post as well, that having high startup time in this proxy can significantly increase compilation time. I don't have a code base to measure this with, but does that mean the wrapper should also be written in Rust or do you think a shell script would do?

TheNeikos commented 1 month ago

I think that this could be done in a way to not break these scripts by generating this wrapper once, and using something simple like a bash case to switch between the versions.

I'd think something like:

rust-bin.generateWrapperFor stable-1-80 [nightly, stable-1-82, beta-1-75]

And it would generate a script with a case for each of those versions, and run the first argument if the first argument is not a +version?