1{ lib, stdenv, fetchurl, makeWrapper, pkgconfig, texinfo
2, cairo, gd, libcerf, pango, readline, zlib
3, withTeXLive ? false, texlive
4, withLua ? false, lua
5, libX11 ? null
6, libXt ? null
7, libXpm ? null
8, libXaw ? null
9, aquaterm ? false
10, withWxGTK ? false, wxGTK ? null
11, fontconfig ? null
12, gnused ? null
13, coreutils ? null
14, withQt ? false, qttools, qtbase, qtsvg
15}:
16
17assert libX11 != null -> (fontconfig != null && gnused != null && coreutils != null);
18let
19 withX = libX11 != null && !aquaterm && !stdenv.isDarwin;
20in
21stdenv.mkDerivation rec {
22 name = "gnuplot-5.2.4";
23
24 src = fetchurl {
25 url = "mirror://sourceforge/gnuplot/${name}.tar.gz";
26 sha256 = "1jvh8xmd2cvrhlsg88kxwh55wkwx31sg50v1n59slfippl0g058m";
27 };
28
29 nativeBuildInputs = [ makeWrapper pkgconfig texinfo ] ++ lib.optional withQt qttools;
30
31 buildInputs =
32 [ cairo gd libcerf pango readline zlib ]
33 ++ lib.optional withTeXLive (texlive.combine { inherit (texlive) scheme-small; })
34 ++ lib.optional withLua lua
35 ++ lib.optionals withX [ libX11 libXpm libXt libXaw ]
36 ++ lib.optionals withQt [ qtbase qtsvg ]
37 ++ lib.optional withWxGTK wxGTK;
38
39 postPatch = ''
40 # lrelease is in qttools, not in qtbase.
41 sed -i configure -e 's|''${QT5LOC}/lrelease|lrelease|'
42 '';
43
44 configureFlags = [
45 (if withX then "--with-x" else "--without-x")
46 (if withQt then "--with-qt=qt5" else "--without-qt")
47 (if aquaterm then "--with-aquaterm" else "--without-aquaterm")
48 ];
49
50 postInstall = lib.optionalString withX ''
51 wrapProgram $out/bin/gnuplot \
52 --prefix PATH : '${gnused}/bin' \
53 --prefix PATH : '${coreutils}/bin' \
54 --prefix PATH : '${fontconfig.bin}/bin' \
55 --run '. ${./set-gdfontpath-from-fontconfig.sh}'
56 '';
57
58 enableParallelBuilding = true;
59
60 meta = with lib; {
61 homepage = http://www.gnuplot.info/;
62 description = "A portable command-line driven graphing utility for many platforms";
63 platforms = platforms.linux ++ platforms.darwin;
64 license = {
65 # Essentially a BSD license with one modifaction:
66 # Permission to modify the software is granted, but not the right to
67 # distribute the complete modified source code. Modifications are to
68 # be distributed as patches to the released version. Permission to
69 # distribute binaries produced by compiling modified sources is granted,
70 # provided you: ...
71 url = https://sourceforge.net/p/gnuplot/gnuplot-main/ci/master/tree/Copyright;
72 };
73 maintainers = with maintainers; [ lovek323 ];
74 };
75}