From 18b64f05c9e4637bbbb516d759da333e2721c6a6 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Wed, 13 Jan 2016 19:07:21 +0300 Subject: [PATCH 01/15] ijs: 9.16 -> 9.18 --- pkgs/development/libraries/ijs/default.nix | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/ijs/default.nix b/pkgs/development/libraries/ijs/default.nix index fbba11c10c93..0c7d412fee65 100644 --- a/pkgs/development/libraries/ijs/default.nix +++ b/pkgs/development/libraries/ijs/default.nix @@ -1,16 +1,25 @@ -{ stdenv, fetchurl, autoreconfHook }: +{ stdenv, fetchurl, fetchpatch, autoreconfHook }: -let version = "9.16"; +let version = "9.18"; in stdenv.mkDerivation { name = "ijs-${version}"; src = fetchurl { url = "http://downloads.ghostscript.com/public/ghostscript-${version}.tar.bz2"; - sha256 = "0vdqbjkickb0109lk6397bb2zjmg1s46dac5p5j4gfxa4pwl8b9y"; + sha256 = "18ad90za28dxybajqwf3y3dld87cgkx1ljllmcnc7ysspfxzbnl3"; }; - prePatch = "cd ijs"; + patches = [ + # http://bugs.ghostscript.com/show_bug.cgi?id=696246 + (fetchpatch { + name = "devijs-account-for-device-subclassing.patch"; + url = "http://git.ghostscript.com/?p=ghostpdl.git;a=patch;h=b68e05c3"; + sha256 = "1c3fzfjzvf15z533vpw3l3da8wcxw98qi3p1lc6lf13940a57c7n"; + }) + ]; + + postPatch = "cd ijs"; enableParallelBuilding = true; From 1967f19f7db4029120b2df3e0ec5bc30e5144598 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Wed, 13 Jan 2016 19:07:42 +0300 Subject: [PATCH 02/15] qpdf: 5.1.3 -> 6.0.0 --- pkgs/development/libraries/qpdf/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/qpdf/default.nix b/pkgs/development/libraries/qpdf/default.nix index 340f4558f819..8f886421d55b 100644 --- a/pkgs/development/libraries/qpdf/default.nix +++ b/pkgs/development/libraries/qpdf/default.nix @@ -1,13 +1,13 @@ { stdenv, fetchurl, pcre, zlib, perl }: -let version = "5.1.3"; +let version = "6.0.0"; in stdenv.mkDerivation rec { name = "qpdf-${version}"; src = fetchurl { url = "mirror://sourceforge/qpdf/qpdf/${version}/${name}.tar.gz"; - sha256 = "1lq1v7xghvl6p4hgrwbps3a13ad6lh4ib3myimb83hxgsgd4n5nm"; + sha256 = "0csj2p2gkxrc0rk8ykymlsdgfas96vzf1dip3y1x7z1q9plwgzd9"; }; nativeBuildInputs = [ perl ]; @@ -23,6 +23,7 @@ stdenv.mkDerivation rec { ''; doCheck = true; + enableParallelBuilding = true; meta = with stdenv.lib; { homepage = http://qpdf.sourceforge.net/; From 35e1f4954555f465fb4499880dcb6a68417fb959 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Wed, 13 Jan 2016 19:46:41 +0300 Subject: [PATCH 03/15] cups: 2.0.4 -> 2.1.2 Also enable parallel building and don't install rc.d scripts. --- pkgs/misc/cups/default.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/misc/cups/default.nix b/pkgs/misc/cups/default.nix index 8fa111ecc023..7dedf26096df 100644 --- a/pkgs/misc/cups/default.nix +++ b/pkgs/misc/cups/default.nix @@ -3,7 +3,7 @@ , libusb ? null, gnutls ? null, avahi ? null, libpaper ? null }: -let version = "2.0.4"; in +let version = "2.1.2"; in with stdenv.lib; stdenv.mkDerivation { @@ -13,7 +13,7 @@ stdenv.mkDerivation { src = fetchurl { url = "https://www.cups.org/software/${version}/cups-${version}-source.tar.bz2"; - sha256 = "1gaakz24k6x5nc09rmpiq0xq20j1qdjc3szag8qwmyi4ky6ydmg1"; + sha256 = "1bc1y8fjgh54ryh520gk63i5rbagn6jijsrskcqlibhfm0xwmc5s"; }; buildInputs = [ pkgconfig zlib libjpeg libpng libtiff libusb gnutls libpaper ] @@ -51,7 +51,6 @@ stdenv.mkDerivation { # Idem for /etc. "PAMDIR=$(out)/etc/pam.d" "DBUSDIR=$(out)/etc/dbus-1" - "INITDIR=$(out)/etc/rc.d" "XINETD=$(out)/etc/xinetd.d" "SERVERROOT=$(out)/etc/cups" # Idem for /usr. @@ -61,6 +60,8 @@ stdenv.mkDerivation { "CUPS_PRIMARY_SYSTEM_GROUP=root" ]; + enableParallelBuilding = true; + postInstall = '' # Delete obsolete stuff that conflicts with cups-filters. rm -rf $out/share/cups/banners $out/share/cups/data/testprint From a814e243b5f330267e779b6f037791da49f8d0e5 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Wed, 13 Jan 2016 19:47:07 +0300 Subject: [PATCH 04/15] ghostscript: 9.15 -> 9.18 --- pkgs/misc/ghostscript/CVE-2015-3228.patch | 20 --------- pkgs/misc/ghostscript/default.nix | 50 ++++++++++++++++++----- 2 files changed, 40 insertions(+), 30 deletions(-) delete mode 100644 pkgs/misc/ghostscript/CVE-2015-3228.patch diff --git a/pkgs/misc/ghostscript/CVE-2015-3228.patch b/pkgs/misc/ghostscript/CVE-2015-3228.patch deleted file mode 100644 index 7be18b0a7302..000000000000 --- a/pkgs/misc/ghostscript/CVE-2015-3228.patch +++ /dev/null @@ -1,20 +0,0 @@ -Description: Sanity check for memory allocation. - In gs_heap_alloc_bytes(), add a sanity check to ensure we don't overflow the - variable holding the actual number of bytes we allocate. -Origin: upstream, http://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=0c0b085 -Author: Chris Liddell -Forwarded: yes -Bug-Debian: http://bugs.debian.org/793489 -Last-Update: 2015-07-26 - ---- a/base/gsmalloc.c -+++ b/base/gsmalloc.c -@@ -178,7 +178,7 @@ - } else { - uint added = size + sizeof(gs_malloc_block_t); - -- if (mmem->limit - added < mmem->used) -+ if (added <= size || mmem->limit - added < mmem->used) - set_msg("exceeded limit"); - else if ((ptr = (byte *) Memento_label(malloc(added), cname)) == 0) - set_msg("failed"); diff --git a/pkgs/misc/ghostscript/default.nix b/pkgs/misc/ghostscript/default.nix index 53b5caf93122..658fa346f1ea 100644 --- a/pkgs/misc/ghostscript/default.nix +++ b/pkgs/misc/ghostscript/default.nix @@ -1,6 +1,6 @@ -{ stdenv, fetchurl, pkgconfig, zlib, expat, openssl +{ stdenv, fetchurl, fetchpatch, pkgconfig, zlib, expat, openssl, autoconf , libjpeg, libpng, libtiff, freetype, fontconfig, lcms2, libpaper, jbig2dec -, libiconv +, libiconv, ijs , x11Support ? false, xlibsWrapper ? null , cupsSupport ? false, cups ? null }: @@ -8,8 +8,8 @@ assert x11Support -> xlibsWrapper != null; assert cupsSupport -> cups != null; let - version = "9.15"; - sha256 = "0p1isp6ssfay141klirn7n9s8b546vcz6paksfmksbwy0ljsypg6"; + version = "9.18"; + sha256 = "18ad90za28dxybajqwf3y3dld87cgkx1ljllmcnc7ysspfxzbnl3"; fonts = stdenv.mkDerivation { name = "ghostscript-fonts"; @@ -45,28 +45,58 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; + nativeBuildInputs = [ pkgconfig autoconf ]; buildInputs = - [ pkgconfig zlib expat openssl + [ zlib expat openssl libjpeg libpng libtiff freetype fontconfig lcms2 libpaper jbig2dec - libiconv + libiconv ijs ] ++ stdenv.lib.optional x11Support xlibsWrapper ++ stdenv.lib.optional cupsSupport cups - # [] # maybe sometimes jpeg2000 support ; patches = [ ./urw-font-files.patch - # fetched from debian's ghostscript 9.15_dfsg-1 (called 020150707~0c0b085.patch there) - ./CVE-2015-3228.patch + # http://bugs.ghostscript.com/show_bug.cgi?id=696281 + (fetchpatch { + name = "fix-check-for-using-shared-freetype-lib.patch"; + url = "http://git.ghostscript.com/?p=ghostpdl.git;a=patch;h=8f5d285"; + sha256 = "1f0k043rng7f0rfl9hhb89qzvvksqmkrikmm38p61yfx51l325xr"; + }) + # http://bugs.ghostscript.com/show_bug.cgi?id=696301 + (fetchpatch { + name = "add-gserrors.h-to-the-installed-files.patch"; + url = "http://git.ghostscript.com/?p=ghostpdl.git;a=patch;h=feafe5e5"; + sha256 = "0s4ayzakjv809dkn7vilxwvs4dw35p3pw942ml91bk9z4kkaxyz7"; + }) + # http://bugs.ghostscript.com/show_bug.cgi?id=696246 + (fetchpatch { + name = "guard-against-NULL-base-for-non-clist-devices.patch"; + url = "http://git.ghostscript.com/?p=ghostpdl.git;a=patch;h=007bd77d08d800e6b07274d62e3c91be7c4a3f47"; + sha256 = "1la53273agl92lpy7qd0qhgzynx8b90hrk8g9jsj3055ssn6rqwh"; + }) + (fetchpatch { + name = "ensure-plib-devices-always-use-the-clist.patch"; + url = "http://git.ghostscript.com/?p=ghostpdl.git;a=patch;h=1bdbe4f87dc57648821e613ebcc591b84e8b35b3"; + sha256 = "1cq83fgyvrycapxm69v4r9f9qhzsr40ygrc3bkp8pk15wsmvq0k7"; + }) + (fetchpatch { + name = "prevent-rinkj-device-crash-when-misconfigured.patch"; + url = "http://git.ghostscript.com/?p=ghostpdl.git;a=patch;h=5571ddfa377c5d7d98f55af40e693814ac287ae4"; + sha256 = "08iqdlrngi6k0ml2b71dj5q136fyp1s9g0rr87ayyshn0k0lxwkv"; + }) ]; makeFlags = [ "cups_serverroot=$(out)" "cups_serverbin=$(out)/lib/cups" ]; preConfigure = '' - rm -rf jpeg libpng zlib jasper expat tiff lcms{,2} jbig2dec openjpeg freetype cups/libs + # requires in-tree (heavily patched) openjpeg + rm -rf jpeg libpng zlib jasper expat tiff lcms{,2} jbig2dec freetype cups/libs ijs sed "s@if ( test -f \$(INCLUDE)[^ ]* )@if ( true )@; s@INCLUDE=/usr/include@INCLUDE=/no-such-path@" -i base/unix-aux.mak + sed "s@^ZLIBDIR=.*@ZLIBDIR=${zlib}/include@" -i configure.ac + + autoconf ''; configureFlags = From eaaf988d4552703be38c8acd2597ddf5eae2b181 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Wed, 13 Jan 2016 19:07:59 +0300 Subject: [PATCH 05/15] cups_filters: 1.0.71 -> 1.5.0 Also wrap filters adding necessary utils to PATH and enable parallel building. --- pkgs/misc/cups/filters.nix | 35 +++++++++++++------------- pkgs/misc/cups/longer-shell-path.patch | 13 ---------- 2 files changed, 18 insertions(+), 30 deletions(-) delete mode 100644 pkgs/misc/cups/longer-shell-path.patch diff --git a/pkgs/misc/cups/filters.nix b/pkgs/misc/cups/filters.nix index b4b3a5a06247..7118511f16d3 100644 --- a/pkgs/misc/cups/filters.nix +++ b/pkgs/misc/cups/filters.nix @@ -1,26 +1,24 @@ -{ stdenv, fetchurl, fetchpatch, pkgconfig, cups, poppler, poppler_utils, fontconfig -, libjpeg, libpng, perl, ijs, qpdf, dbus, substituteAll, bash, avahi }: +{ stdenv, fetchurl, pkgconfig, cups, poppler, poppler_utils, fontconfig +, libjpeg, libpng, perl, ijs, qpdf, dbus, substituteAll, bash, avahi +, makeWrapper, coreutils, gnused, bc, gawk, gnugrep, which +}: -stdenv.mkDerivation rec { +let + binPath = stdenv.lib.makeSearchPath "bin" [ coreutils gnused bc gawk gnugrep which ]; + +in stdenv.mkDerivation rec { name = "cups-filters-${version}"; - version = "1.0.71"; + version = "1.5.0"; src = fetchurl { url = "http://openprinting.org/download/cups-filters/${name}.tar.xz"; - sha256 = "07wwlqcykfjfqcwj1bxk60ggahyaw7wcx32n5s104d1qkhham01i"; + sha256 = "0cjrh4wpdhkvmahfkg8f2a2qzilcq12i78q5arwr7dnmx1j8hapj"; }; - patches = [ - ./longer-shell-path.patch - (fetchpatch { # drop on update - name = "poppler-0.34.patch"; - url = "https://bugs.linuxfoundation.org/attachment.cgi?id=493"; - sha256 = "18za83q0b0n4hpvvw76jsv0hm89zmijvps2z5kg1srickqlxj891"; - }) - ]; + nativeBuildInputs = [ pkgconfig makeWrapper ]; buildInputs = [ - pkgconfig cups poppler poppler_utils fontconfig libjpeg libpng perl + cups poppler poppler_utils fontconfig libjpeg libpng perl ijs qpdf dbus avahi ]; @@ -29,9 +27,10 @@ stdenv.mkDerivation rec { "--enable-imagefilters" "--with-rcdir=no" "--with-shell=${stdenv.shell}" + "--with-test-font-path=/path-does-not-exist" ]; - makeFlags = "CUPS_SERVERBIN=$(out)/lib/cups CUPS_DATADIR=$(out)/share/cups CUPS_SERVERROOT=$(out)/etc/cups"; + makeFlags = [ "CUPS_SERVERBIN=$(out)/lib/cups" "CUPS_DATADIR=$(out)/share/cups" "CUPS_SERVERROOT=$(out)/etc/cups" ]; postConfigure = '' @@ -46,11 +45,13 @@ stdenv.mkDerivation rec { postInstall = '' - for i in $out/lib/cups/filter/{pstopdf,texttops,imagetops}; do - substituteInPlace $i --replace 'which ' 'type -p ' + for i in $out/lib/cups/filter/*; do + wrapProgram "$i" --prefix PATH ':' ${binPath} done ''; + enableParallelBuilding = true; + meta = { homepage = http://www.linuxfoundation.org/collaborate/workgroups/openprinting/cups-filters; description = "Backends, filters, and other software that was once part of the core CUPS distribution but is no longer maintained by Apple Inc"; diff --git a/pkgs/misc/cups/longer-shell-path.patch b/pkgs/misc/cups/longer-shell-path.patch deleted file mode 100644 index 397cc681732b..000000000000 --- a/pkgs/misc/cups/longer-shell-path.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/filter/foomatic-rip/foomaticrip.c b/filter/foomatic-rip/foomaticrip.c -index 90a851c..689a2bd 100644 ---- a/filter/foomatic-rip/foomaticrip.c -+++ b/filter/foomatic-rip/foomaticrip.c -@@ -174,7 +174,7 @@ char cupsfilterpath[PATH_MAX] = "/usr/local/lib/cups/filter:" - "/opt/cups/filter:" - "/usr/lib/cups/filter"; - --char modern_shell[64] = SHELL; -+char modern_shell[] = SHELL; - - void config_set_option(const char *key, const char *value) - { From d34a72dfba19e6db6f70023b92544b54e88b81f4 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Wed, 13 Jan 2016 20:48:28 +0300 Subject: [PATCH 06/15] libspectre: fix for ghostscript 9.18 --- .../libraries/libspectre/default.nix | 2 + .../libspectre/libspectre-0.2.7-gs918.patch | 42 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 pkgs/development/libraries/libspectre/libspectre-0.2.7-gs918.patch diff --git a/pkgs/development/libraries/libspectre/default.nix b/pkgs/development/libraries/libspectre/default.nix index 0e5f976c1224..5c10fff50ad3 100644 --- a/pkgs/development/libraries/libspectre/default.nix +++ b/pkgs/development/libraries/libspectre/default.nix @@ -8,6 +8,8 @@ stdenv.mkDerivation rec { sha256 = "1v63lqc6bhhxwkpa43qmz8phqs8ci4dhzizyy16d3vkb20m846z8"; }; + patches = [ ./libspectre-0.2.7-gs918.patch ]; + buildInputs = [ # Need `libgs.so'. pkgconfig ghostscript cairo /*for tests*/ diff --git a/pkgs/development/libraries/libspectre/libspectre-0.2.7-gs918.patch b/pkgs/development/libraries/libspectre/libspectre-0.2.7-gs918.patch new file mode 100644 index 000000000000..e9a4eda192ba --- /dev/null +++ b/pkgs/development/libraries/libspectre/libspectre-0.2.7-gs918.patch @@ -0,0 +1,42 @@ +Fixed error namespace for >=ghostscript-gpl-9.18 + +https://bugs.gentoo.org/563540 + +--- libspectre-0.2.7/libspectre/spectre-gs.c ++++ libspectre-0.2.7/libspectre/spectre-gs.c +@@ -43,12 +43,12 @@ + + if (code <= -100) { + switch (code) { +- case e_Fatal: ++ case gs_error_Fatal: + fprintf (stderr, "fatal internal error %d", code); + return TRUE; + break; + +- case e_ExecStackUnderflow: ++ case gs_error_ExecStackUnderflow: + fprintf (stderr, "stack overflow %d", code); + return TRUE; + break; +@@ -109,9 +109,9 @@ + set = _spectre_strdup_printf ("%d %d translate\n", -x, -y); + error = gsapi_run_string_continue (ghostscript_instance, set, strlen (set), + 0, &exit_code); +- error = error == e_NeedInput ? 0 : error; ++ error = error == gs_error_NeedInput ? 0 : error; + free (set); +- if (error != e_NeedInput && critic_error_code (error)) { ++ if (error != gs_error_NeedInput && critic_error_code (error)) { + fclose (fd); + return FALSE; + } +@@ -126,7 +126,7 @@ + read = fread (buf, sizeof (char), to_read, fd); + error = gsapi_run_string_continue (ghostscript_instance, + buf, read, 0, &exit_code); +- error = error == e_NeedInput ? 0 : error; ++ error = error == gs_error_NeedInput ? 0 : error; + left -= read; + } + From fbd3ad83e513e394698e71c0371ffc712a6da79f Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Sun, 17 Jan 2016 03:28:58 +0300 Subject: [PATCH 07/15] gimp: enable parallel building --- pkgs/applications/graphics/gimp/2.8.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/applications/graphics/gimp/2.8.nix b/pkgs/applications/graphics/gimp/2.8.nix index 954a1d4c19c9..96d6dbd52857 100644 --- a/pkgs/applications/graphics/gimp/2.8.nix +++ b/pkgs/applications/graphics/gimp/2.8.nix @@ -27,6 +27,8 @@ stdenv.mkDerivation rec { #configureFlags = [ "--disable-print" ]; + enableParallelBuilding = true; + # "screenshot" needs this. NIX_LDFLAGS = "-rpath ${xorg.libX11}/lib" + stdenv.lib.optionalString stdenv.isDarwin " -lintl"; From a8b3e686d0f1c4fe4a8836f7cbd79639fe34fede Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Sun, 17 Jan 2016 03:29:56 +0300 Subject: [PATCH 08/15] gutenprint: 5.2.10 -> 5.2.11 Rework gutenprint derivation: * Convert to regular stdenv.mkDerivation; * Enable IJS driver; * Fix cups-genppdupdate; * Move things around to the proper directories; * Enable parallel building; * Clean from old hacks. --- pkgs/misc/drivers/gutenprint/default.nix | 91 +++++++----------------- 1 file changed, 27 insertions(+), 64 deletions(-) diff --git a/pkgs/misc/drivers/gutenprint/default.nix b/pkgs/misc/drivers/gutenprint/default.nix index 98776c0c42b0..5be7f5ecff4d 100644 --- a/pkgs/misc/drivers/gutenprint/default.nix +++ b/pkgs/misc/drivers/gutenprint/default.nix @@ -1,78 +1,41 @@ # this package was called gimp-print in the past -{ fetchurl, stdenv, pkgconfig, composableDerivation, cups -, libtiff, libpng, makeWrapper, openssl, gimp }: +{ stdenv, lib, fetchurl, pkgconfig +, ijs, makeWrapper +, gimp2Support ? true, gimp +, cupsSupport ? true, cups, libusb, perl +}: -let - version = "5.2.10"; - inherit (composableDerivation) edf wwf; -in - -composableDerivation.composableDerivation {} { - name = "gutenprint-${version}"; +stdenv.mkDerivation rec { + name = "gutenprint-5.2.11"; src = fetchurl { - url = "mirror://sourceforge/gimp-print/gutenprint-${version}.tar.bz2"; - sha256 = "0n8f6vpadnagrp6yib3mca1c3lgwl4vmma16s44riyrd84mka7s3"; + url = "mirror://sourceforge/gimp-print/${name}.tar.bz2"; + sha256 = "1yadw96rgp1z0jv1wxrz6cds36nb693w3xlv596xw9r5w394r8y1"; }; - # gimp, gui is still not working (TODO) - buildInputs = [ makeWrapper openssl pkgconfig ]; + nativeBuildInputs = [ makeWrapper pkgconfig ]; + buildInputs = + [ ijs ] + ++ lib.optionals gimp2Support [ gimp.gtk gimp ] + ++ lib.optionals cupsSupport [ cups libusb perl ]; - configureFlags = ["--enable-static-genppd"]; - NIX_CFLAGS_COMPILE="-include stdio.h"; - - #preConfigure = '' - # configureFlags="--with-cups=$out/usr-cups $configureFlags" - #''; - - /* - is this recommended? without it this warning is printed: + configureFlags = lib.optionals cupsSupport [ + "--disable-static-genppd" # should be harmless on NixOS + ]; - ***WARNING: Use of --disable-static-genppd or --disable-static - when building CUPS is very dangerous. The build may - fail when building the PPD files, or may *SILENTLY* - build incorrect PPD files or cause other problems. - Please review the README and release notes carefully! - */ + enableParallelBuilding = true; - installPhase = '' - eval "make install $installArgs" - mkdir -p $out/lib/cups - ln -s $out/filter $out/lib/cups/ - wrapProgram $out/filter/rastertogutenprint.5.2 --prefix LD_LIBRARY_PATH : $out/lib - wrapProgram $out/sbin/cups-genppd.5.2 --prefix LD_LIBRARY_PATH : $out/lib - ''; + # Testing is very, very long. + # doCheck = true; - meta = { + installFlags = + lib.optionals cupsSupport [ "cups_conf_datadir=$(out)/share/cups" "cups_conf_serverbin=$(out)/lib/cups" "cups_conf_serverroot=$(out)/etc/cups" ] + ++ lib.optionals gimp2Support [ "gimp2_plug_indir=$(out)/${gimp.name}-plugins" ]; + + meta = with stdenv.lib; { description = "Ghostscript and cups printer drivers"; homepage = http://sourceforge.net/projects/gimp-print/; - license = "GPL"; + license = licenses.gpl2; + platforms = platforms.linux; }; - - mergeAttrBy = { installArgs = stdenv.lib.concat; }; - - # most interpreters aren't tested yet.. (see python for example how to do it) - flags = - wwf { - name = "gimp2"; - enable = { - buildInputs = [gimp gimp.gtk]; - installArgs = [ "gimp2_plug_indir=$out/${gimp.name}-plugins" ]; - }; - } - // { - cups = { - set = { - buildInputs = [cups libtiff libpng ]; - installArgs = [ "cups_conf_datadir=$out cups_conf_serverbin=$out cups_conf_serverroot=$out"]; - }; - }; - } - ; - - cfg = { - gimp2Support = true; - cupsSupport = true; - }; - } From 06865208e8516099c5ae54cfcd0c0be24ac9d0b9 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Sun, 17 Jan 2016 03:34:39 +0300 Subject: [PATCH 09/15] cupsd service: use cups-pk-helper is policykit is enabled --- nixos/modules/services/printing/cupsd.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/nixos/modules/services/printing/cupsd.nix b/nixos/modules/services/printing/cupsd.nix index 0fe25b66da08..6f5df23f3427 100644 --- a/nixos/modules/services/printing/cupsd.nix +++ b/nixos/modules/services/printing/cupsd.nix @@ -4,10 +4,13 @@ with lib; let - inherit (pkgs) cups cups_filters; + inherit (pkgs) cups cups-pk-helper cups_filters; cfg = config.services.printing; + avahiEnabled = config.services.avahi.enable; + polkitEnabled = config.security.polkit.enable; + additionalBackends = pkgs.runCommand "additional-cups-backends" { } '' mkdir -p $out @@ -204,7 +207,7 @@ in description = "CUPS printing services"; }; - environment.systemPackages = [ cups ]; + environment.systemPackages = [ cups ] ++ optional polkitEnabled cups-pk-helper; environment.etc."cups/client.conf".text = cfg.clientConf; environment.etc."cups/cups-files.conf".text = cfg.cupsFilesConf; @@ -212,7 +215,7 @@ in environment.etc."cups/cups-browsed.conf".text = cfg.browsedConf; environment.etc."cups/snmp.conf".text = cfg.snmpConf; - services.dbus.packages = [ cups ]; + services.dbus.packages = [ cups ] ++ optional polkitEnabled cups-pk-helper; # Cups uses libusb to talk to printers, and does not use the # linux kernel driver. If the driver is not in a black list, it @@ -242,7 +245,7 @@ in ]; }; - systemd.services.cups-browsed = mkIf config.services.avahi.enable + systemd.services.cups-browsed = mkIf avahiEnabled { description = "CUPS Remote Printer Discovery"; wantedBy = [ "multi-user.target" ]; From 8377b4e5d6e008ba528e54d0760f0aea7707d087 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Sun, 17 Jan 2016 03:38:52 +0300 Subject: [PATCH 10/15] cupsd service: move all default drivers to the bindir directly --- nixos/modules/services/printing/cupsd.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nixos/modules/services/printing/cupsd.nix b/nixos/modules/services/printing/cupsd.nix index 6f5df23f3427..06de71316ecc 100644 --- a/nixos/modules/services/printing/cupsd.nix +++ b/nixos/modules/services/printing/cupsd.nix @@ -33,7 +33,9 @@ let # cupsd.conf tells cupsd to use this tree. bindir = pkgs.buildEnv { name = "cups-progs"; - paths = cfg.drivers; + paths = + [ cups additionalBackends cups_filters pkgs.ghostscript ] + ++ cfg.drivers; pathsToLink = [ "/lib/cups" "/share/cups" "/bin" "/etc/cups" ]; postBuild = cfg.bindirCmds; ignoreCollisions = true; @@ -176,6 +178,7 @@ in drivers = mkOption { type = types.listOf types.path; + default = []; example = literalExample "[ pkgs.splix ]"; description = '' CUPS drivers to use. Drivers provided by CUPS, cups-filters, Ghostscript @@ -263,11 +266,6 @@ in ]; }; - services.printing.drivers = - [ cups pkgs.ghostscript pkgs.cups_filters additionalBackends - pkgs.perl pkgs.coreutils pkgs.gnused pkgs.bc pkgs.gawk pkgs.gnugrep - ]; - services.printing.cupsFilesConf = '' SystemGroup root wheel From d93f866f55adb6831e054e717253ee94071240b0 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Sun, 17 Jan 2016 04:05:02 +0300 Subject: [PATCH 11/15] cupsd service: add gutenprint support --- nixos/modules/services/printing/cupsd.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/printing/cupsd.nix b/nixos/modules/services/printing/cupsd.nix index 06de71316ecc..5964b62cc214 100644 --- a/nixos/modules/services/printing/cupsd.nix +++ b/nixos/modules/services/printing/cupsd.nix @@ -4,7 +4,7 @@ with lib; let - inherit (pkgs) cups cups-pk-helper cups_filters; + inherit (pkgs) cups cups-pk-helper cups_filters gutenprint; cfg = config.services.printing; @@ -35,6 +35,7 @@ let name = "cups-progs"; paths = [ cups additionalBackends cups_filters pkgs.ghostscript ] + ++ optional cfg.gutenprint gutenprint ++ cfg.drivers; pathsToLink = [ "/lib/cups" "/share/cups" "/bin" "/etc/cups" ]; postBuild = cfg.bindirCmds; @@ -176,6 +177,15 @@ in ''; }; + gutenprint = mkOption { + type = types.bool; + default = false; + description = '' + Whether to enable Gutenprint drivers for CUPS. This includes auto-updating + Gutenprint PPD files. + ''; + }; + drivers = mkOption { type = types.listOf types.path; default = []; @@ -240,6 +250,9 @@ in mkdir -m 0700 -p /var/cache/cups mkdir -m 0700 -p /var/spool/cups mkdir -m 0755 -p ${cfg.tempDir} + ${optionalString cfg.gutenprint '' + ${gutenprint}/bin/cups-genppdupdate + ''} ''; restartTriggers = From c311901810ab8ddefd38d94e5f625212a86e1c6b Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Sun, 17 Jan 2016 04:10:29 +0300 Subject: [PATCH 12/15] cupsd service: don't allow overriding necessary configuration options --- nixos/modules/rename.nix | 2 + nixos/modules/services/printing/cupsd.nix | 112 ++++++++++------------ 2 files changed, 55 insertions(+), 59 deletions(-) diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix index 010d44c40d19..cc7557c06eb4 100644 --- a/nixos/modules/rename.nix +++ b/nixos/modules/rename.nix @@ -99,6 +99,8 @@ with lib; (mkRemovedOptionModule [ "services" "syslog-ng" "listenToJournal" ]) (mkRemovedOptionModule [ "ec2" "metadata" ]) (mkRemovedOptionModule [ "services" "openvpn" "enable" ]) + (mkRemovedOptionModule [ "services" "printing" "cupsFilesConf" ]) + (mkRemovedOptionModule [ "services" "printing" "cupsdConf" ]) ]; } diff --git a/nixos/modules/services/printing/cupsd.nix b/nixos/modules/services/printing/cupsd.nix index 5964b62cc214..58d541dbcba6 100644 --- a/nixos/modules/services/printing/cupsd.nix +++ b/nixos/modules/services/printing/cupsd.nix @@ -42,6 +42,52 @@ let ignoreCollisions = true; }; + writeConf = name: text: pkgs.writeTextFile { + inherit name text; + destination = "/etc/cups/${name}"; + }; + + cupsFilesFile = writeConf "cups-files.conf" '' + SystemGroup root wheel + + ServerBin ${bindir}/lib/cups + DataDir ${bindir}/share/cups + + AccessLog syslog + ErrorLog syslog + PageLog syslog + + TempDir ${cfg.tempDir} + + # User and group used to run external programs, including + # those that actually send the job to the printer. Note that + # Udev sets the group of printer devices to `lp', so we want + # these programs to run as `lp' as well. + User cups + Group lp + + ${cfg.extraFilesConf} + ''; + + cupsdFile = writeConf "cupsd.conf" '' + ${concatMapStrings (addr: '' + Listen ${addr} + '') cfg.listenAddresses} + Listen /var/run/cups/cups.sock + + SetEnv PATH ${bindir}/lib/cups/filter:${bindir}/bin + + DefaultShared ${if cfg.defaultShared then "Yes" else "No"} + + Browsing ${if cfg.browsing then "Yes" else "No"} + + WebInterface ${if cfg.webInterface then "Yes" else "No"} + + ${cfg.extraConf} + ''; + + browsedFile = writeConf "cups-browsed.conf" cfg.browsedConf; + in { @@ -102,25 +148,11 @@ in ''; }; - cupsdConf = mkOption { - type = types.lines; - default = ""; - example = - '' - BrowsePoll cups.example.com - LogLevel debug - ''; - description = '' - The contents of the configuration file of the CUPS daemon - (cupsd.conf). - ''; - }; - - cupsFilesConf = mkOption { + extraFilesConf = mkOption { type = types.lines; default = ""; description = '' - The contents of the configuration file of the CUPS daemon + Extra contents of the configuration file of the CUPS daemon (cups-files.conf). ''; }; @@ -223,9 +255,9 @@ in environment.systemPackages = [ cups ] ++ optional polkitEnabled cups-pk-helper; environment.etc."cups/client.conf".text = cfg.clientConf; - environment.etc."cups/cups-files.conf".text = cfg.cupsFilesConf; - environment.etc."cups/cupsd.conf".text = cfg.cupsdConf; - environment.etc."cups/cups-browsed.conf".text = cfg.browsedConf; + environment.etc."cups/cups-files.conf".source = cupsFilesFile; + environment.etc."cups/cupsd.conf".source = cupsdFile; + environment.etc."cups/cups-browsed.conf".source = browsedFile; environment.etc."cups/snmp.conf".text = cfg.snmpConf; services.dbus.packages = [ cups ] ++ optional polkitEnabled cups-pk-helper; @@ -274,49 +306,13 @@ in serviceConfig.ExecStart = "${cups_filters}/bin/cups-browsed"; - restartTriggers = - [ config.environment.etc."cups/cups-browsed.conf".source - ]; + restartTriggers = [ browsedFile ]; }; - services.printing.cupsFilesConf = - '' - SystemGroup root wheel - - ServerBin ${bindir}/lib/cups - DataDir ${bindir}/share/cups - - AccessLog syslog - ErrorLog syslog - PageLog syslog - - TempDir ${cfg.tempDir} - - # User and group used to run external programs, including - # those that actually send the job to the printer. Note that - # Udev sets the group of printer devices to `lp', so we want - # these programs to run as `lp' as well. - User cups - Group lp - ''; - - services.printing.cupsdConf = + services.printing.extraConf = '' LogLevel info - ${concatMapStrings (addr: '' - Listen ${addr} - '') cfg.listenAddresses} - Listen /var/run/cups/cups.sock - - SetEnv PATH ${bindir}/lib/cups/filter:${bindir}/bin:${bindir}/sbin - - DefaultShared ${if cfg.defaultShared then "Yes" else "No"} - - Browsing ${if cfg.browsing then "Yes" else "No"} - - WebInterface ${if cfg.webInterface then "Yes" else "No"} - DefaultAuthType Basic @@ -357,8 +353,6 @@ in Order deny,allow - - ${cfg.extraConf} ''; security.pam.services.cups = {}; From 47017474fd75a75d747cdb5600b14b9203801984 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Sun, 17 Jan 2016 04:12:11 +0300 Subject: [PATCH 13/15] cupsd service: move root directory to /var/lib/cups --- nixos/modules/services/printing/cupsd.nix | 48 +++++++++++++++++------ 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/nixos/modules/services/printing/cupsd.nix b/nixos/modules/services/printing/cupsd.nix index 58d541dbcba6..98fb33e3256c 100644 --- a/nixos/modules/services/printing/cupsd.nix +++ b/nixos/modules/services/printing/cupsd.nix @@ -37,7 +37,7 @@ let [ cups additionalBackends cups_filters pkgs.ghostscript ] ++ optional cfg.gutenprint gutenprint ++ cfg.drivers; - pathsToLink = [ "/lib/cups" "/share/cups" "/bin" "/etc/cups" ]; + pathsToLink = [ "/lib/cups" "/share/cups" "/bin" ]; postBuild = cfg.bindirCmds; ignoreCollisions = true; }; @@ -88,6 +88,20 @@ let browsedFile = writeConf "cups-browsed.conf" cfg.browsedConf; + rootdir = pkgs.buildEnv { + name = "cups-progs"; + paths = [ + cupsFilesFile + cupsdFile + (writeConf "client.conf" cfg.clientConf) + (writeConf "snmp.conf" cfg.snmpConf) + ] ++ optional avahiEnabled browsedFile + ++ optional cfg.gutenprint gutenprint + ++ cfg.drivers; + pathsToLink = [ "/etc/cups" ]; + ignoreCollisions = true; + }; + in { @@ -253,12 +267,7 @@ in }; environment.systemPackages = [ cups ] ++ optional polkitEnabled cups-pk-helper; - - environment.etc."cups/client.conf".text = cfg.clientConf; - environment.etc."cups/cups-files.conf".source = cupsFilesFile; - environment.etc."cups/cupsd.conf".source = cupsdFile; - environment.etc."cups/cups-browsed.conf".source = browsedFile; - environment.etc."cups/snmp.conf".text = cfg.snmpConf; + environment.etc."cups".source = "/var/lib/cups"; services.dbus.packages = [ cups ] ++ optional polkitEnabled cups-pk-helper; @@ -278,19 +287,32 @@ in preStart = '' - mkdir -m 0755 -p /etc/cups mkdir -m 0700 -p /var/cache/cups mkdir -m 0700 -p /var/spool/cups mkdir -m 0755 -p ${cfg.tempDir} + + mkdir -m 0755 -p /var/lib/cups + # Backwards compatibility + if [ ! -L /etc/cups ]; then + mv /etc/cups/* /var/lib/cups + rmdir /etc/cups + ln -s /var/lib/cups /etc/cups + fi + # First, clean existing symlinks + if [ -n "$(ls /var/lib/cups)" ]; then + for i in /var/lib/cups/*; do + [ -L "$i" ] && rm "$i" + done + fi + # Then, populate it with static files + cd ${rootdir}/etc/cups + for i in *; do + [ ! -e "/var/lib/cups/$i" ] && ln -s "${rootdir}/etc/cups/$i" "/var/lib/cups/$i" + done ${optionalString cfg.gutenprint '' ${gutenprint}/bin/cups-genppdupdate ''} ''; - - restartTriggers = - [ config.environment.etc."cups/cups-files.conf".source - config.environment.etc."cups/cupsd.conf".source - ]; }; systemd.services.cups-browsed = mkIf avahiEnabled From 03353ce6ff738acce3d535f6a414895751967a05 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Sun, 17 Jan 2016 14:54:28 +0300 Subject: [PATCH 14/15] system-config-printer: 1.3.12 -> 1 5.7 --- .../misc/system-config-printer/default.nix | 27 ++++++++++++++----- .../detect_serverbindir.patch | 17 ++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 pkgs/tools/misc/system-config-printer/detect_serverbindir.patch diff --git a/pkgs/tools/misc/system-config-printer/default.nix b/pkgs/tools/misc/system-config-printer/default.nix index 6b0be9d2f6e8..7ed25fb549b0 100644 --- a/pkgs/tools/misc/system-config-printer/default.nix +++ b/pkgs/tools/misc/system-config-printer/default.nix @@ -5,16 +5,20 @@ , withGUI ? true }: -stdenv.mkDerivation rec { - name = "system-config-printer-1.3.12"; +let majorVersion = "1.5"; + +in stdenv.mkDerivation rec { + name = "system-config-printer-${majorVersion}.7"; src = fetchurl { - url = "http://cyberelk.net/tim/data/system-config-printer/1.3/${name}.tar.xz"; + url = "http://cyberelk.net/tim/data/system-config-printer/${majorVersion}/${name}.tar.xz"; sha256 = "1cg9n75rg5l9vr1925n2g771kga33imikyl0mf70lww2sfgvs18r"; }; propagatedBuildInputs = [ pythonPackages.pycurl ]; + patches = [ ./detect_serverbindir.patch ]; + buildInputs = [ intltool pkgconfig glib udev libusb1 cups xmlto libxml2 docbook_xml_dtd_412 docbook_xsl desktop_file_utils @@ -32,17 +36,28 @@ stdenv.mkDerivation rec { postInstall = '' + export makeWrapperArgs="--set prefix $out" wrapPythonPrograms + # The program imports itself, so we need to move shell wrappers to a proper place. + fixupWrapper() { + mv "$out/share/system-config-printer/$2.py" \ + "$out/bin/$1" + sed -i "s/.$2.py-wrapped/$2.py/g" "$out/bin/$1" + mv "$out/share/system-config-printer/.$2.py-wrapped" \ + "$out/share/system-config-printer/$2.py" + } + fixupWrapper scp-dbus-service scp-dbus-service + fixupWrapper system-config-printer system-config-printer + fixupWrapper system-config-printer-applet applet + # This __init__.py is both executed and imported. ( cd $out/share/system-config-printer/troubleshoot mv .__init__.py-wrapped __init__.py ) - - # Upstream issue: https://github.com/twaugh/system-config-printer/issues/28 - sed -i -e "s|/usr/bin|$out/bin|" "$out/share/dbus-1/services/org.fedoraproject.Config.Printing.service" ''; meta = { homepage = http://cyberelk.net/tim/software/system-config-printer/; platforms = stdenv.lib.platforms.linux; + license = stdenv.lib.licenses.gpl2; }; } diff --git a/pkgs/tools/misc/system-config-printer/detect_serverbindir.patch b/pkgs/tools/misc/system-config-printer/detect_serverbindir.patch new file mode 100644 index 000000000000..2cd3058f2330 --- /dev/null +++ b/pkgs/tools/misc/system-config-printer/detect_serverbindir.patch @@ -0,0 +1,17 @@ +diff --git a/cupshelpers/config.py.in b/cupshelpers/config.py.in +index 55abbfc..1244327 100644 +--- a/cupshelpers/config.py.in ++++ b/cupshelpers/config.py.in +@@ -22,3 +22,12 @@ + prefix="@prefix@" + sysconfdir="@sysconfdir@" + cupsserverbindir="@cupsserverbindir@" ++ ++try: ++ with open("/etc/cups/cups-files.conf") as config: ++ for cfgline in config: ++ args = cfgline.split(" ") ++ if len(args) == 2 and args[0] == "ServerBin": ++ cupsserverbindir = args[1].strip() ++except OSError: ++ pass From 3ade072aade5ba4ce4a09ce286f4229070926f22 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Thu, 21 Jan 2016 12:38:03 +0300 Subject: [PATCH 15/15] nixos changelog: mention CUPS changes --- .../doc/manual/release-notes/rl-unstable.xml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/nixos/doc/manual/release-notes/rl-unstable.xml b/nixos/doc/manual/release-notes/rl-unstable.xml index cd828dfc8887..ffe8171171ac 100644 --- a/nixos/doc/manual/release-notes/rl-unstable.xml +++ b/nixos/doc/manual/release-notes/rl-unstable.xml @@ -145,6 +145,26 @@ nginx.override { from the ELPA, MELPA, and MELPA Stable repositories. + + + CUPS, installed by services.printing module, now + has its data directory in /var/lib/cups. Old + configurations from /etc/cups are moved there + automatically, but there might be problems. Also configuration options + services.printing.cupsdConf and + services.printing.cupsdFilesConf were removed + because they had been allowing one to override configuration variables + required for CUPS to work at all on NixOS. For most use cases, + services.printing.extraConf and new option + services.printing.extraFilesConf should be enough; + if you encounter a situation when they are not, please file a bug. + + There are also Gutenprint improvements; in particular, a new option + services.printing.gutenprint is added to enable automatic + updating of Gutenprint PPMs; it's greatly recommended to enable it instead + of adding gutenprint to the drivers list. + +