nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 ocaml,
6 writeText,
7}:
8
9stdenv.mkDerivation rec {
10 pname = "ocaml${ocaml.version}-camlidl";
11 version = "1.12";
12
13 src = fetchFromGitHub {
14 owner = "xavierleroy";
15 repo = "camlidl";
16 rev = "camlidl112";
17 hash = "sha256-ONPQMDFaU2OzFa5jgMVKx+ZRKk8ZgBZyk42vDvbM7E0=";
18 };
19
20 nativeBuildInputs = [ ocaml ];
21
22 # build fails otherwise
23 enableParallelBuilding = false;
24
25 preBuild = ''
26 mv config/Makefile.unix config/Makefile
27 substituteInPlace config/Makefile --replace BINDIR=/usr/local/bin BINDIR=$out
28 substituteInPlace config/Makefile --replace 'OCAMLLIB=$(shell $(OCAMLC) -where)' OCAMLLIB=$out/lib/ocaml/${ocaml.version}/site-lib/camlidl
29 substituteInPlace config/Makefile --replace CPP=cpp CPP=${stdenv.cc}/bin/cpp
30 substituteInPlace lib/Makefile --replace '$(OCAMLLIB)/Makefile.config' "${ocaml}/lib/ocaml/Makefile.config"
31 mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib/camlidl/caml
32 mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib/camlidl/stublibs
33 '';
34
35 postInstall = ''
36 cat >$out/lib/ocaml/${ocaml.version}/site-lib/camlidl/META <<EOF
37 # Courtesy of GODI
38 description = "Stub generator"
39 version = "${version}"
40 archive(byte) = "com.cma"
41 archive(native) = "com.cmxa"
42 EOF
43 mkdir -p $out/bin
44 ln -s $out/camlidl $out/bin
45 '';
46
47 setupHook = writeText "setupHook.sh" ''
48 export NIX_CFLAGS_COMPILE+=" -isystem $1/lib/ocaml/${ocaml.version}/site-lib/camlidl"
49 export NIX_LDFLAGS+=" -L $1/lib/ocaml/${ocaml.version}/site-lib/camlidl"
50 '';
51
52 meta = {
53 description = "Stub code generator and COM binding for Objective Caml";
54 mainProgram = "camlidl";
55 homepage = "https://xavierleroy.org/camlidl/";
56 license = lib.licenses.lgpl21;
57 maintainers = [ lib.maintainers.roconnor ];
58 broken = !(lib.versionAtLeast ocaml.version "4.03");
59 };
60}