summaryrefslogtreecommitdiffstats
path: root/pkgs/development/ocaml-modules/odoc-parser/default.nix
blob: fb1554719b4724685a30eedc058dd5c3143db4aa (plain)
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
{
  lib,
  fetchurl,
  buildDunePackage,
  ocaml,
  astring,
  result,
  camlp-streams,
  version ? "3.2.1",
}:

let
  param =
    {
      "3.2.1" = {
        sha256 = "sha256-1F6xJVFIOf2awncCu0k40bTztpeOmxarlnPqBnJFr/w=";
      };
      "3.1.0" = {
        sha256 = "sha256-NVs8//STSQPLrti1HONeMz6GCZMtIwKUIAqfLUL/qRQ=";
      };
      "2.4.4" = {
        sha256 = "sha256-fiU6VbXI9hD54LSJQOza8hwBVTFDr5O0DJmMMEmeUfM=";
      };
      "2.0.0" = {
        sha256 = "sha256-QHkZ+7DrlXYdb8bsZ3dijZSqGQc0O9ymeLGIC6+zOSI=";
      };
      "1.0.1" = {
        sha256 = "sha256-orvo5CAbYOmAurAeluQfK6CwW6P1C0T3WDfoovuQfSw=";
      };
      "1.0.0" = {
        sha256 = "sha256-tqoI6nGp662bK+vE2h7aDXE882dObVfRBFnZNChueqE=";
        max_version = "5.0";
      };
      "0.9.0" = {
        sha256 = "sha256-3w2tG605v03mvmZsS2O5c71y66O3W+n3JjFxIbXwvXk=";
        max_version = "5.0";
      };
    }
    ."${version}";
in

lib.throwIf (param ? max_version && lib.versionAtLeast ocaml.version param.max_version)
  "odoc-parser ${version} is not available for OCaml ${ocaml.version}"

  buildDunePackage
  rec {
    pname = "odoc-parser";
    inherit version;

    src = fetchurl {
      url =
        if lib.versionAtLeast version "2.4" then
          "https://github.com/ocaml/odoc/releases/download/${version}/odoc-${version}.tbz"
        else
          "https://github.com/ocaml-doc/odoc-parser/releases/download/${version}/odoc-parser-${version}.tbz";
      inherit (param) sha256;
    };

    propagatedBuildInputs = [
      astring
    ]
    ++ lib.optional (!lib.versionAtLeast version "3.1.0") result
    ++ lib.optional (lib.versionAtLeast version "1.0.1") camlp-streams;

    meta = {
      description = "Parser for Ocaml documentation comments";
      license = lib.licenses.isc;
      maintainers = [ ];
      homepage = "https://github.com/ocaml-doc/odoc-parser";
      changelog = "https://github.com/ocaml-doc/odoc-parser/raw/${version}/CHANGES.md";
    };
  }