nixpkgs/pkgs/applications/science/logic/elan/default.nix

70 lines
2.1 KiB
Nix
Raw Normal View History

{ stdenv, lib, runCommand, patchelf, makeWrapper, pkg-config, curl
2021-05-15 10:02:46 +00:00
, openssl, gmp, zlib, fetchFromGitHub, rustPlatform, libiconv }:
let
libPath = lib.makeLibraryPath [ gmp ];
in
2018-04-10 16:36:12 +00:00
rustPlatform.buildRustPackage rec {
2019-08-31 11:41:23 +00:00
pname = "elan";
2021-05-26 05:44:59 +00:00
version = "1.0.6";
2018-04-10 16:36:12 +00:00
src = fetchFromGitHub {
2021-04-22 08:54:42 +00:00
owner = "leanprover";
2018-04-10 16:36:12 +00:00
repo = "elan";
rev = "v${version}";
2021-05-26 05:44:59 +00:00
sha256 = "sha256-Ns8vSS/PDlfopigW4Nz3fdR9PCMG8gDoL36+/s0Qkeo=";
2018-04-10 16:36:12 +00:00
};
2021-05-26 05:44:59 +00:00
cargoSha256 = "sha256-NDtldiVo4SyE88f6ntKn1WJDFdvwN5Ps4DxQH15iNZE=";
nativeBuildInputs = [ pkg-config makeWrapper ];
2018-04-10 16:36:12 +00:00
OPENSSL_NO_VENDOR = 1;
2021-05-15 10:02:46 +00:00
buildInputs = [ curl zlib openssl ]
++ lib.optional stdenv.isDarwin libiconv;
2018-04-10 16:36:12 +00:00
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
'')
];
2018-04-10 16:36:12 +00:00
postInstall = ''
pushd $out/bin
mv elan-init elan
2020-05-07 13:35:13 +00:00
for link in lean leanpkg leanchecker leanc leanmake; do
2018-04-10 16:36:12 +00:00
ln -s elan $link
done
popd
wrapProgram $out/bin/elan --prefix "LD_LIBRARY_PATH" : "${libPath}"
2018-04-10 16:36:12 +00:00
# tries to create .elan
export HOME=$(mktemp -d)
mkdir -p "$out/share/"{bash-completion/completions,fish/vendor_completions.d,zsh/site-functions}
$out/bin/elan completions bash > "$out/share/bash-completion/completions/elan"
$out/bin/elan completions fish > "$out/share/fish/vendor_completions.d/elan.fish"
$out/bin/elan completions zsh > "$out/share/zsh/site-functions/_elan"
'';
meta = with lib; {
2018-04-10 16:36:12 +00:00
description = "Small tool to manage your installations of the Lean theorem prover";
2021-04-22 08:54:42 +00:00
homepage = "https://github.com/leanprover/elan";
2018-04-10 16:36:12 +00:00
license = with licenses; [ asl20 /* or */ mit ];
maintainers = with maintainers; [ gebner ];
};
}