summary refs log tree commit diff
path: root/pkgs/misc
diff options
context:
space:
mode:
authorOrivej Desh <orivej@gmx.fr>2017-12-04 17:52:29 +0000
committerOrivej Desh <orivej@gmx.fr>2017-12-07 07:22:39 +0000
commitbf0d121aed383b03c486ce280341e538835649c0 (patch)
treed71a359469f8cf63c7980b01f4b51510b677dcdb /pkgs/misc
parente5715d94645a46c26d09c633214e5421db758d2c (diff)
downloadnixlib-bf0d121aed383b03c486ce280341e538835649c0.tar
nixlib-bf0d121aed383b03c486ce280341e538835649c0.tar.gz
nixlib-bf0d121aed383b03c486ce280341e538835649c0.tar.bz2
nixlib-bf0d121aed383b03c486ce280341e538835649c0.tar.lz
nixlib-bf0d121aed383b03c486ce280341e538835649c0.tar.xz
nixlib-bf0d121aed383b03c486ce280341e538835649c0.tar.zst
nixlib-bf0d121aed383b03c486ce280341e538835649c0.zip
cups: fix configure flags
Diffstat (limited to 'pkgs/misc')
-rw-r--r--pkgs/misc/cups/default.nix51
1 files changed, 31 insertions, 20 deletions
diff --git a/pkgs/misc/cups/default.nix b/pkgs/misc/cups/default.nix
index 9d8134d21561..db344b32d218 100644
--- a/pkgs/misc/cups/default.nix
+++ b/pkgs/misc/cups/default.nix
@@ -1,5 +1,5 @@
-{ stdenv, fetchurl, fetchpatch, pkgconfig, zlib, libjpeg, libpng, libtiff, pam
-, dbus, systemd, acl, gmp, darwin
+{ stdenv, fetchurl, fetchpatch, pkgconfig, removeReferencesTo
+, zlib, libjpeg, libpng, libtiff, pam, dbus, systemd, acl, gmp, darwin
 , libusb ? null, gnutls ? null, avahi ? null, libpaper ? null
 }:
 
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
     })
   ];
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig removeReferencesTo ];
 
   buildInputs = [ zlib libjpeg libpng libtiff libusb gnutls libpaper ]
     ++ optionals stdenv.isLinux [ avahi pam dbus systemd acl ]
@@ -38,17 +38,9 @@ stdenv.mkDerivation rec {
   propagatedBuildInputs = [ gmp ];
 
   configureFlags = [
-    # Put just lib/* and locale into $lib; this didn't work directly.
-    # lib/cups is moved back to $out in postInstall.
-    # Beware: some parts of cups probably don't fully respect these.
-    "--prefix=$(lib)"
-    "--datadir=$(out)/share"
-    "--localedir=$(lib)/share/locale"
-
     "--localstatedir=/var"
     "--sysconfdir=/etc"
     "--with-rundir=/run"
-    "--with-systemd=\${out}/lib/systemd/system"
     "--enable-raw-printing"
     "--enable-threads"
   ] ++ optionals stdenv.isLinux [
@@ -58,10 +50,24 @@ stdenv.mkDerivation rec {
     ++ optional (gnutls != null) "--enable-ssl"
     ++ optional (avahi != null) "--enable-avahi"
     ++ optional (libpaper != null) "--enable-libpaper"
-    ++ optionals stdenv.isDarwin [
-    "--with-bundledir=$out"
-    "--disable-launchd"
-  ];
+    ++ optional stdenv.isDarwin "--disable-launchd";
+
+  preConfigure = ''
+    configureFlagsArray+=(
+      # Put just lib/* and locale into $lib; this didn't work directly.
+      # lib/cups is moved back to $out in postInstall.
+      # Beware: some parts of cups probably don't fully respect these.
+      "--prefix=$lib"
+      "--datadir=$out/share"
+      "--localedir=$lib/share/locale"
+
+      "--with-systemd=$out/lib/systemd/system"
+
+      ${optionalString stdenv.isDarwin ''
+        "--with-bundledir=$out"
+      ''}
+    )
+  '';
 
   installFlags =
     [ # Don't try to write in /var at build time.
@@ -84,21 +90,26 @@ stdenv.mkDerivation rec {
   enableParallelBuilding = true;
 
   postInstall = ''
-      moveToOutput lib/cups "$out"
+      libexec=${if stdenv.isDarwin then "libexec/cups" else "lib/cups"}
+      moveToOutput $libexec "$out"
+
+      # $lib contains references to $out/share/cups.
+      # CUPS is working without them, so they are not vital.
+      find "$lib" -type f -exec grep -q "$out" {} \; \
+           -printf "removing references from %p\n" \
+           -exec remove-references-to -t "$out" {} +
 
       # Delete obsolete stuff that conflicts with cups-filters.
       rm -rf $out/share/cups/banners $out/share/cups/data/testprint
 
-      # Some outputs in cups-config were unexpanded and some even wrong.
       moveToOutput bin/cups-config "$dev"
-      sed -e "/^cups_serverbin=/s|\$(lib)|$out|" \
-          -e "s|\$(out)|$out|" \
-          -e "s|\$(lib)|$lib|" \
+      sed -e "/^cups_serverbin=/s|$lib|$out|" \
           -i "$dev/bin/cups-config"
 
       # Rename systemd files provided by CUPS
       for f in "$out"/lib/systemd/system/*; do
         substituteInPlace "$f" \
+          --replace "$lib/$libexec" "$out/$libexec" \
           --replace "org.cups.cupsd" "cups" \
           --replace "org.cups." ""