2021-03-20 04:20:00 +00:00
|
|
|
{ stdenv, lib, runCommand, patchelf, makeWrapper, pkg-config, curl
|
2021-05-20 23:08:51 +00:00
|
|
|
, openssl, gmp, zlib, fetchFromGitHub, rustPlatform, libiconv }:
|
2021-03-20 04:20:00 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
libPath = lib.makeLibraryPath [ gmp ];
|
|
|
|
in
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "elan";
|
2021-08-18 13:19:15 +00:00
|
|
|
version = "1.0.7";
|
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-08-18 13:19:15 +00:00
|
|
|
sha256 = "sha256-SFY9RbUHoaOXCaK+uIqhnKbzSkbtWiS6os/JvsggagI=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-08-18 13:19:15 +00:00
|
|
|
cargoSha256 = "sha256-6TFionZw76V4htYQrz8eLX7ioW7Fbgd63rtz53s0TLU=";
|
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
|
|
|
|
|
|
|
cargoBuildFlags = [ "--features no-self-update" ];
|
|
|
|
|
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;
|
|
|
|
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
|
|
|
|
'')
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
postInstall = ''
|
|
|
|
pushd $out/bin
|
|
|
|
mv elan-init elan
|
2020-05-15 21:57:56 +00:00
|
|
|
for link in lean leanpkg leanchecker leanc leanmake; do
|
2020-04-24 23:36:52 +00:00
|
|
|
ln -s elan $link
|
|
|
|
done
|
|
|
|
popd
|
|
|
|
|
2021-03-20 04:20:00 +00:00
|
|
|
wrapProgram $out/bin/elan --prefix "LD_LIBRARY_PATH" : "${libPath}"
|
|
|
|
|
2020-04-24 23:36:52 +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; {
|
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
}
|