nixpkgs/pkgs/development/compilers/fstar/default.nix

90 lines
2.7 KiB
Nix
Raw Normal View History

2017-05-10 10:33:16 +02:00
{ stdenv, fetchFromGitHub, mono, fsharp, dotnetPackages, z3, ocamlPackages, openssl, makeWrapper, pkgconfig, file }:
2016-01-19 01:44:21 +01:00
stdenv.mkDerivation rec {
name = "fstar-${version}";
2017-05-10 10:33:16 +02:00
version = "0.9.4.0";
2016-01-19 01:44:21 +01:00
src = fetchFromGitHub {
owner = "FStarLang";
repo = "FStar";
rev = "v${version}";
2017-05-10 10:33:16 +02:00
sha256 = "130779p5plsgvz0dkcqycns3vwrvyfl138nq2xdhd3rkdsbyyvb7";
2016-01-19 01:44:21 +01:00
};
nativeBuildInputs = [ makeWrapper ];
2016-01-19 01:44:21 +01:00
buildInputs = with ocamlPackages; [
2017-05-10 10:33:16 +02:00
mono fsharp z3 dotnetPackages.FsLexYacc ocaml findlib ocaml_batteries
zarith camlp4 yojson pprint openssl pkgconfig file
2016-01-19 01:44:21 +01:00
];
preBuild = ''
2017-05-30 19:08:47 +02:00
substituteInPlace src/Makefile --replace "\$(RUNTIME) VS/.nuget/NuGet.exe" "true" \
--replace Darwin xyz
2017-05-10 10:33:16 +02:00
substituteInPlace src/VS/.nuget/NuGet.targets --replace "mono" "true"
2016-01-19 01:44:21 +01:00
2017-05-10 10:33:16 +02:00
# Fails with bad interpreter otherwise
patchShebangs src/tools
patchShebangs bin
export FSharpTargetsPath="$(dirname $(pkg-config FSharp.Core --variable=Libraries))/Microsoft.FSharp.Targets"
# remove hardcoded windows paths
sed -i '/<FSharpTargetsPath/d' src/*/*.fsproj
mkdir -p src/VS/packages/FsLexYacc.6.1.0
ln -s ${dotnetPackages.FsLexYacc}/lib/dotnet/FsLexYacc src/VS/packages/FsLexYacc.6.1.0/build
2016-01-19 01:44:21 +01:00
'';
makeFlags = [
"FSYACC=${dotnetPackages.FsLexYacc}/bin/fsyacc"
"FSLEX=${dotnetPackages.FsLexYacc}/bin/fslex"
"NUGET=true"
"PREFIX=$(out)"
];
buildFlags = "-C src";
# Now that the .NET fstar.exe is built, use it to build the native OCaml binary
postBuild = ''
patchShebangs bin/fstar.exe
# Workaround for fsharp/fsharp#419
cp ${fsharp}/lib/mono/4.5/FSharp.Core.dll bin/
# Use the built .NET binary to extract the sources of itself from F* to OCaml
make ''${enableParallelBuilding:+-j''${NIX_BUILD_CORES} -l''${NIX_BUILD_CORES}} \
$makeFlags "''${makeFlagsArray[@]}" \
ocaml -C src
# Build the extracted OCaml sources
make ''${enableParallelBuilding:+-j''${NIX_BUILD_CORES} -l''${NIX_BUILD_CORES}} \
$makeFlags "''${makeFlagsArray[@]}" \
-C src/ocaml-output
'';
# https://github.com/FStarLang/FStar/issues/676
doCheck = false;
2016-01-19 01:44:21 +01:00
preCheck = "ulimit -s unlimited";
# Basic test suite:
#checkFlags = "VERBOSE=y -C examples";
# Complete, but heavyweight test suite:
checkTarget = "regressions";
checkFlags = "VERBOSE=y -C src";
installFlags = "-C src/ocaml-output";
postInstall = ''
wrapProgram $out/bin/fstar.exe --prefix PATH ":" "${z3}/bin"
'';
meta = with stdenv.lib; {
description = "ML-like functional programming language aimed at program verification";
homepage = "https://www.fstar-lang.org";
license = licenses.asl20;
2016-06-30 17:57:32 +02:00
platforms = with platforms; darwin ++ linux;
2016-01-19 01:44:21 +01:00
};
}