nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1diff --git a/src/dist/component/package.rs b/src/dist/component/package.rs
2index 4b432785..fa45e87e 100644
3--- a/src/dist/component/package.rs
4+++ b/src/dist/component/package.rs
5@@ -109,10 +109,11 @@ impl Package for DirectoryPackage {
6 match &*part.0 {
7 "file" => {
8 if self.copy {
9- builder.copy_file(path.clone(), &src_path)?
10+ builder.copy_file(path.clone(), &src_path)?;
11 } else {
12- builder.move_file(path.clone(), &src_path)?
13+ builder.move_file(path.clone(), &src_path)?;
14 }
15+ nix_patchelf_if_needed(&target.prefix().path().join(path.clone()), &src_path)
16 }
17 "dir" => {
18 if self.copy {
19@@ -135,6 +136,22 @@ impl Package for DirectoryPackage {
20 }
21 }
22
23+fn nix_patchelf_if_needed(dest_path: &Path, src_path: &Path) {
24+ let is_bin = if let Some(p) = src_path.parent() {
25+ p.ends_with("bin")
26+ } else {
27+ false
28+ };
29+
30+ if is_bin {
31+ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
32+ .arg("--set-interpreter")
33+ .arg("@dynamicLinker@")
34+ .arg(dest_path)
35+ .output();
36+ }
37+}
38+
39 #[derive(Debug)]
40 pub struct TarPackage<'a>(DirectoryPackage, temp::Dir<'a>);
41