at 17.09-beta 3.8 kB view raw
1{ stdenv, lib, fetchurl, fetchpatch, pkgconfig, zlib, expat, openssl, autoconf 2, libjpeg, libpng, libtiff, freetype, fontconfig, lcms2, libpaper, jbig2dec 3, libiconv, ijs 4, x11Support ? false, xlibsWrapper ? null 5, cupsSupport ? false, cups ? null 6}: 7 8assert x11Support -> xlibsWrapper != null; 9assert cupsSupport -> cups != null; 10let 11 version = "9.20"; 12 sha256 = "1az0dnvgingqv78yvfhzmx1zavn5sv1xrrscz984hy3gvz2ks3rw"; 13 14 fonts = stdenv.mkDerivation { 15 name = "ghostscript-fonts"; 16 17 srcs = [ 18 (fetchurl { 19 url = "mirror://sourceforge/gs-fonts/ghostscript-fonts-std-8.11.tar.gz"; 20 sha256 = "00f4l10xd826kak51wsmaz69szzm2wp8a41jasr4jblz25bg7dhf"; 21 }) 22 (fetchurl { 23 url = "mirror://gnu/ghostscript/gnu-gs-fonts-other-6.0.tar.gz"; 24 sha256 = "1cxaah3r52qq152bbkiyj2f7dx1rf38vsihlhjmrvzlr8v6cqil1"; 25 }) 26 # ... add other fonts here 27 ]; 28 29 installPhase = '' 30 mkdir "$out" 31 mv -v * "$out/" 32 ''; 33 }; 34 35in 36stdenv.mkDerivation rec { 37 name = "ghostscript-${version}"; 38 39 src = fetchurl { 40 url = "https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs920/${name}.tar.xz"; 41 inherit sha256; 42 }; 43 44 outputs = [ "out" "man" "doc" ]; 45 46 enableParallelBuilding = true; 47 48 nativeBuildInputs = [ pkgconfig autoconf ]; 49 buildInputs = 50 [ zlib expat openssl 51 libjpeg libpng libtiff freetype fontconfig lcms2 libpaper jbig2dec 52 libiconv ijs 53 ] 54 ++ lib.optional x11Support xlibsWrapper 55 ++ lib.optional cupsSupport cups 56 ; 57 58 patches = [ 59 ./urw-font-files.patch 60 ]; 61 62 preConfigure = '' 63 # requires in-tree (heavily patched) openjpeg 64 rm -rf jpeg libpng zlib jasper expat tiff lcms{,2} jbig2dec freetype cups/libs ijs 65 66 sed "s@if ( test -f \$(INCLUDE)[^ ]* )@if ( true )@; s@INCLUDE=/usr/include@INCLUDE=/no-such-path@" -i base/unix-aux.mak 67 sed "s@^ZLIBDIR=.*@ZLIBDIR=${zlib.dev}/include@" -i configure.ac 68 69 autoconf 70 '' + lib.optionalString cupsSupport '' 71 configureFlags="$configureFlags --with-cups-serverbin=$out/lib/cups --with-cups-serverroot=$out/etc/cups --with-cups-datadir=$out/share/cups" 72 ''; 73 74 configureFlags = 75 [ "--with-system-libtiff" 76 "--enable-dynamic" 77 ] ++ lib.optional x11Support "--with-x" 78 ++ lib.optional cupsSupport "--enable-cups"; 79 80 doCheck = true; 81 82 # don't build/install statically linked bin/gs 83 buildFlags = [ "so" ]; 84 installTargets = [ "soinstall" ]; 85 86 postInstall = '' 87 ln -s gsc "$out"/bin/gs 88 89 cp -r Resource "$out/share/ghostscript/${version}" 90 91 mkdir -p "$doc/share/ghostscript/${version}" 92 mv "$out/share/ghostscript/${version}"/{doc,examples} "$doc/share/ghostscript/${version}/" 93 94 ln -s "${fonts}" "$out/share/ghostscript/fonts" 95 '' + stdenv.lib.optionalString stdenv.isDarwin '' 96 for file in $out/lib/*.dylib* ; do 97 install_name_tool -id "$file" $file 98 done 99 ''; 100 101 preFixup = lib.optionalString stdenv.isDarwin '' 102 install_name_tool -change libgs.dylib.${version} $out/lib/libgs.dylib.${version} $out/bin/gs 103 ''; 104 105 passthru = { inherit version; }; 106 107 meta = { 108 homepage = https://www.ghostscript.com/; 109 description = "PostScript interpreter (mainline version)"; 110 111 longDescription = '' 112 Ghostscript is the name of a set of tools that provides (i) an 113 interpreter for the PostScript language and the PDF file format, 114 (ii) a set of C procedures (the Ghostscript library) that 115 implement the graphics capabilities that appear as primitive 116 operations in the PostScript language, and (iii) a wide variety 117 of output drivers for various file formats and printers. 118 ''; 119 120 license = stdenv.lib.licenses.gpl3Plus; 121 122 platforms = stdenv.lib.platforms.all; 123 maintainers = [ stdenv.lib.maintainers.viric ]; 124 }; 125}