1{
2 lib,
3 stdenv,
4 fetchFromGitLab,
5 autoreconfHook,
6 pkg-config,
7 cairo,
8 expat,
9 flex,
10 fontconfig,
11 gd,
12 gts,
13 libjpeg,
14 libpng,
15 libtool,
16 makeWrapper,
17 pango,
18 bash,
19 bison,
20 xorg,
21 python3,
22 withXorg ? true,
23
24 # for passthru.tests
25 exiv2,
26 fltk,
27 graphicsmagick,
28}:
29
30let
31 inherit (lib) optional optionals optionalString;
32in
33stdenv.mkDerivation rec {
34 pname = "graphviz";
35 version = "12.2.1";
36
37 src = fetchFromGitLab {
38 owner = "graphviz";
39 repo = "graphviz";
40 rev = version;
41 hash = "sha256-Uxqg/7+LpSGX4lGH12uRBxukVw0IswFPfpb2EkLsaiI=";
42 };
43
44 nativeBuildInputs = [
45 autoreconfHook
46 makeWrapper
47 pkg-config
48 python3
49 bison
50 flex
51 ];
52
53 buildInputs = [
54 libpng
55 libjpeg
56 expat
57 fontconfig
58 gd
59 gts
60 pango
61 bash
62 ]
63 ++ optionals withXorg (with xorg; [ libXrender ]);
64
65 hardeningDisable = [ "fortify" ];
66
67 configureFlags = [
68 "--with-ltdl-lib=${libtool.lib}/lib"
69 "--with-ltdl-include=${libtool}/include"
70 ]
71 ++ optional (xorg == null) "--without-x";
72
73 enableParallelBuilding = true;
74
75 CPPFLAGS = optionalString (withXorg && stdenv.hostPlatform.isDarwin) "-I${cairo.dev}/include/cairo";
76
77 doCheck = false; # fails with "Graphviz test suite requires ksh93" which is not in nixpkgs
78
79 preAutoreconf = ''
80 ./autogen.sh
81 '';
82
83 postFixup = optionalString withXorg ''
84 substituteInPlace $out/bin/vimdot \
85 --replace-warn '"/usr/bin/vi"' '"$(command -v vi)"' \
86 --replace-warn '"/usr/bin/vim"' '"$(command -v vim)"' \
87 --replace-warn /usr/bin/vimdot $out/bin/vimdot
88
89 wrapProgram $out/bin/vimdot --prefix PATH : "$out/bin"
90 '';
91
92 passthru.tests = {
93 inherit (python3.pkgs)
94 graphviz
95 pydot
96 pygraphviz
97 xdot
98 ;
99 inherit
100 exiv2
101 fltk
102 graphicsmagick
103 ;
104 };
105
106 meta = with lib; {
107 homepage = "https://graphviz.org";
108 description = "Graph visualization tools";
109 license = licenses.epl10;
110 platforms = platforms.unix;
111 maintainers = with maintainers; [
112 bjornfor
113 raskin
114 ];
115 };
116}