Rust: local documentation

I’m just getting started with Rust, and I’m on NixOS. I’m inclined to use nixpkgs (and overlays) to manage Rust compilers/toolchains, as opposed to using rustup for this purpose. However, rustup allows you to spin up a local copy of documentation by running:

rustup doc

If I don’t use rustup, is there another way I could spin up local documentation for the compiler/toolchain I’m using?

You can use oxalica’s overlay or fenix overlay to download the toolchains directly, without rustup.

For oxalica’s, I wrote a quite blog post about it:

With fenix, you can do this (with flakes)

nix build fenix#latest.rust-docs
firefox result/share/doc/rust/html/index.html

or if you want a one-liner that doesn’t leave a result symlink

firefox $(nix build fenix#latest.rust-docs --json --no-link | jq '.[0].outputs.out' -r)/share/doc/rust/html/index.html

(replace firefox with the browser you prefer or xdg-open)

1 Like