Rust: Difference between revisions

From NixOS Wiki
imported>Konfou
m Capitalization
imported>Samuela
No edit summary
Line 1: Line 1:
This article is about the [https://www.rust-lang.org Rust programming language].
This article is about the [https://www.rust-lang.org Rust programming language]. There are 3 methods to use the rust compiler and toolchain in Nix/NixOS: via nixpkgs, via rustup, or with unofficial overlays on nixpkgs. Installing via nixpkgs is the nix-iest way to use rust, but there are valid reasons to use any approach.
 
== Installing via nixpkgs ==
The <code>cargo</code> and <code>rustc</code> derivations provide the rust toolchain in nixpkgs.
 
=== VSCode integration ===
 
== Installation via rustup ==
The <code>rustup</code> tool is maintained by the rust community and offers and interface to install and switch between rust toolchains. In this scenario, <code>rustup</code> handles the "package management" of rust toolchains and places them in <code>$PATH</code>.
 
== Unofficial overlays ==


== Rust Nightlies ==
== Rust Nightlies ==

Revision as of 06:34, 19 February 2021

This article is about the Rust programming language. There are 3 methods to use the rust compiler and toolchain in Nix/NixOS: via nixpkgs, via rustup, or with unofficial overlays on nixpkgs. Installing via nixpkgs is the nix-iest way to use rust, but there are valid reasons to use any approach.

Installing via nixpkgs

The cargo and rustc derivations provide the rust toolchain in nixpkgs.

VSCode integration

Installation via rustup

The rustup tool is maintained by the rust community and offers and interface to install and switch between rust toolchains. In this scenario, rustup handles the "package management" of rust toolchains and places them in $PATH.

Unofficial overlays

Rust Nightlies

Either use Rust overlay or rustup to get install Rust nightlies.

Neovim Completion

Racer completion can be configured using the following snippet:

(neovim.override {
  configure = {
    customRC = ''
      if filereadable($HOME . "/.vimrc")
        source ~/.vimrc
      endif
      let $RUST_SRC_PATH = '${stdenv.mkDerivation {
        inherit (rustc) src;
        inherit (rustc.src) name;
        phases = ["unpackPhase" "installPhase"];
        installPhase = ''cp -r library $out'';
      }}'
    '';
    packages.nixbundle.start = with vimPlugins; [
      nvim-completion-manager
      nvim-cm-racer
    ];
  };
})