about summary refs log tree commit diff
path: root/pkgs/misc
diff options
context:
space:
mode:
authorThomas Tuegel <ttuegel@secure.mailbox.org>2017-09-21 11:19:27 -0500
committerGitHub <noreply@github.com>2017-09-21 11:19:27 -0500
commit5f328b33abefca6bedd8b204a752c27318af4348 (patch)
tree20c56099e213106debfc2179dee7d7a094c5bd2d /pkgs/misc
parenta127f91f284ec001db70e92d487abcbbac7cde5f (diff)
parent1e2ebee42a717b27c02539c7ee2e0ec37712834f (diff)
downloadnixlib-5f328b33abefca6bedd8b204a752c27318af4348.tar
nixlib-5f328b33abefca6bedd8b204a752c27318af4348.tar.gz
nixlib-5f328b33abefca6bedd8b204a752c27318af4348.tar.bz2
nixlib-5f328b33abefca6bedd8b204a752c27318af4348.tar.lz
nixlib-5f328b33abefca6bedd8b204a752c27318af4348.tar.xz
nixlib-5f328b33abefca6bedd8b204a752c27318af4348.tar.zst
nixlib-5f328b33abefca6bedd8b204a752c27318af4348.zip
Merge pull request #29616 from ttuegel/hplip
HPLIP: Fix PostScript printers, installed utilities
Diffstat (limited to 'pkgs/misc')
-rw-r--r--pkgs/misc/drivers/hplip/default.nix32
1 files changed, 27 insertions, 5 deletions
diff --git a/pkgs/misc/drivers/hplip/default.nix b/pkgs/misc/drivers/hplip/default.nix
index 6adc2a765c7f..9342c547a17e 100644
--- a/pkgs/misc/drivers/hplip/default.nix
+++ b/pkgs/misc/drivers/hplip/default.nix
@@ -61,10 +61,9 @@ pythonPackages.buildPythonApplication {
 
   nativeBuildInputs = [
     pkgconfig
-    makeWrapper
   ];
 
-  propagatedBuildInputs = with pythonPackages; [
+  pythonPath = with pythonPackages; [
     dbus
     pillow
     pygobject2
@@ -74,6 +73,8 @@ pythonPackages.buildPythonApplication {
     pyqt4
   ];
 
+  makeWrapperArgs = [ ''--prefix PATH : "${nettools}/bin"'' ];
+
   prePatch = ''
     # HPLIP hardcodes absolute paths everywhere. Nuke from orbit.
     find . -type f -exec sed -i \
@@ -88,6 +89,7 @@ pythonPackages.buildPythonApplication {
 
   preConfigure = ''
     export configureFlags="$configureFlags
+      --with-hpppddir=$out/share/cups/model/HP
       --with-cupsfilterdir=$out/lib/cups/filter
       --with-cupsbackenddir=$out/lib/cups/backend
       --with-icondir=$out/share/applications
@@ -144,10 +146,30 @@ pythonPackages.buildPythonApplication {
     rm $out/etc/udev/rules.d/56-hpmud.rules
   '';
 
-  postFixup = ''
-    wrapProgram $out/lib/cups/filter/hpps \
-      --prefix PATH : "${nettools}/bin"
+  # The installed executables are just symlinks into $out/share/hplip,
+  # but wrapPythonPrograms ignores symlinks. We cannot replace the Python
+  # modules in $out/share/hplip with wrapper scripts because they import
+  # each other as libraries. Instead, we emulate wrapPythonPrograms by
+  # 1. Calling patchPythonProgram on the original script in $out/share/hplip
+  # 2. Making our own wrapper pointing directly to the original script.
+  dontWrapPythonPrograms = true;
+  preFixup = ''
+    buildPythonPath "$out $pythonPath"
+
+    for bin in $out/bin/*; do
+      py=$(readlink -m $bin)
+      rm $bin
+      echo "patching \`$py'..."
+      patchPythonScript "$py"
+      echo "wrapping \`$bin'..."
+      makeWrapper "$py" "$bin" \
+          --prefix PATH ':' "$program_PATH" \
+          --set PYTHONNOUSERSITE "true" \
+          $makeWrapperArgs
+    done
+  '';
 
+  postFixup = ''
     substituteInPlace $out/etc/hp/hplip.conf --replace /usr $out
   '' + stdenv.lib.optionalString (!withPlugin) ''
     # A udev rule to notify users that they need the binary plugin.