Rust: Difference between revisions
→FAQ: from a rustup toolchain file |
→Custom Rust version: make cross compatible |
||
| Line 254: | Line 254: | ||
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 === | === Custom Rust version or targets === | ||
< | <syntaxhighlight lang="nix"> | ||
let | let | ||
rustVersion = "latest"; | rustVersion = "latest"; | ||
#rustVersion = "1.62.0"; | #rustVersion = "1.62.0"; | ||
rust = | rust_overlay = import ( | ||
builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz" | |||
); | |||
pkgs = import <nixpkgs> { | |||
overlays = [ | |||
rust_overlay | |||
(_: prev: { | |||
my-rust = prev.rust-bin.stable.${rustVersion}.default.override { | |||
extensions = [ | |||
"rust-src" # for rust-analyzer | |||
"rust-analyzer" | |||
]; | |||
#targets = [ "arm-unknown-linux-gnueabihf" ]; | |||
}; | |||
}) | |||
]; | ]; | ||
}; | }; | ||
in | in | ||
pkgs.mkShell { | pkgs.callPackage ( | ||
{ | |||
mkShell, | |||
hello, | |||
my-rust, | |||
pkg-config, | |||
# | openssl, | ||
}: | |||
mkShell { | |||
# host/target agnostic programs | |||
} | depsBuildBuild = [ | ||
</ | hello | ||
]; | |||
# compilers & linkers & dependecy finding programs | |||
nativeBuildInputs = [ | |||
my-rust | |||
pkg-config | |||
]; | |||
# libraries | |||
buildInputs = [ | |||
openssl | |||
]; | |||
RUST_BACKTRACE = 1; | |||
} | |||
) { } | |||
</syntaxhighlight> | |||
=== VSCode integration === | === VSCode integration === | ||