diff --git a/pkgs/development/compilers/fstar/default.nix b/pkgs/development/compilers/fstar/default.nix new file mode 100644 index 000000000000..e6fe97c6fe8f --- /dev/null +++ b/pkgs/development/compilers/fstar/default.nix @@ -0,0 +1,78 @@ +{ stdenv, fetchFromGitHub, mono, fsharp, dotnetPackages, z3, ocamlPackages, openssl, makeWrapper }: + +stdenv.mkDerivation rec { + name = "fstar-${version}"; + version = "2016-01-12"; + + src = fetchFromGitHub { + owner = "FStarLang"; + repo = "FStar"; + rev = "af9a231566ca52c9bc3409398c801ae9e8191cfa"; + sha256 = "1zri4gqr6j6hygnh0ckfhq93mqwk9i19vng8chnmvlr27zq734a2"; + }; + + buildInputs = with ocamlPackages; [ + mono fsharp z3 dotnetPackages.FsLexYacc ocaml findlib ocaml_batteries openssl makeWrapper + ]; + + preBuild = '' + substituteInPlace src/Makefile --replace "\$(RUNTIME) VS/.nuget/NuGet.exe" "true" + + source setenv.sh + ''; + + 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 + ''; + + doCheck = true; + + 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 = '' + # Workaround for FStarLang/FStar#456 + mv $out/lib/fstar/* $out/lib/ + rmdir $out/lib/fstar + + 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; + platforms = with platforms; linux; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a14986b6b311..5e5be73ea745 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4180,6 +4180,10 @@ let fsharp = callPackage ../development/compilers/fsharp {}; + fstar = callPackage ../development/compilers/fstar { + ocamlPackages = ocamlPackages_4_02; + }; + dotnetPackages = recurseIntoAttrs (callPackage ./dotnet-packages.nix {}); go_1_4 = callPackage ../development/compilers/go/1.4.nix { diff --git a/pkgs/top-level/dotnet-packages.nix b/pkgs/top-level/dotnet-packages.nix index b66a37c69351..a1c54074622e 100644 --- a/pkgs/top-level/dotnet-packages.nix +++ b/pkgs/top-level/dotnet-packages.nix @@ -67,6 +67,13 @@ let self = dotnetPackages // overrides; dotnetPackages = with self; { outputFiles = [ "lib/net45/*" ]; }; + FsLexYacc = fetchNuGet { + baseName = "FsLexYacc"; + version = "6.1.0"; + sha256 = "1v5myn62zqs431i046gscqw2v0c969fc7pdplx7z9cnpy0p2s4rv"; + outputFiles = [ "build/*" ]; + }; + FsPickler = fetchNuGet { baseName = "FsPickler"; version = "1.2.9";