2021-12-06 16:07:01 +00:00
|
|
|
{ stdenv, lib, runCommand, patchelf, makeWrapper, pkg-config, curl, runtimeShell
|
|
|
|
, openssl, zlib, fetchFromGitHub, rustPlatform, libiconv }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "elan";
|
2021-12-06 16:07:01 +00:00
|
|
|
version = "1.3.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2021-05-03 20:48:10 +00:00
|
|
|
owner = "leanprover";
|
2020-04-24 23:36:52 +00:00
|
|
|
repo = "elan";
|
|
|
|
rev = "v${version}";
|
2021-12-06 16:07:01 +00:00
|
|
|
sha256 = "sha256-QNVzpnT77+9PXhq4Yz0q3o+GiQTVy7dOrg2yBTscoek=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
cargoSha256 = "sha256-G70QopoMqFrkOnuui3+3cEHYvmnf0meX1Ecv4q8FCpM=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-03-20 04:20:00 +00:00
|
|
|
nativeBuildInputs = [ pkg-config makeWrapper ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-03-20 04:20:00 +00:00
|
|
|
OPENSSL_NO_VENDOR = 1;
|
2021-05-20 23:08:51 +00:00
|
|
|
buildInputs = [ curl zlib openssl ]
|
|
|
|
++ lib.optional stdenv.isDarwin libiconv;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
buildFeatures = [ "no-self-update" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-03-20 04:20:00 +00:00
|
|
|
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;
|
2021-12-06 16:07:01 +00:00
|
|
|
shell = runtimeShell;
|
2021-03-20 04:20:00 +00:00
|
|
|
} ''
|
|
|
|
export dynamicLinker=$(cat $CC/nix-support/dynamic-linker)
|
|
|
|
substitute ${./0001-dynamically-patchelf-binaries.patch} $out \
|
|
|
|
--subst-var patchelf \
|
|
|
|
--subst-var dynamicLinker \
|
2021-12-06 16:07:01 +00:00
|
|
|
--subst-var shell
|
2021-03-20 04:20:00 +00:00
|
|
|
'')
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
postInstall = ''
|
|
|
|
pushd $out/bin
|
|
|
|
mv elan-init elan
|
2021-10-11 16:52:03 +00:00
|
|
|
for link in lean leanpkg leanchecker leanc leanmake lake; do
|
2020-04-24 23:36:52 +00:00
|
|
|
ln -s elan $link
|
|
|
|
done
|
|
|
|
popd
|
|
|
|
|
|
|
|
# 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; {
|
|
|
|
description = "Small tool to manage your installations of the Lean theorem prover";
|
2021-05-03 20:48:10 +00:00
|
|
|
homepage = "https://github.com/leanprover/elan";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = with licenses; [ asl20 /* or */ mit ];
|
|
|
|
maintainers = with maintainers; [ gebner ];
|
|
|
|
};
|
|
|
|
}
|