Rust: Difference between revisions
Phanirithvij (talk | contribs) m dream2nix update link |
→FAQ: from a rustup toolchain file |
||
| Line 292: | Line 292: | ||
== FAQ == | == FAQ == | ||
=== Rust from a rustup toolchain file === | |||
<syntaxhighlight lang="nix"> | |||
let | |||
rust-overlay = builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"; | |||
pkgs = import <nixpkgs> { | |||
overlays = [(import rust-overlay)]; | |||
}; | |||
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./toolchain.toml; | |||
in | |||
pkgs.mkShell { | |||
nativeBuildInputs = [ | |||
toolchain | |||
]; | |||
} | |||
</syntaxhighlight>From https://ayats.org/blog/nix-rustup and https://github.com/oxalica/rust-overlay?tab=readme-ov-file#cheat-sheet-common-usage-of-rust-bin | |||
=== Building Rust crates that require external system libraries === | === Building Rust crates that require external system libraries === | ||
For example, the <code>openssl-sys</code> crate needs the OpenSSL static libraries and searches for the library path with <code>pkg-config</code>. That's why you need to have the Nix derivatives <code>openssl</code> and <code>pkg-config</code> in order to build that crate. You'll need to start a shell providing these packages: | For example, the <code>openssl-sys</code> crate needs the OpenSSL static libraries and searches for the library path with <code>pkg-config</code>. That's why you need to have the Nix derivatives <code>openssl</code> and <code>pkg-config</code> in order to build that crate. You'll need to start a shell providing these packages: | ||