summaryrefslogtreecommitdiffstats
path: root/pkgs/development/ocaml-modules/vg/default.nix
blob: 508e4055200fa98255bc39303af03feefd879b49 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{
  stdenv,
  lib,
  fetchurl,
  ocaml,
  findlib,
  ocamlbuild,
  topkg,
  uchar,
  result,
  gg,
  otfm,
  brr,
  pdfBackend ? true, # depends on otfm
  htmlcBackend ? true, # depends on brr
}:

let
  inherit (lib) optionals versionOlder;
in
stdenv.mkDerivation (finalAttrs: {
  name = "ocaml${ocaml.version}-${finalAttrs.pname}-${finalAttrs.version}";
  pname = "vg";
  version = "0.9.5";

  src = fetchurl {
    url = "https://erratique.ch/software/vg/releases/vg-${finalAttrs.version}.tbz";
    hash = "sha256-qcTtvIfSUwzpUZDspL+54UTNvWY6u3BTvfGWF6c0Jvw=";
  };

  nativeBuildInputs = [
    ocaml
    findlib
    ocamlbuild
  ];
  buildInputs = [ topkg ];

  propagatedBuildInputs = [
    uchar
    result
    gg
  ]
  ++ optionals pdfBackend [
    otfm
  ]
  ++ optionals htmlcBackend [
    brr
  ];

  strictDeps = true;

  buildPhase =
    topkg.buildPhase
    + " --with-otfm ${lib.boolToString pdfBackend}"
    + " --with-brr ${lib.boolToString htmlcBackend}"
    + " --with-cairo2 false";

  inherit (topkg) installPhase;

  meta = {
    description = "Declarative 2D vector graphics for OCaml";
    longDescription = ''
      Vg is an OCaml module for declarative 2D vector graphics. In Vg, images
      are values that denote functions mapping points of the cartesian plane
      to colors. The module provides combinators to define and compose these
      values.

      Renderers for PDF, SVG and the HTML canvas are distributed with the
      module. An API allows to implement new renderers.
    '';
    homepage = "https://erratique.ch/software/vg";
    license = lib.licenses.isc;
    maintainers = [ lib.maintainers.jirkamarsik ];
    mainProgram = "vecho";
    inherit (ocaml.meta) platforms;
    broken = versionOlder ocaml.version "4.14";
  };
})