diff options
author | Thomas Tuegel <ttuegel@mailbox.org> | 2017-09-20 17:03:12 -0500 |
---|---|---|
committer | Thomas Tuegel <ttuegel@mailbox.org> | 2017-09-20 17:03:12 -0500 |
commit | 1e2ebee42a717b27c02539c7ee2e0ec37712834f (patch) | |
tree | aaff0751f6322a3d4e9b682d71e06ff3a7a2bb46 /pkgs/misc/drivers | |
parent | 5ab37fb913554e749ffd389dd6190c8b92d3ca31 (diff) |
hplip: fix Python wrappers
We cannot rely on wrapPythonPrograms to wrap the installed executables because
they are symlinks (which it ignores). Instead, we have to emulate it to make
the wrappers ourselves.
Diffstat (limited to 'pkgs/misc/drivers')
-rw-r--r-- | pkgs/misc/drivers/hplip/default.nix | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/pkgs/misc/drivers/hplip/default.nix b/pkgs/misc/drivers/hplip/default.nix index 22f7080611fb..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 \ @@ -145,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. |