Nightly Rust development with devenv | Paperless
Nix
Rust
development
Creating a Nix shell for Rust development is easy if you’re prepared to either<br>use only stable Rust or use Rustup to manage your Rust toolchain. But the<br>latest version of Bevy was not compatible with stable Rust at the time of<br>writing, and using Rustup would sacrifice one of the biggest advantages of Nix:<br>having reproducibility managed by a single component. I’m pretty happy with what<br>I ended up with, so here’s the gist of what you need.
Devenv setup
devenv.yaml needs nixpkgs and an overlay to install nightly Rust:
inputs:<br>nixpkgs:<br>url: github:NixOS/nixpkgs/nixpkgs-unstable<br>rust-overlay:<br>url: github:oxalica/rust-overlay<br>inputs:<br>nixpkgs:<br>follows: nixpkgs
devenv.nix needs to install and make libraries available for consumption<br>during the project build:
lib,<br>pkgs,<br>options,<br>...<br>}:<br>let<br>libraries = [<br># Omitted project specific packages<br>];<br>in<br>packages = [<br># Omitted project specific packages<br>++ libraries;
env.LD_LIBRARY_PATH = lib.makeLibraryPath libraries;
languages = {<br>nix.enable = true;<br>rust = {<br>enable = true;<br>channel = "nightly";<br>components = options.languages.rust.components.default ++ [<br>"rust-src" # For IDE integration; see below<br>];<br>};<br>};
enterTest = ''<br>cargo test<br>'';
IDE setup
(These instructions are for RustRover, but should be generally applicable.)
To ensure that RustRover uses the exact source and executables installed in the<br>devenv, you need to configure the following paths:
Toolchain location: PROJECT_DIR/.devenv/profile/bin
Standard library: PROJECT_DIR/.devenv/profile/lib/rustlib/src/rust/library
Comments? Feedback? Corrections? Send an email.
Version history
No webmentions were found.