Jump to content

Rust: Difference between revisions

682 bytes added ,  15 October 2022
add shell.nix example: Custom Rust version
imported>Amjoseph-nixpkgs
No edit summary
imported>Milahu
(add shell.nix example: Custom Rust version)
Line 214: Line 214:
</syntaxHighlight>
</syntaxHighlight>
This will have the stable Rust compiler + the official formatter and linter inside the ephemeral shell. It'll also set the RUST_SRC_PATH environment variable to point to the right location, which tools, such as rust-analyzer, require to be set.
This will have the stable Rust compiler + the official formatter and linter inside the ephemeral shell. It'll also set the RUST_SRC_PATH environment variable to point to the right location, which tools, such as rust-analyzer, require to be set.
=== Custom Rust version ===
<syntaxHighlight lang="nix">
# based on https://discourse.nixos.org/t/how-can-i-set-up-my-rust-programming-environment/4501/9
let
  rust_overlay = import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz");
  pkgs = import <nixpkgs> { overlays = [ rust_overlay ]; };
  rustVersion = "latest";
  #rustVersion = "1.62";
  rust = pkgs.rust-bin.stable.${rustVersion}.default.override {
    extensions = [
      "rust-src" # for rust-analyzer
    ];
  };
in
pkgs.mkShell {
  buildInputs = [
    rust
  ] ++ (with pkgs; [
    # other dependencies
    #rust-analyzer
    #gtk3
    #wrapGAppsHook
  ]);
}
</syntaxHighlight>


=== VSCode integration ===
=== VSCode integration ===
Anonymous user