summary refs log tree commit diff
path: root/pkgs/development/tools/pyre/default.nix
blob: 7cbfc438504877fd7c9a20f03c6dfa2e6d226126 (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
{ stdenv, fetchFromGitHub, ocamlPackages, makeWrapper, writeScript }:
let
  # Manually set version - the setup script requires
  # hg and git + keeping the .git directory around.
  version = "0.0.8";
  versionFile = writeScript "version.ml" ''
    cat > "./version.ml" <<EOF
    let build_info () =
    "pyre-nixpkgs ${version}"
    let version () =
    "${version}"
    EOF
  '';
in stdenv.mkDerivation {
  name = "pyre-${version}";

  src = fetchFromGitHub {
    owner = "facebook";
    repo = "pyre-check";
    rev = "v${version}";
    sha256 = "0c4km27xnzsqcqvjqxmqak37x473z6azlbldy7f05ghkms7mchrw";
  };

  nativeBuildInputs = [ makeWrapper ];

  buildInputs = with ocamlPackages; [
    ocaml
    findlib
    menhir
    yojson
    core
    sedlex
    ppx_deriving_yojson
    ocamlbuild
    ppxlib
  ];

  buildPhase = ''
    # build requires HOME to be set
    export HOME=.

    # "external" because https://github.com/facebook/pyre-check/pull/8/files
    sed "s/%VERSION%/external ${version}/" Makefile.template > Makefile

    cp ${versionFile} ./scripts/generate-version-number.sh

    mkdir $(pwd)/build
    export OCAMLFIND_DESTDIR=$(pwd)/build
    export OCAMLPATH=$OCAMLPATH:$(pwd)/build
    make release
  '';

  checkPhase = ''
    make test
  '';

  # Note that we're not installing the typeshed yet.
  # Improvement for a future version.
  installPhase = ''
    mkdir -p $out/bin
    cp _build/all/main.native $out/bin/pyre
  '';

  meta = with stdenv.lib; {
    description = "A performant type-checker for Python 3";
    homepage = https://pyre-check.org;
    license = licenses.mit;
    platforms = with platforms; linux;
    maintainers = with maintainers; [ teh ];
  };
}