1 { lib, stdenv, fetchFromGitHub, ocaml, writeText }:
3 lib.throwIfNot (lib.versionAtLeast ocaml.version "4.03")
4 "camlidl is not available for OCaml ${ocaml.version}"
6 stdenv.mkDerivation rec {
7 pname = "ocaml${ocaml.version}-camlidl";
10 src = fetchFromGitHub {
11 owner = "xavierleroy";
14 hash = "sha256-ONPQMDFaU2OzFa5jgMVKx+ZRKk8ZgBZyk42vDvbM7E0=";
17 nativeBuildInputs = [ ocaml ];
19 # build fails otherwise
20 enableParallelBuilding = false;
23 mv config/Makefile.unix config/Makefile
24 substituteInPlace config/Makefile --replace BINDIR=/usr/local/bin BINDIR=$out
25 substituteInPlace config/Makefile --replace 'OCAMLLIB=$(shell $(OCAMLC) -where)' OCAMLLIB=$out/lib/ocaml/${ocaml.version}/site-lib/camlidl
26 substituteInPlace config/Makefile --replace CPP=cpp CPP=${stdenv.cc}/bin/cpp
27 substituteInPlace lib/Makefile --replace '$(OCAMLLIB)/Makefile.config' "${ocaml}/lib/ocaml/Makefile.config"
28 mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib/camlidl/caml
29 mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib/camlidl/stublibs
33 cat >$out/lib/ocaml/${ocaml.version}/site-lib/camlidl/META <<EOF
35 description = "Stub generator"
36 version = "${version}"
37 archive(byte) = "com.cma"
38 archive(native) = "com.cmxa"
41 ln -s $out/camlidl $out/bin
44 setupHook = writeText "setupHook.sh" ''
45 export NIX_CFLAGS_COMPILE+=" -isystem $1/lib/ocaml/${ocaml.version}/site-lib/camlidl"
46 export NIX_LDFLAGS+=" -L $1/lib/ocaml/${ocaml.version}/site-lib/camlidl"
50 description = "A stub code generator and COM binding for Objective Caml";
51 mainProgram = "camlidl";
52 homepage = "https://xavierleroy.org/camlidl/";
53 license = lib.licenses.lgpl21;
54 maintainers = [ lib.maintainers.roconnor ];