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 ] ++ extraBuildInputs;
52
53 nativeCheckInputs = [ cacert ];
54
55 meta = {
56 description = "Tool for searching and changing code structure";
57 mainProgram = "comby";
58 license = lib.licenses.asl20;
59 homepage = "https://comby.dev";
60 };
61 };
62
63 combyKernel = mkCombyPackage { pname = "comby-kernel"; };
64 combySemantic = mkCombyPackage {
65 pname = "comby-semantic";
66 extraBuildInputs = [ ocamlPackages.cohttp-lwt-unix ];
67 };
68in
69mkCombyPackage {
70 pname = "comby";
71
72 # tests have to be removed before building otherwise installPhase will fail
73 # cli tests expect a path to the built binary
74 preBuild = ''
75 substituteInPlace test/common/dune \
76 --replace "test_cli_list" "" \
77 --replace "test_cli_helper" "" \
78 --replace "test_cli" ""
79 rm test/common/{test_cli_list,test_cli_helper,test_cli}.ml
80 '';
81
82 extraBuildInputs =
83 [
84 zlib
85 gmp
86 libev
87 sqlite
88 ocamlPackages.shell # This input must appear before `parany` or any other input that propagates `ocamlnet`
89 ocamlPackages.lwt
90 ocamlPackages.patience_diff
91 ocamlPackages.toml
92 ocamlPackages.cohttp-lwt-unix
93 ocamlPackages.textutils
94 ocamlPackages.jst-config
95 ocamlPackages.parany
96 ocamlPackages.conduit-lwt-unix
97 ocamlPackages.lwt_react
98 ocamlPackages.tar-unix
99 ocamlPackages.tls
100 ocamlPackages.ppx_jane
101 ocamlPackages.ppx_expect
102 ocamlPackages.dune-configurator
103 combyKernel
104 combySemantic
105 ]
106 ++ (
107 if !stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64 then
108 [ ocamlPackages.hack_parallel ]
109 else
110 [ ]
111 );
112
113 extraNativeInputs = [
114 autoconf
115 pkg-config
116 ];
117
118}