about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/ocaml-modules/ocamlformat/ocamlformat.nix
blob: 4c3b6607737d4c1d6dcc0a7239d8dfc5da96623f (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
# Version can be selected with the 'version' argument, see generic.nix.
{ lib
, callPackage
, buildDunePackage
, ocaml
, re
, ocamlformat-lib
, menhir
, ...
}@args:

let inherit (callPackage ./generic.nix args) src version library_deps;
in

lib.throwIf (lib.versionAtLeast ocaml.version "5.0" && !lib.versionAtLeast version "0.23")
  "ocamlformat ${version} is not available for OCaml ${ocaml.version}"

buildDunePackage {
  pname = "ocamlformat";
  inherit src version;

  minimalOCamlVersion = "4.08";

  nativeBuildInputs =
    if lib.versionAtLeast version "0.25.1" then [ ] else [ menhir ];

  buildInputs = [ re ] ++ library_deps
    ++ lib.optionals (lib.versionAtLeast version "0.25.1")
    [ (ocamlformat-lib.override { inherit version; }) ];

  meta = {
    homepage = "https://github.com/ocaml-ppx/ocamlformat";
    description = "Auto-formatter for OCaml code";
    maintainers = with lib.maintainers; [ Zimmi48 marsam Julow ];
    license = lib.licenses.mit;
    mainProgram = "ocamlformat";
  };
}