summaryrefslogtreecommitdiffstats
path: root/pkgs/development/ocaml-modules/ocamlformat/generic.nix
blob: 12b27c5b180919ef4eb6e00d0ec6b8e893d89889 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
{
  lib,
  ocaml,
  fetchurl,
  version ? if lib.versionAtLeast ocaml.version "4.14" then "0.29.0" else "0.28.1",
  astring,
  base,
  camlp-streams,
  cmdliner_1_0,
  cmdliner_1,
  cmdliner,
  csexp,
  dune-build-info,
  either,
  fix,
  fpath,
  menhirLib,
  menhirSdk,
  ocaml-version,
  ocp-indent,
  odoc-parser,
  result,
  stdio,
  uuseg,
  uutf,
  ...
}:

# The ocamlformat package have been split into two in version 0.25.1:
# one for the library and one for the executable.
# Both have the same sources and very similar dependencies.

rec {
  tarballName = "ocamlformat-${version}.tbz";

  src = fetchurl {
    url = "https://github.com/ocaml-ppx/ocamlformat/releases/download/${version}/${tarballName}";
    sha256 =
      {
        "0.19.0" = "0ihgwl7d489g938m1jvgx8azdgq9f5np5mzqwwya797hx2m4dz32";
        "0.20.0" = "sha256-JtmNCgwjbCyUE4bWqdH5Nc2YSit+rekwS43DcviIfgk=";
        "0.20.1" = "sha256-fTpRZFQW+ngoc0T6A69reEUAZ6GmHkeQvxspd5zRAjU=";
        "0.21.0" = "sha256-KhgX9rxYH/DM6fCqloe4l7AnJuKrdXSe6Y1XY3BXMy0=";
        "0.22.4" = "sha256-61TeK4GsfMLmjYGn3ICzkagbc3/Po++Wnqkb2tbJwGA=";
        "0.23.0" = "sha256-m9Pjz7DaGy917M1GjyfqG5Lm5ne7YSlJF2SVcDHe3+0=";
        "0.24.0" = "sha256-Zil0wceeXmq2xy0OVLxa/Ujl4Dtsmc4COyv6Jo7rVaM=";
        "0.24.1" = "sha256-AjQl6YGPgOpQU3sjcaSnZsFJqZV9BYB+iKAE0tX0Qc4=";
        "0.25.1" = "sha256-3I8qMwyjkws2yssmI7s2Dti99uSorNKT29niJBpv0z0=";
        "0.26.0" = "sha256-AxSUq3cM7xCo9qocvrVmDkbDqmwM1FexEP7IWadeh30=";
        "0.26.1" = "sha256-2gBuQn8VuexhL7gI1EZZm9m3w+4lq+s9VVdHpw10xtc=";
        "0.26.2" = "sha256-Lk9Za/eqNnqET+g7oPawvxSyplF53cCCNj/peT0DdcU=";
        "0.27.0" = "sha256-3b9ITAdtCPmUAO6Et5DsIx9cj8vV0zJKZADVOI6EbRU=";
        "0.28.1" = "sha256-cL2gN9C+2WHtkb21GYsu7vVCREdQqLAV2AzLlLP/Qfs=";
        "0.29.0" = "sha256-2sd/CpV654K7S4abB7mAOocqNPjB6uiQG0LSG2I8nbU=";
      }
      ."${version}";
  };

  inherit version;

  odoc-parser_v = odoc-parser.override {
    version =
      if lib.versionAtLeast version "0.24.0" then
        "2.0.0"
      else if lib.versionAtLeast version "0.20.1" then
        "1.0.1"
      else
        "0.9.0";
  };

  cmdliner_v =
    if lib.versionAtLeast version "0.28.1" then
      cmdliner
    else if lib.versionAtLeast version "0.21.0" then
      cmdliner_1
    else
      cmdliner_1_0;

  library_deps = [
    base
    cmdliner_v
    dune-build-info
    fix
    fpath
    menhirLib
    menhirSdk
    ocp-indent
    stdio
    uuseg
    uutf
  ]
  ++ lib.optionals (lib.versionAtLeast version "0.20.0") [
    either
    ocaml-version
  ]
  ++ lib.optionals (lib.versionAtLeast version "0.22.4") [ csexp ]
  ++ (
    if lib.versionOlder version "0.25.1" then
      [ odoc-parser_v ]
    else
      [
        camlp-streams
        result
        astring
      ]
  );
}