hplip: fix hp-setup crash by adding proper NixOS PPD search path

HPLIP's getSystemPPDs() function relies on searching for PPDs below common FHS
paths.  None of these exist on NixOS, but the code assumes that at least one of
the directories will be found, and crashes when it doesn't (cups_ppd_path is
None and the code passes that to os.path.join).

A usable PPD search path for the running system on NixOS is
/var/lib/cups/path/share, so this patches the source to check this path as well.
This should fix the NixOS case and keep non-NixOS cases working too.
This commit is contained in:
Bryan Gardiner 2021-01-08 20:20:00 -08:00
parent 58ce91234f
commit 60df55c9fb
No known key found for this signature in database
GPG key ID: 53EFBCA063E6183C
2 changed files with 30 additions and 0 deletions

View file

@ -93,6 +93,12 @@ python3Packages.buildPythonApplication {
# https://bugs.launchpad.net/hplip/+bug/1788706
# https://bugs.launchpad.net/hplip/+bug/1787289
./image-processor.patch
# HPLIP's getSystemPPDs() function relies on searching for PPDs below common FHS
# paths, and hp-setup crashes if none of these paths actually exist (which they
# don't on NixOS). Add the equivalent NixOS path, /var/lib/cups/path/share.
# See: https://github.com/NixOS/nixpkgs/issues/21796
./hplip-3.20.11-nixos-cups-ppd-search-path.patch
];
prePatch = ''

View file

@ -0,0 +1,24 @@
From: Bryan Gardiner <bog@khumba.net>
Date: Sat, 9 Jan 2021 16:51:20 -0800
Subject: [PATCH] Add NixOS CUPS PPD search path.
---
base/g.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/base/g.py b/base/g.py
index f73e23f..758f339 100644
--- a/base/g.py
+++ b/base/g.py
@@ -283,7 +283,7 @@ prop.max_message_len = 8192
prop.max_message_read = 65536
prop.read_timeout = 90
-prop.ppd_search_path = '/usr/share;/usr/local/share;/usr/lib;/usr/local/lib;/usr/libexec;/opt;/usr/lib64'
+prop.ppd_search_path = '/var/lib/cups/path/share;/usr/share;/usr/local/share;/usr/lib;/usr/local/lib;/usr/libexec;/opt;/usr/lib64'
prop.ppd_search_pattern = 'HP-*.ppd.*'
prop.ppd_download_url = 'http://www.linuxprinting.org/ppd-o-matic.cgi'
prop.ppd_file_suffix = '-hpijs.ppd'
--
2.29.2