1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 ocaml,
6 findlib,
7 withStatic ? false,
8}:
9
10stdenv.mkDerivation (
11 rec {
12 version = "1.6";
13 pname = "ocaml${ocaml.version}-num";
14 src = fetchFromGitHub {
15 owner = "ocaml";
16 repo = "num";
17 tag = "v${version}";
18 hash = "sha256-JWn0WBsbKpiUlxRDaXmwXVbL2WhqQIDrXiZk1aXeEtQ=";
19 };
20
21 patches = lib.optional withStatic ./enable-static.patch;
22
23 postPatch = ''
24 substituteInPlace num.opam --replace-fail '1.7~dev' "${version}"
25 substituteInPlace src/Makefile --replace-fail "cp META.num META" "mv META.num META"
26 '';
27
28 nativeBuildInputs = [
29 ocaml
30 findlib
31 ];
32
33 strictDeps = true;
34
35 createFindlibDestdir = true;
36
37 installTargets = "findlib-install";
38
39 meta = {
40 description = "Legacy Num library for arbitrary-precision integer and rational arithmetic";
41 license = lib.licenses.lgpl21;
42 inherit (ocaml.meta) platforms;
43 inherit (src.meta) homepage;
44 };
45 }
46 // (lib.optionalAttrs (lib.versions.majorMinor ocaml.version == "4.06") {
47 env.NIX_CFLAGS_COMPILE = "-fcommon";
48 })
49)