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 useDune2 = true;
19 minimumOcamlVersion = "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 = [
32 ocamlPackages.ppx_deriving
33 ocamlPackages.ppx_deriving_yojson
34 ocamlPackages.ppx_sexp_conv
35 ocamlPackages.ppx_sexp_message
36 ] ++ extraNativeInputs;
37
38 buildInputs = [
39 ocamlPackages.core
40 ocamlPackages.core_kernel
41 ocamlPackages.ocaml_pcre
42 ocamlPackages.mparser
43 ocamlPackages.mparser-pcre
44 ocamlPackages.angstrom
45 ] ++ extraBuildInputs;
46
47 checkInputs = [ cacert ];
48
49 meta = {
50 description = "Tool for searching and changing code structure";
51 license = lib.licenses.asl20;
52 homepage = "https://comby.dev";
53 };
54 };
55
56 combyKernel = mkCombyPackage { pname = "comby-kernel"; };
57 combySemantic = mkCombyPackage { pname = "comby-semantic"; extraBuildInputs = [ ocamlPackages.cohttp-lwt-unix ]; };
58in
59mkCombyPackage {
60 pname = "comby";
61
62 # tests have to be removed before building otherwise installPhase will fail
63 # cli tests expect a path to the built binary
64 preBuild = ''
65 substituteInPlace test/common/dune \
66 --replace "test_cli_list" "" \
67 --replace "test_cli_helper" "" \
68 --replace "test_cli" ""
69 rm test/common/{test_cli_list,test_cli_helper,test_cli}.ml
70 '';
71
72 extraBuildInputs = [
73 zlib
74 gmp
75 libev
76 sqlite
77 ocamlPackages.shell # This input must appear before `parany` or any other input that propagates `ocamlnet`
78 ocamlPackages.lwt
79 ocamlPackages.patience_diff
80 ocamlPackages.toml
81 ocamlPackages.cohttp-lwt-unix
82 ocamlPackages.opium
83 ocamlPackages.textutils
84 ocamlPackages.jst-config
85 ocamlPackages.parany
86 ocamlPackages.conduit-lwt-unix
87 ocamlPackages.lwt_react
88 ocamlPackages.tar-unix
89 ocamlPackages.tls
90 combyKernel
91 combySemantic
92 ] ++ (if !stdenv.isAarch32 && !stdenv.isAarch64 then
93 [ ocamlPackages.hack_parallel ]
94 else
95 [ ]);
96
97 extraNativeInputs = [
98 autoconf
99 pkg-config
100 ocamlPackages.ppx_jane
101 ocamlPackages.ppx_expect
102 ocamlPackages.dune-configurator
103 ];
104
105}