diff options
author | Gabriel Ebner <gebner@gebner.org> | 2021-03-26 18:47:19 +0100 |
---|---|---|
committer | Gabriel Ebner <gebner@gebner.org> | 2021-03-26 19:16:33 +0100 |
commit | 0661cf48823bc0ec6aa8aecfef5debfb8b2d4dd4 (patch) | |
tree | 3ba520893d5d2a220c526b39b15ecf87759b2d4e /pkgs/applications | |
parent | 51f34b22f2a2805659fc959873e922e886c84cdc (diff) |
elan: 0.10.3 -> 0.11.0
Also adapt the patchelf patch from rustup, since Lean 4 now dynamically
links to gmp.
Diffstat (limited to 'pkgs/applications')
-rw-r--r-- | pkgs/applications/science/logic/elan/0001-dynamically-patchelf-binaries.patch | 40 | ||||
-rw-r--r-- | pkgs/applications/science/logic/elan/default.nix | 34 |
2 files changed, 69 insertions, 5 deletions
diff --git a/pkgs/applications/science/logic/elan/0001-dynamically-patchelf-binaries.patch b/pkgs/applications/science/logic/elan/0001-dynamically-patchelf-binaries.patch new file mode 100644 index 000000000000..b382e6f9e754 --- /dev/null +++ b/pkgs/applications/science/logic/elan/0001-dynamically-patchelf-binaries.patch @@ -0,0 +1,40 @@ +diff --git a/src/elan-dist/src/component/package.rs b/src/elan-dist/src/component/package.rs +index fd9fe74..0fefa39 100644 +--- a/src/elan-dist/src/component/package.rs ++++ b/src/elan-dist/src/component/package.rs +@@ -50,11 +50,35 @@ fn unpack_without_first_dir<R: Read>(archive: &mut tar::Archive<R>, path: &Path) + }; + + try!(entry.unpack(&full_path).chain_err(|| ErrorKind::ExtractingPackage)); ++ nix_patchelf_if_needed(&full_path); + } + + Ok(()) + } + ++fn nix_patchelf_if_needed(dest_path: &Path) { ++ let (is_bin, is_lib) = if let Some(p) = dest_path.parent() { ++ (p.ends_with("bin"), p.ends_with("lib")) ++ } else { ++ (false, false) ++ }; ++ ++ if is_bin { ++ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf") ++ .arg("--set-interpreter") ++ .arg("@dynamicLinker@") ++ .arg(dest_path) ++ .output(); ++ } ++ else if is_lib { ++ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf") ++ .arg("--set-rpath") ++ .arg("@libPath@") ++ .arg(dest_path) ++ .output(); ++ } ++} ++ + #[derive(Debug)] + pub struct ZipPackage<'a>(temp::Dir<'a>); + diff --git a/pkgs/applications/science/logic/elan/default.nix b/pkgs/applications/science/logic/elan/default.nix index bb10998b2f45..fab930e2c7b8 100644 --- a/pkgs/applications/science/logic/elan/default.nix +++ b/pkgs/applications/science/logic/elan/default.nix @@ -1,24 +1,46 @@ -{ lib, pkg-config, curl, openssl, zlib, fetchFromGitHub, rustPlatform }: +{ stdenv, lib, runCommand, patchelf, makeWrapper, pkg-config, curl +, openssl, gmp, zlib, fetchFromGitHub, rustPlatform }: + +let + libPath = lib.makeLibraryPath [ gmp ]; +in rustPlatform.buildRustPackage rec { pname = "elan"; - version = "0.10.3"; + version = "0.11.0"; src = fetchFromGitHub { owner = "kha"; repo = "elan"; rev = "v${version}"; - sha256 = "sha256-YkGfuqtvVfPcxJ8UqD5QidcNEy5brTWGEK4fR64Yz70="; + sha256 = "1sl69ygdwhf80sx6m76x5gp1kwsw0rr1lv814cgzm8hvyr6g0jqa"; }; - cargoSha256 = "sha256-2fYicpoEERwD4OjdpseKQOkDvZlb7NnOZcb6Tu+rQdA="; + cargoSha256 = "1f881maf8jizd5ip7pc1ncbiq7lpggp0byma13pvqk7gisnqyr4r"; - nativeBuildInputs = [ pkg-config ]; + nativeBuildInputs = [ pkg-config makeWrapper ]; + OPENSSL_NO_VENDOR = 1; buildInputs = [ curl zlib openssl ]; cargoBuildFlags = [ "--features no-self-update" ]; + patches = lib.optionals stdenv.isLinux [ + # Run patchelf on the downloaded binaries. + # This necessary because Lean 4 now dynamically links to GMP. + (runCommand "0001-dynamically-patchelf-binaries.patch" { + CC = stdenv.cc; + patchelf = patchelf; + libPath = "$ORIGIN/../lib:${libPath}"; + } '' + export dynamicLinker=$(cat $CC/nix-support/dynamic-linker) + substitute ${./0001-dynamically-patchelf-binaries.patch} $out \ + --subst-var patchelf \ + --subst-var dynamicLinker \ + --subst-var libPath + '') + ]; + postInstall = '' pushd $out/bin mv elan-init elan @@ -27,6 +49,8 @@ rustPlatform.buildRustPackage rec { done popd + wrapProgram $out/bin/elan --prefix "LD_LIBRARY_PATH" : "${libPath}" + # tries to create .elan export HOME=$(mktemp -d) mkdir -p "$out/share/"{bash-completion/completions,fish/vendor_completions.d,zsh/site-functions} |