nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1diff --git a/src/toolchains.rs b/src/toolchains.rs
2index 53a7ddb..795a711 100644
3--- a/src/toolchains.rs
4+++ b/src/toolchains.rs
5@@ -206,6 +206,8 @@ impl Toolchain {
6 })?;
7 }
8
9+ nix_patchelf(tmpdir.path().to_path_buf())
10+ .expect("failed to patch toolchain for NixOS");
11 fs::rename(tmpdir.into_path(), dest).map_err(InstallError::Move)
12 }
13
14@@ -533,3 +535,42 @@ fn download_tarball(
15 res => res,
16 }
17 }
18+
19+fn nix_patchelf(mut toolchain_path: PathBuf) -> io::Result<()> {
20+ toolchain_path.push("bin");
21+
22+ for entry in toolchain_path.read_dir()? {
23+ let entry = entry?;
24+ if !entry.file_type()?.is_file() {
25+ continue;
26+ }
27+
28+ eprintln!("info: you seem to be running NixOS. Attempting to patch {}",
29+ entry.path().to_str().unwrap());
30+ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
31+ .arg("--set-interpreter")
32+ .arg("@dynamicLinker@")
33+ .arg(entry.path())
34+ .output();
35+ }
36+
37+ toolchain_path.pop();
38+ toolchain_path.push("lib");
39+
40+ for entry in toolchain_path.read_dir()? {
41+ let entry = entry?;
42+ if !entry.file_type()?.is_file() {
43+ continue;
44+ }
45+
46+ eprintln!("info: you seem to be running NixOS. Attempting to patch {}",
47+ entry.path().to_str().unwrap());
48+ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
49+ .arg("--set-rpath")
50+ .arg("@libPath@")
51+ .arg(entry.path())
52+ .output();
53+ }
54+
55+ Ok(())
56+}