Skip to content
/ template-rust-nix Public template

A template project for rust development via nix.

Notifications You must be signed in to change notification settings

fatho/template-rust-nix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust-Nix Template

Repository template for a Rust project that pulls in the rust compiler (and cargo etc.) via nix. The shell.nix file provides an environment containing rustc and cargo, as well as the libstd source code for facilitating the use of rust-analyzer.

Rust-Analyzer itself is not provided via the nix environment, as the official Rust-Analyzer plugin for VS Code already takes care of downloading the latest version (and even patches the binary for NixOS).

Getting Started

Simply spawn a nix shell by running nix-shell in this directory. Inside that shell, rustc and some convenience tools are available. Instead of running nix-shell manually, direnv can improve usability. A suitable .envrc is included.

For use with VS Code it is important to start VS Code from within the nix-shell session by running code .. That way, it will capture the environment of the nix shell. Otherwise, it won't be able to find rustc and the libstd sources.

Updating Upstream

The nix dependencies are managed using niv. Niv is provided via the shell.nix environment. In order to get the latest snapshot, just run niv update inside the nix shell.

Custom Hotfixes

Currently, the master branch of mozilla/nixpkgs-mozilla seems to be broken in that it cannot build the rust-src derivation. Therefore, the nixpkgs-mozilla reference in nix/sources.json currently points to a fork of that repository with a hotfix applied that was taken from mozilla/nixpkgs-mozilla#304 (comment) and seems to fix the build.

About

A template project for rust development via nix.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published