summary refs log tree commit diff
diff options
context:
space:
mode:
authorEli Flanagan <eli@typedspace.com>2021-11-02 16:30:03 -0400
committerRaphael Megzari <raphael@megzari.com>2021-11-05 00:17:56 +0900
commitb829fe48e36b326d8bcefda14475c2420a52e537 (patch)
treecdc07a5c1d3575f0f41daf43c93e0e78affe70b8
parent8650a7e6e1fdab6fcd3e4886bc6929677311f270 (diff)
downloadnixpkgs-b829fe48e36b326d8bcefda14475c2420a52e537.tar
nixpkgs-b829fe48e36b326d8bcefda14475c2420a52e537.tar.gz
nixpkgs-b829fe48e36b326d8bcefda14475c2420a52e537.tar.bz2
nixpkgs-b829fe48e36b326d8bcefda14475c2420a52e537.tar.lz
nixpkgs-b829fe48e36b326d8bcefda14475c2420a52e537.tar.xz
nixpkgs-b829fe48e36b326d8bcefda14475c2420a52e537.tar.zst
nixpkgs-b829fe48e36b326d8bcefda14475c2420a52e537.zip
add an example with buildRustPackage
-rw-r--r--doc/languages-frameworks/rust.section.md42
1 files changed, 42 insertions, 0 deletions
diff --git a/doc/languages-frameworks/rust.section.md b/doc/languages-frameworks/rust.section.md
index 1e155629c97..d1136346fcb 100644
--- a/doc/languages-frameworks/rust.section.md
+++ b/doc/languages-frameworks/rust.section.md
@@ -912,6 +912,48 @@ You can try this out by:
 
 As of writing, this prints out `rustc 1.56.0 (09c42c458 2021-10-18)`.
 
+### How to use an overlay toolchain in a derivation  {#how-to-use-an-overlay-toolchain-in-a-derivation}
+
+You can also use an overlay's Rust toolchain with `buildRustPackage`.
+The below snippet demonstrates invoking `buildRustPackage` with an oxalica overlay selected Rust toolchain:
+```nix
+with import <nixpkgs>
+{
+  overlays = [
+    (import (fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"))
+  ];
+};
+
+rustPlatform.buildRustPackage rec {
+  pname = "ripgrep";
+  version = "12.1.1";
+  nativeBuildInputs = [
+    rust-bin.stable.latest.minimal
+  ];
+
+  src = fetchFromGitHub {
+    owner = "BurntSushi";
+    repo = pname;
+    rev = version;
+    sha256 = "1hqps7l5qrjh9f914r5i6kmcz6f1yb951nv4lby0cjnp5l253kps";
+  };
+
+  cargoSha256 = "03wf9r2csi6jpa7v5sw5lpxkrk4wfzwmzx7k3991q3bdjzcwnnwp";
+
+  meta = with lib; {
+    description = "A fast line-oriented regex search tool, similar to ag and ack";
+    homepage = "https://github.com/BurntSushi/ripgrep";
+    license = licenses.unlicense;
+    maintainers = [ maintainers.tailhook ];
+  };
+}
+```
+
+Follow the below steps to try that snippet.
+1. create a new directory
+1. save the above snippet as `default.nix` in that directory
+1. cd into that directory and run `nix-build`
+
 ### Rust overlay installation {#rust-overlay-installation}
 
 You can use this overlay by either changing your local nixpkgs configuration,