summaryrefslogtreecommitdiffstats
path: root/pkgs/development/ocaml-modules/num/default.nix
blob: 7833b03b8f1aa472eaa22409e15f1aafe8724e49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{
  stdenv,
  lib,
  fetchFromGitHub,
  ocaml,
  findlib,
  withStatic ? false,
}:

stdenv.mkDerivation (
  rec {
    version = "1.6";
    pname = "ocaml${ocaml.version}-num";
    src = fetchFromGitHub {
      owner = "ocaml";
      repo = "num";
      tag = "v${version}";
      hash = "sha256-JWn0WBsbKpiUlxRDaXmwXVbL2WhqQIDrXiZk1aXeEtQ=";
    };

    patches = lib.optional withStatic ./enable-static.patch;

    postPatch = ''
      substituteInPlace num.opam --replace-fail '1.7~dev' "${version}"
      substituteInPlace src/Makefile --replace-fail "cp META.num META" "mv META.num META"
    '';

    nativeBuildInputs = [
      ocaml
      findlib
    ];

    strictDeps = true;

    createFindlibDestdir = true;

    installTargets = "findlib-install";

    meta = {
      description = "Legacy Num library for arbitrary-precision integer and rational arithmetic";
      license = lib.licenses.lgpl21;
      inherit (ocaml.meta) platforms;
      inherit (src.meta) homepage;
    };
  }
  // (lib.optionalAttrs (lib.versions.majorMinor ocaml.version == "4.06") {
    env.NIX_CFLAGS_COMPILE = "-fcommon";
  })
)