1{ lib, stdenv, fetchurl, makeWrapper, pkgconfig, texinfo
2, cairo, gd, libcerf, pango, readline, zlib
3, withTeXLive ? false, texlive
4, withLua ? false, lua
5, emacs ? null
6, libX11 ? null
7, libXt ? null
8, libXpm ? null
9, libXaw ? null
10, aquaterm ? false
11, withWxGTK ? false, wxGTK ? null
12, fontconfig ? null
13, gnused ? null
14, coreutils ? null
15, withQt ? false, qttools, qtbase, qtsvg
16}:
17
18assert libX11 != null -> (fontconfig != null && gnused != null && coreutils != null);
19let
20 withX = libX11 != null && !aquaterm && !stdenv.isDarwin;
21in
22stdenv.mkDerivation rec {
23 name = "gnuplot-5.2.2";
24
25 src = fetchurl {
26 url = "mirror://sourceforge/gnuplot/${name}.tar.gz";
27 sha256 = "18diyy7aib9mn098x07g25c7jij1x7wbfpicz0z8gwxx08px45m4";
28 };
29
30 nativeBuildInputs = [ makeWrapper pkgconfig texinfo ] ++ lib.optional withQt qttools;
31
32 buildInputs =
33 [ cairo gd libcerf pango readline zlib ]
34 ++ lib.optional withTeXLive (texlive.combine { inherit (texlive) scheme-small; })
35 ++ lib.optional withLua lua
36 ++ lib.optionals withX [ libX11 libXpm libXt libXaw ]
37 ++ lib.optionals withQt [ qtbase qtsvg ]
38 ++ lib.optional withWxGTK wxGTK;
39
40 postPatch = ''
41 # lrelease is in qttools, not in qtbase.
42 sed -i configure -e 's|''${QT5LOC}/lrelease|lrelease|'
43 '';
44
45 configureFlags = [
46 (if withX then "--with-x" else "--without-x")
47 (if withQt then "--with-qt=qt5" else "--without-qt")
48 (if aquaterm then "--with-aquaterm" else "--without-aquaterm")
49 ];
50
51 postInstall = lib.optionalString withX ''
52 wrapProgram $out/bin/gnuplot \
53 --prefix PATH : '${gnused}/bin' \
54 --prefix PATH : '${coreutils}/bin' \
55 --prefix PATH : '${fontconfig.bin}/bin' \
56 --run '. ${./set-gdfontpath-from-fontconfig.sh}'
57 '';
58
59 enableParallelBuilding = true;
60
61 meta = with lib; {
62 homepage = http://www.gnuplot.info/;
63 description = "A portable command-line driven graphing utility for many platforms";
64 platforms = platforms.linux ++ platforms.darwin;
65 maintainers = with maintainers; [ lovek323 ];
66 };
67}