Jump to content

Rust: Difference between revisions

558 bytes added ,  15 April 2021
adds a example shell.nix file for rust development
imported>Srid
(Meta summary of nix + rust)
imported>Legendofmiracles
(adds a example shell.nix file for rust development)
Line 89: Line 89:
})
})
</syntaxHighlight>
</syntaxHighlight>
== shell.nix example ==
<syntaxHighlight lang="nix">
{ pkgs ? import <nixpkgs> {}  }:
pkgs.mkShell {
          nativeBuildInputs = with pkgs; [ rustc cargo gcc ];
          buildInputs = with pkgs; [ rustfmt clippy ];
          RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
}
</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, so that tools like rust-analyzer will work.


== FAQ ==
== FAQ ==