1 { config, stdenv, lib, fetchurl, pkg-config, zlib, expat, openssl, autoconf
2 , libjpeg, libpng, libtiff, freetype, fontconfig, libpaper, jbig2dec
3 , libiconv, ijs, lcms2, fetchpatch
4 , cupsSupport ? config.ghostscript.cups or (!stdenv.isDarwin), cups ? null
5 , x11Support ? cupsSupport, xlibsWrapper ? null # with CUPS, X11 only adds very little
8 assert x11Support -> xlibsWrapper != null;
9 assert cupsSupport -> cups != null;
12 fonts = stdenv.mkDerivation {
13 name = "ghostscript-fonts";
17 url = "mirror://sourceforge/gs-fonts/ghostscript-fonts-std-8.11.tar.gz";
18 sha256 = "00f4l10xd826kak51wsmaz69szzm2wp8a41jasr4jblz25bg7dhf";
21 url = "mirror://gnu/ghostscript/gnu-gs-fonts-other-6.0.tar.gz";
22 sha256 = "1cxaah3r52qq152bbkiyj2f7dx1rf38vsihlhjmrvzlr8v6cqil1";
24 # ... add other fonts here
34 stdenv.mkDerivation rec {
35 pname = "ghostscript";
39 url = "https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs9${lib.versions.minor version}${lib.versions.patch version}/${pname}-${version}.tar.xz";
40 sha512 = "2vif3vgxa5wma16yxvhhkymk4p309y5204yykarq94r5rk890556d2lj5w7acnaa2ymkym6y0zd4vq9sy9ca2346igg2c6dxqkjr0zb";
45 url = "https://github.com/ArtifexSoftware/ghostpdl/commit/41ef9a0bc36b9db7115fbe9623f989bfb47bbade.patch";
46 sha256 = "1qpc6q1fpxshqc0mqgg36kng47kgljk50bmr8p7wn21jgfkh7m8w";
48 ./urw-font-files.patch
52 outputs = [ "out" "man" "doc" ];
54 enableParallelBuilding = true;
56 nativeBuildInputs = [ pkg-config autoconf ];
59 libjpeg libpng libtiff freetype fontconfig libpaper jbig2dec
62 ++ lib.optional x11Support xlibsWrapper
63 ++ lib.optional cupsSupport cups
67 # requires in-tree (heavily patched) openjpeg
68 rm -rf jpeg libpng zlib jasper expat tiff lcms2mt jbig2dec freetype cups/libs ijs
70 sed "s@if ( test -f \$(INCLUDE)[^ ]* )@if ( true )@; s@INCLUDE=/usr/include@INCLUDE=/no-such-path@" -i base/unix-aux.mak
71 sed "s@^ZLIBDIR=.*@ZLIBDIR=${zlib.dev}/include@" -i configure.ac
77 "--with-system-libtiff"
80 ++ lib.optional x11Support "--with-x"
81 ++ lib.optionals cupsSupport [
83 "--with-cups-serverbin=$(out)/lib/cups"
84 "--with-cups-serverroot=$(out)/etc/cups"
85 "--with-cups-datadir=$(out)/share/cups"
90 # don't build/install statically linked bin/gs
91 buildFlags = [ "so" ];
92 installTargets = [ "soinstall" ];
95 ln -s gsc "$out"/bin/gs
97 cp -r Resource "$out/share/ghostscript/${version}"
99 ln -s "${fonts}" "$out/share/ghostscript/fonts"
100 '' + lib.optionalString stdenv.isDarwin ''
101 for file in $out/lib/*.dylib* ; do
102 install_name_tool -id "$file" $file
106 # dynamic library name only contains maj.min, eg. '9.53'
107 dylib_version = lib.versions.majorMinor version;
108 preFixup = lib.optionalString stdenv.isDarwin ''
109 install_name_tool -change libgs.dylib.$dylib_version $out/lib/libgs.dylib.$dylib_version $out/bin/gs
112 # validate dynamic linkage
113 doInstallCheck = true;
114 installCheckPhase = ''
115 runHook preInstallCheck
117 $out/bin/gs --version
119 runHook postInstallCheck
123 homepage = "https://www.ghostscript.com/";
124 description = "PostScript interpreter (mainline version)";
127 Ghostscript is the name of a set of tools that provides (i) an
128 interpreter for the PostScript language and the PDF file format,
129 (ii) a set of C procedures (the Ghostscript library) that
130 implement the graphics capabilities that appear as primitive
131 operations in the PostScript language, and (iii) a wide variety
132 of output drivers for various file formats and printers.
135 license = lib.licenses.agpl3;
137 platforms = lib.platforms.all;
138 maintainers = [ lib.maintainers.viric ];