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";
|
2022-09-14 18:05:37 +00:00
|
|
|
version = "1.4.2";
|
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}";
|
2022-09-14 18:05:37 +00:00
|
|
|
sha256 = "1aq06d66y622n0bbd57dx8s0ajz6cdv1vzaz25wvi4i62sg4x21x";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-09-14 18:05:37 +00:00
|
|
|
cargoSha256 = "sha256-RzeewQzsV5F5E0xwJF1MpzzQ8usyfQjzlDInOJqZdO8=";
|
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.
|
2021-12-21 02:18:32 +00:00
|
|
|
# This is necessary because Lean 4 is now dynamically linked.
|
2021-03-20 04:20:00 +00:00
|
|
|
(runCommand "0001-dynamically-patchelf-binaries.patch" {
|
|
|
|
CC = stdenv.cc;
|
2021-12-21 02:18:32 +00:00
|
|
|
cc = "${stdenv.cc}/bin/cc";
|
2022-09-09 14:08:57 +00:00
|
|
|
ar = "${stdenv.cc}/bin/ar";
|
2021-03-20 04:20:00 +00:00
|
|
|
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-21 02:18:32 +00:00
|
|
|
--subst-var cc \
|
2022-09-09 14:08:57 +00:00
|
|
|
--subst-var ar \
|
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 ];
|
|
|
|
};
|
|
|
|
}
|