1 diff --git a/src/toolchains.rs b/src/toolchains.rs
2 index 53a7ddb..795a711 100644
3 --- a/src/toolchains.rs
4 +++ b/src/toolchains.rs
5 @@ -206,6 +206,8 @@ impl Toolchain {
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)
14 @@ -533,3 +535,42 @@ fn download_tarball(
19 +fn nix_patchelf(mut toolchain_path: PathBuf) -> io::Result<()> {
20 + toolchain_path.push("bin");
22 + for entry in toolchain_path.read_dir()? {
24 + if !entry.file_type()?.is_file() {
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@")
37 + toolchain_path.pop();
38 + toolchain_path.push("lib");
40 + for entry in toolchain_path.read_dir()? {
42 + if !entry.file_type()?.is_file() {
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")