mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 19:21:04 +00:00
571c71e6f7
We are migrating packages that meet below requirements: 1. using `callPackage` 2. called path is a directory 3. overriding set is empty (`{ }`) 4. not containing path expressions other than relative path (to makenixpkgs-vet happy) 5. not referenced by nix files outside of the directory, other than`pkgs/top-level/all-packages.nix` 6. not referencing nix files outside of the directory 7. not referencing `default.nix` (since it's changed to `package.nix`) 8. `outPath` doesn't change after migration The tool is here: https://github.com/Aleksanaa/by-name-migrate.
43 lines
1.6 KiB
Diff
43 lines
1.6 KiB
Diff
diff --git a/src/elan-dist/src/component/package.rs b/src/elan-dist/src/component/package.rs
|
|
index c51e76d..ae8159e 100644
|
|
--- a/src/elan-dist/src/component/package.rs
|
|
+++ b/src/elan-dist/src/component/package.rs
|
|
@@ -56,6 +56,37 @@ fn unpack_without_first_dir<R: Read>(archive: &mut tar::Archive<R>, path: &Path)
|
|
entry
|
|
.unpack(&full_path)
|
|
.chain_err(|| ErrorKind::ExtractingPackage)?;
|
|
+ nix_patch_if_needed(&full_path)?;
|
|
+ }
|
|
+
|
|
+ Ok(())
|
|
+}
|
|
+
|
|
+fn nix_patch_if_needed(dest_path: &Path) -> Result<()> {
|
|
+ let is_bin = matches!(dest_path.parent(), Some(p) if p.ends_with("bin"));
|
|
+ if is_bin {
|
|
+ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
|
|
+ .arg("--set-interpreter")
|
|
+ .arg("@dynamicLinker@")
|
|
+ .arg(dest_path)
|
|
+ .output();
|
|
+ }
|
|
+
|
|
+ if dest_path.file_name() == Some(::std::ffi::OsStr::new("leanc")) {
|
|
+ use std::os::unix::fs::PermissionsExt;
|
|
+ let new_path = dest_path.with_extension("orig");
|
|
+ ::std::fs::rename(dest_path, &new_path)?;
|
|
+ ::std::fs::write(dest_path, r#"#! @shell@
|
|
+dir="$(dirname "${BASH_SOURCE[0]}")"
|
|
+# use bundled libraries, but not bundled compiler that doesn't know about NIX_LDFLAGS
|
|
+LEAN_CC="${LEAN_CC:-@cc@}" exec -a "$0" "$dir/leanc.orig" "$@" -L"$dir/../lib"
|
|
+"#)?;
|
|
+ ::std::fs::set_permissions(dest_path, ::std::fs::Permissions::from_mode(0o755))?;
|
|
+ }
|
|
+
|
|
+ if dest_path.file_name() == Some(::std::ffi::OsStr::new("llvm-ar")) {
|
|
+ ::std::fs::remove_file(dest_path)?;
|
|
+ ::std::os::unix::fs::symlink("@ar@", dest_path)?;
|
|
}
|
|
|
|
Ok(())
|