about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/fstar/default.nix
blob: a8a7e2076c1c47425fb09f728a9bc17375253147 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
{ lib, stdenv, fetchFromGitHub, z3, ocamlPackages, makeWrapper, installShellFiles }:

let
  # FStar requires sedlex < 2.4
  # see https://github.com/FStarLang/FStar/issues/2343
  sedlex-2_3 = ocamlPackages.sedlex_2.overrideAttrs (_: rec {
    pname = "sedlex";
    version = "2.3";
    src = fetchFromGitHub {
       owner = "ocaml-community";
       repo = "sedlex";
       rev = "v${version}";
       sha256 = "WXUXUuIaBUrFPQOKtZ7dgDZYdpEVnoJck0dkrCi8g0c=";
    };
  });
in

stdenv.mkDerivation rec {
  pname = "fstar";
  version = "2021.09.30";

  src = fetchFromGitHub {
    owner = "FStarLang";
    repo = "FStar";
    rev = "v${version}";
    sha256 = "gqy9iaLZlTyv9ufHrUG87ta2xyc1OaZ/KRGhAzB+wsQ=";
  };

  nativeBuildInputs = [ makeWrapper installShellFiles ];

  buildInputs = [
    z3
    sedlex-2_3
  ] ++ (with ocamlPackages; [
    ocaml
    findlib
    ocamlbuild
    batteries
    zarith
    stdint
    yojson
    fileutils
    menhir
    menhirLib
    pprint
    ppxlib
    ppx_deriving
    ppx_deriving_yojson
    process
  ]);

  makeFlags = [ "PREFIX=$(out)" ];

  buildFlags = [ "libs" ];

  enableParallelBuilding = true;

  postPatch = ''
    patchShebangs ulib/gen_mllib.sh
    substituteInPlace src/ocaml-output/Makefile --replace '$(COMMIT)' 'v${version}'
  '';

  preInstall = ''
    mkdir -p $out/lib/ocaml/${ocamlPackages.ocaml.version}/site-lib/fstarlib
  '';
  postInstall = ''
    wrapProgram $out/bin/fstar.exe --prefix PATH ":" "${z3}/bin"
    installShellCompletion --bash .completion/bash/fstar.exe.bash
    installShellCompletion --fish .completion/fish/fstar.exe.fish
    installShellCompletion --zsh --name _fstar.exe .completion/zsh/__fstar.exe
  '';

  meta = with lib; {
    description = "ML-like functional programming language aimed at program verification";
    homepage = "https://www.fstar-lang.org";
    license = licenses.asl20;
    changelog = "https://github.com/FStarLang/FStar/raw/v${version}/CHANGES.md";
    platforms = with platforms; darwin ++ linux;
    maintainers = with maintainers; [ gebner pnmadelaine ];
  };
}