1{
2 ocamlPackages,
3 fetchFromGitHub,
4 lib,
5 zlib,
6 pkg-config,
7 cacert,
8 gmp,
9 libev,
10 autoconf,
11 sqlite,
12 stdenv,
13}:
14let
15 mkCombyPackage =
16 {
17 pname,
18 extraBuildInputs ? [ ],
19 extraNativeInputs ? [ ],
20 preBuild ? "",
21 }:
22 ocamlPackages.buildDunePackage rec {
23 inherit pname preBuild;
24 version = "1.8.1";
25 duneVersion = "3";
26 minimalOCamlVersion = "4.08.1";
27 doCheck = true;
28
29 src = fetchFromGitHub {
30 owner = "comby-tools";
31 repo = "comby";
32 rev = version;
33 sha256 = "sha256-yQrfSzJgJm0OWJxhxst2XjZULIVHeEfPMvMIwH7BYDc=";
34 };
35
36 patches = [ ./comby.patch ];
37
38 nativeBuildInputs = extraNativeInputs;
39
40 buildInputs = [
41 ocamlPackages.core
42 ocamlPackages.core_kernel
43 ocamlPackages.ocaml_pcre
44 ocamlPackages.mparser
45 ocamlPackages.mparser-pcre
46 ocamlPackages.angstrom
47 ocamlPackages.ppx_deriving
48 ocamlPackages.ppx_deriving_yojson
49 ocamlPackages.ppx_sexp_conv
50 ocamlPackages.ppx_sexp_message
51 ]
52 ++ extraBuildInputs;
53
54 nativeCheckInputs = [ cacert ];
55
56 meta = {
57 description = "Tool for searching and changing code structure";
58 mainProgram = "comby";
59 license = lib.licenses.asl20;
60 homepage = "https://comby.dev";
61 broken = true; # Not compatible with ocamlPackages.tar ≥ 3
62 };
63 };
64
65 combyKernel = mkCombyPackage { pname = "comby-kernel"; };
66 combySemantic = mkCombyPackage {
67 pname = "comby-semantic";
68 extraBuildInputs = [ ocamlPackages.cohttp-lwt-unix ];
69 };
70in
71mkCombyPackage {
72 pname = "comby";
73
74 # tests have to be removed before building otherwise installPhase will fail
75 # cli tests expect a path to the built binary
76 preBuild = ''
77 substituteInPlace test/common/dune \
78 --replace "test_cli_list" "" \
79 --replace "test_cli_helper" "" \
80 --replace "test_cli" ""
81 rm test/common/{test_cli_list,test_cli_helper,test_cli}.ml
82 '';
83
84 extraBuildInputs = [
85 zlib
86 gmp
87 libev
88 sqlite
89 ocamlPackages.shell # This input must appear before `parany` or any other input that propagates `ocamlnet`
90 ocamlPackages.lwt
91 ocamlPackages.patience_diff
92 ocamlPackages.toml
93 ocamlPackages.cohttp-lwt-unix
94 ocamlPackages.textutils
95 ocamlPackages.jst-config
96 ocamlPackages.parany
97 ocamlPackages.conduit-lwt-unix
98 ocamlPackages.lwt_react
99 ocamlPackages.tar-unix
100 ocamlPackages.tls
101 ocamlPackages.ppx_jane
102 ocamlPackages.ppx_expect
103 ocamlPackages.dune-configurator
104 combyKernel
105 combySemantic
106 ]
107 ++ (
108 if !stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64 then
109 [ ocamlPackages.hack_parallel ]
110 else
111 [ ]
112 );
113
114 extraNativeInputs = [
115 autoconf
116 pkg-config
117 ];
118
119}