1{ stdenv, lib, fetchurl, ocaml, findlib, ocamlbuild, topkg
2, uchar, result, gg, uutf, otfm
3, js_of_ocaml, js_of_ocaml-ppx,
4 pdfBackend ? true, # depends on uutf and otfm
5 htmlcBackend ? true # depends on js_of_ocaml
6}:
7
8let
9 inherit (lib) optionals versionOlder;
10
11 pname = "vg";
12 version = "0.9.4";
13 webpage = "https://erratique.ch/software/${pname}";
14in
15
16if versionOlder ocaml.version "4.03"
17then throw "vg is not available for OCaml ${ocaml.version}"
18else
19
20stdenv.mkDerivation {
21
22 name = "ocaml${ocaml.version}-${pname}-${version}";
23
24 src = fetchurl {
25 url = "${webpage}/releases/${pname}-${version}.tbz";
26 sha256 = "181sz6l5xrj5jvwg4m2yqsjzwp2s5h8v0mwhjcwbam90kdfx2nak";
27 };
28
29 nativeBuildInputs = [ ocaml findlib ocamlbuild ];
30 buildInputs = [ topkg ];
31
32 propagatedBuildInputs = [ uchar result gg ]
33 ++ optionals pdfBackend [ uutf otfm ]
34 ++ optionals htmlcBackend [ js_of_ocaml js_of_ocaml-ppx ];
35
36 strictDeps = true;
37
38 buildPhase = topkg.buildPhase
39 + " --with-uutf ${lib.boolToString pdfBackend}"
40 + " --with-otfm ${lib.boolToString pdfBackend}"
41 + " --with-js_of_ocaml ${lib.boolToString htmlcBackend}"
42 + " --with-cairo2 false";
43
44 inherit (topkg) installPhase;
45
46 meta = with lib; {
47 description = "Declarative 2D vector graphics for OCaml";
48 longDescription = ''
49 Vg is an OCaml module for declarative 2D vector graphics. In Vg, images
50 are values that denote functions mapping points of the cartesian plane
51 to colors. The module provides combinators to define and compose these
52 values.
53
54 Renderers for PDF, SVG and the HTML canvas are distributed with the
55 module. An API allows to implement new renderers.
56 '';
57 homepage = webpage;
58 license = licenses.isc;
59 maintainers = [ maintainers.jirkamarsik ];
60 mainProgram = "vecho";
61 inherit (ocaml.meta) platforms;
62 };
63}