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