Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{lib, stdenv, fetchurl, zlib, ocaml, findlib}:
2
3let
4 common = {
5 patches = [];
6 postPatchInit = ''
7 cp META-zip META-camlzip
8 echo 'directory="../zip"' >> META-camlzip
9 '';
10 };
11 param =
12 if lib.versionAtLeast ocaml.version "4.07"
13 then common // {
14 version = "1.11";
15 url = "https://github.com/xavierleroy/camlzip/archive/rel111.tar.gz";
16 sha256 = "sha256-/7vF3j4cE9wOWScjdtIy0u3pGzJ1UQY9R/3bdPHV7Tc=";
17 } else if lib.versionAtLeast ocaml.version "4.02"
18 then common // {
19 version = "1.10";
20 url = "https://github.com/xavierleroy/camlzip/archive/rel110.tar.gz";
21 sha256 = "X0YcczaQ3lFeJEiTIgjSSZ1zi32KFMtmZsP0FFpyfbI=";
22 } else {
23 version = "1.05";
24 download_id = "1037";
25 url = "http://forge.ocamlcore.org/frs/download.php/${param.download_id}/camlzip-${param.version}.tar.gz";
26 sha256 = "930b70c736ab5a7ed1b05220102310a0a2241564786657abe418e834a538d06b";
27 patches = [./makefile_1_05.patch];
28 postPatchInit = ''
29 substitute ${./META} META --subst-var-by VERSION "${param.version}"
30 '';
31 };
32in
33
34stdenv.mkDerivation {
35 pname = "ocaml${ocaml.version}-camlzip";
36 version = param.version;
37
38 src = fetchurl {
39 inherit (param) url;
40 inherit (param) sha256;
41 };
42
43 nativeBuildInputs = [ ocaml findlib ];
44
45 propagatedBuildInputs = [zlib];
46
47 strictDeps = true;
48
49 inherit (param) patches;
50
51 createFindlibDestdir = true;
52
53 postPatch = param.postPatchInit + ''
54 substituteInPlace Makefile \
55 --subst-var-by ZLIB_LIBDIR "${zlib.out}/lib" \
56 --subst-var-by ZLIB_INCLUDE "${zlib.dev}/include"
57 '';
58
59 buildFlags = [ "all" "allopt" ];
60
61 postInstall = ''
62 ln -s $out/lib/ocaml/${ocaml.version}/site-lib/{,caml}zip
63 '';
64
65 meta = with lib; {
66 homepage = "http://cristal.inria.fr/~xleroy/software.html#camlzip";
67 description = "A library for handling ZIP and GZIP files in OCaml";
68 longDescription = ''
69 This Objective Caml library provides easy access to compressed files in
70 ZIP and GZIP format, as well as to Java JAR files. It provides functions
71 for reading from and writing to compressed files in these formats.
72 '';
73 license = "LGPL+linking exceptions";
74 inherit (ocaml.meta) platforms;
75 maintainers = with maintainers; [ maggesi ];
76 };
77}