What Rust overlay do you use and why? advice appreciated

I have used 3 different overlays to manage my Rust toolchain using nix:

  1. mozilla’s
  2. oxalica’s

Today I learned about fenix
(see question in this thread too: (Fenix - Rust nightly toolchains and rust analyzer nightly for nix)

I prefer oxalica’s because it is faster and better documented than mozilla’s overlay.
I’m stumped about fenix though.

So I’m curious what overlay you use and why? Thanks!

6 Likes

There is pretty much no reason to use mozilla’s rust overlay any more

rust-overlay is bigger in size and includes all the manifests in the past
fenix requires sha256 for older toolchains and depends on ifd for things like fromToolchainFile, but is a lot smaller in size

I never did a benchmark, so I don’t know about speed
I’m also the author of fenix, so I’m probably biased

2 Likes

The wiki page has some info, but it could use updates/edits as this stuff is changing somewhat frequently…

1 Like

I’ve also been happily using oxalica’s overlay for about a year now.

I originally started using it because it allowed me to specify a custom set of components and targets without requiring the imperative rustup approach. It also makes it easy to track nightly with its automated nightly channel updates, which is sometimes necessary as I maintain quite a few libs.

I had not heard of fenix until coming across this post. I’d be curious to see a comparison between the two.

My only qualm with my current setup is that I have to use an external overlay at all. I’d love to be able to configure what components and targets I want available using some standard package inside nixpkgs. Perhaps there’s some rational behind leaving this kind of configuration to overlays, I haven’t done much investigation into the matter.

3 Likes

This. Using overlays for setting up language-specific dev environments kinda defeats the purpose of Nix. It’s like using PPAs or specific version managers (like nvm, rustup) in the sense that one has to research in reddit/forums to find out what is the “best” way of setting up stuff in $CURRENT_YEAR

1 Like

Well put. I share this reservation!

On my nixOS machine I used to install rustup and then use it to imperatively manage my Rust toolchain. I ran into linking problems and state discrepancies between configuration.nix and rustup’s installation. In asking arround, people recommended using the overlay.
https://discourse.nixos.org/t/do-rustup-installed-components-such-as-rls-supposed-to-be-usable-on-nixos is an example of a similar problem.
So for me I use overlays because it works and I haven’t been interesting in determining the root cause and resolution to first class Rust support.

But that begs the question: why do Nix users working on Rust projects resort to community overlays as opposed to a nixpkgs idiom for managing Rust toolchains?

I have because of usability and the nixpkg’s manual guidance.
It recommends installing cargo and rustc directly or using the Mozilla overlay :confused: .

2 Likes

We should probably update the manual to recommend oxalica/rust-overlay or nix-community/fenix over mozilla’s overlay

2 Likes

I don’t think I’ve ever used a rust overlay. I just have rustup in my configuration.nix, and it has been working perfectly for my use-case of NixOS on desktop. For rust-analyzer, I just cargo xtask install --jemalloc form my local clone of the repository.

1 Like

I started using fenix recently and I really like it. I am not sure if oxalica packages rust-analyzer nightlies but I went with fenix because they specifically advertise that they do, and I like to pull it into a shell for development so that I can be guaranteed to be using the same toolchain for the lsp as is used for the Nix build.

1 Like

FYI I opened a merge request to improve the documentation here:

Reading through that documentation I feel like the copy needs more updating to reflect usage with fenix.
I’ll attempt follow up PRs in the coming weeks to do that.

3 Likes