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