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