1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 ocaml,
6 findlib,
7 pkg-config,
8 gmp,
9 version ? if lib.versionAtLeast ocaml.version "4.08" then "1.14" else "1.13",
10}:
11
12if lib.versionOlder ocaml.version "4.04" then
13 throw "zarith is not available for OCaml ${ocaml.version}"
14else
15
16 stdenv.mkDerivation (finalAttrs: {
17 pname = "ocaml${ocaml.version}-zarith";
18 inherit version;
19 src = fetchFromGitHub {
20 owner = "ocaml";
21 repo = "Zarith";
22 rev = "release-${version}";
23 hash =
24 {
25 "1.13" = "sha256-CNVKoJeO3fsmWaV/dwnUA8lgI4ZlxR/LKCXpCXUrpSg=";
26 "1.14" = "sha256-xUrBDr+M8uW2KOy7DZieO/vDgsSOnyBnpOzQDlXJ0oE=";
27 }
28 ."${finalAttrs.version}";
29 };
30
31 nativeBuildInputs = [
32 pkg-config
33 ocaml
34 findlib
35 ];
36 propagatedBuildInputs = [ gmp ];
37 strictDeps = true;
38
39 dontAddPrefix = true;
40 dontAddStaticConfigureFlags = true;
41 configurePlatforms = [ ];
42 configureFlags = [ "-installdir ${placeholder "out"}/lib/ocaml/${ocaml.version}/site-lib" ];
43
44 preInstall = "mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib/stublibs";
45
46 meta = with lib; {
47 description = "Fast, arbitrary precision OCaml integers";
48 homepage = "https://github.com/ocaml/Zarith";
49 changelog = "https://github.com/ocaml/Zarith/raw/${finalAttrs.src.rev}/Changes";
50 license = licenses.lgpl2;
51 inherit (ocaml.meta) platforms;
52 maintainers = with maintainers; [
53 thoughtpolice
54 vbgl
55 ];
56 };
57 })