mirror of
https://github.com/Noratrieb/nixos.git
synced 2026-03-15 00:36:05 +01:00
64 lines
1.9 KiB
Diff
64 lines
1.9 KiB
Diff
diff --git a/src/toolchains.rs b/src/toolchains.rs
|
|
index a4be8cd..95e9d16 100644
|
|
--- a/src/toolchains.rs
|
|
+++ b/src/toolchains.rs
|
|
@@ -19,6 +19,49 @@ use xz2::read::XzDecoder;
|
|
|
|
use crate::{Config, GitDate};
|
|
|
|
+fn nix_patchelf(mut toolchain_path: PathBuf) -> Result<(), io::Error> {
|
|
+ toolchain_path.push("bin");
|
|
+
|
|
+ for entry in toolchain_path.read_dir()? {
|
|
+ let entry = entry?;
|
|
+ if !entry.file_type()?.is_file() {
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ eprintln!(
|
|
+ "info: you seem to be running NixOS. Attempting to patch {}",
|
|
+ entry.path().to_str().unwrap()
|
|
+ );
|
|
+ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
|
|
+ .arg("--set-interpreter")
|
|
+ .arg("@dynamicLinker@")
|
|
+ .arg(entry.path())
|
|
+ .output();
|
|
+ }
|
|
+
|
|
+ toolchain_path.pop();
|
|
+ toolchain_path.push("lib");
|
|
+
|
|
+ for entry in toolchain_path.read_dir()? {
|
|
+ let entry = entry?;
|
|
+ if !entry.file_type()?.is_file() {
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ eprintln!(
|
|
+ "info: you seem to be running NixOS. Attempting to patch {}",
|
|
+ entry.path().to_str().unwrap()
|
|
+ );
|
|
+ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
|
|
+ .arg("--set-rpath")
|
|
+ .arg("@libPath@")
|
|
+ .arg(entry.path())
|
|
+ .output();
|
|
+ }
|
|
+
|
|
+ Ok(())
|
|
+}
|
|
+
|
|
pub const YYYY_MM_DD: &str = "%Y-%m-%d";
|
|
|
|
pub(crate) const NIGHTLY_SERVER: &str = "https://static.rust-lang.org/dist";
|
|
@@ -208,7 +251,8 @@ impl Toolchain {
|
|
})?;
|
|
}
|
|
|
|
- fs::rename(tmpdir.keep(), dest).map_err(InstallError::Move)
|
|
+ fs::rename(tmpdir.into_path(), &dest).map_err(InstallError::Move)?;
|
|
+ nix_patchelf(dest).map_err(InstallError::Move)
|
|
}
|
|
|
|
pub(crate) fn remove(&self, dl_params: &DownloadParams) -> io::Result<()> {
|