2023-02-02 18:25:31 +00:00
|
|
|
{ lib, stdenv, writeScript, fetchFromGitHub, z3, ocamlPackages, makeWrapper, installShellFiles, removeReferencesTo }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "fstar";
|
2023-02-09 11:40:11 +00:00
|
|
|
version = "2023.02.01";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "FStarLang";
|
|
|
|
repo = "FStar";
|
|
|
|
rev = "v${version}";
|
2023-02-09 11:40:11 +00:00
|
|
|
hash = "sha256-sLhbIGF7j1tH8zKsPq1qOSwHvYDrVCyfln9UbE3IYv0=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
strictDeps = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
nativeBuildInputs = [
|
2023-03-04 12:14:45 +00:00
|
|
|
z3
|
2022-03-05 16:20:37 +00:00
|
|
|
makeWrapper
|
|
|
|
installShellFiles
|
2023-02-02 18:25:31 +00:00
|
|
|
removeReferencesTo
|
2021-08-27 14:25:00 +00:00
|
|
|
] ++ (with ocamlPackages; [
|
|
|
|
ocaml
|
|
|
|
findlib
|
|
|
|
ocamlbuild
|
2022-03-05 16:20:37 +00:00
|
|
|
menhir
|
|
|
|
]);
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
buildInputs = with ocamlPackages; [
|
2021-08-27 14:25:00 +00:00
|
|
|
batteries
|
|
|
|
zarith
|
|
|
|
stdint
|
|
|
|
yojson
|
|
|
|
fileutils
|
|
|
|
menhirLib
|
|
|
|
pprint
|
2022-06-16 17:23:12 +00:00
|
|
|
sedlex
|
2021-08-27 14:25:00 +00:00
|
|
|
ppxlib
|
|
|
|
ppx_deriving
|
|
|
|
ppx_deriving_yojson
|
|
|
|
process
|
2023-03-04 12:14:45 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
makeFlags = [ "PREFIX=$(out)" ];
|
|
|
|
|
2021-10-06 13:57:05 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-08-27 14:25:00 +00:00
|
|
|
postPatch = ''
|
|
|
|
patchShebangs ulib/gen_mllib.sh
|
|
|
|
substituteInPlace src/ocaml-output/Makefile --replace '$(COMMIT)' 'v${version}'
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
preInstall = ''
|
|
|
|
mkdir -p $out/lib/ocaml/${ocamlPackages.ocaml.version}/site-lib/fstarlib
|
|
|
|
'';
|
|
|
|
postInstall = ''
|
2023-02-02 18:25:31 +00:00
|
|
|
# Remove build artifacts
|
|
|
|
find $out -name _build -type d | xargs -I{} rm -rf "{}"
|
|
|
|
remove-references-to -t '${ocamlPackages.ocaml}' $out/bin/fstar.exe
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
wrapProgram $out/bin/fstar.exe --prefix PATH ":" "${z3}/bin"
|
2020-05-03 17:38:23 +00:00
|
|
|
installShellCompletion --bash .completion/bash/fstar.exe.bash
|
|
|
|
installShellCompletion --fish .completion/fish/fstar.exe.fish
|
|
|
|
installShellCompletion --zsh --name _fstar.exe .completion/zsh/__fstar.exe
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-12-28 21:21:41 +00:00
|
|
|
passthru.updateScript = writeScript "update-fstar" ''
|
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -i bash -p git gnugrep common-updater-scripts
|
|
|
|
set -eu -o pipefail
|
|
|
|
|
|
|
|
version="$(git ls-remote --tags git@github.com:FStarLang/FStar.git | grep -Po 'v\K\d{4}\.\d{2}\.\d{2}' | sort | tail -n1)"
|
|
|
|
update-source-version fstar "$version"
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "ML-like functional programming language aimed at program verification";
|
|
|
|
homepage = "https://www.fstar-lang.org";
|
2021-09-18 10:52:07 +00:00
|
|
|
changelog = "https://github.com/FStarLang/FStar/raw/v${version}/CHANGES.md";
|
2022-05-18 14:49:53 +00:00
|
|
|
license = licenses.asl20;
|
2021-10-06 13:57:05 +00:00
|
|
|
maintainers = with maintainers; [ gebner pnmadelaine ];
|
2022-05-18 14:49:53 +00:00
|
|
|
mainProgram = "fstar.exe";
|
|
|
|
platforms = with platforms; darwin ++ linux;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|