Rust: Difference between revisions
Make everything more cross-compatible |
→Installation via rustup: use bindgenHook and remove now uneccesary attrs |
||
| Line 94: | Line 94: | ||
If you want the most "normal" Rust experience I recommend using rustup with the following example shell.nix: | If you want the most "normal" Rust experience I recommend using rustup with the following example shell.nix: | ||
< | <syntaxhighlight lang="nix"> | ||
{ pkgs ? import <nixpkgs> {} }: | { | ||
pkgs ? import <nixpkgs> { }, | |||
}: | |||
let | |||
overrides = (builtins.fromTOML (builtins.readFile ./rust-toolchain.toml)); | |||
in | in | ||
pkgs.callPackage ( | |||
{ | |||
stdenv, | |||
mkShell, | |||
rustup, | |||
rustPlatform, | |||
}: | |||
mkShell { | |||
nativeBuildInputs = [ | |||
rustup | rustup | ||
rustPlatform.bindgenHook | |||
]; | ]; | ||
# libraries here | |||
buildInputs = | |||
[ | |||
]; | |||
RUSTC_VERSION = overrides.toolchain.channel; | RUSTC_VERSION = overrides.toolchain.channel; | ||
# https://github.com/rust-lang/rust-bindgen#environment-variables | # https://github.com/rust-lang/rust-bindgen#environment-variables | ||
shellHook = '' | shellHook = '' | ||
export PATH= | export PATH="''${CARGO_HOME:-~/.cargo}/bin":"$PATH" | ||
export PATH= | export PATH="''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-${stdenv.hostPlatform.rust.rustcTarget}/bin":"$PATH" | ||
''; | |||
} | } | ||
</ | ) { } | ||
</syntaxhighlight> | |||
It's important to have a file named <code>rust-toolchain.toml</code> lying in the same directory as the shell.nix. | It's important to have a file named <code>rust-toolchain.toml</code> lying in the same directory as the shell.nix. | ||
| Line 147: | Line 138: | ||
# or nightly-20XX-XX-XX for a specific nightly. | # or nightly-20XX-XX-XX for a specific nightly. | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Cross-compiling == | == Cross-compiling == | ||