9 # Sets the default paper format: use "EU" for A4, or "Global" for Letter
11 # optional GUI, quite redundant to CUPS admin web GUI
18 # Printing in grayscale mode (e.g. the test page) generates a warning
19 # > [Job 59] Grayscale/monochrome printing requested for this job but Poppler is not able to convert to grayscale/monochrome PostScript.
20 # > [Job 59] Use \"pdftops-renderer\" option (see cups-filters README file) to use Ghostscript or MuPDF for the PDF -> PostScript conversion.
22 # This is related to https://github.com/OpenPrinting/cups-filters/issues/169.
24 assert region == "Global" || region == "EU";
27 kyodialog_version = "9.3";
30 stdenv.mkDerivation rec {
31 pname = "cups-kyodialog";
32 version = "${kyodialog_version}-${date}";
37 # Steps to find the release download URL:
38 # 1. Go to https://www.kyoceradocumentsolutions.us/en/support/downloads.html
39 # 2. Search for printer model, e.g. "TASKalfa 6053ci"
40 # 3. Locate e.g. "Linux Print Driver (9.3)" in the list
42 "https://www.kyoceradocumentsolutions.us/content/download-center-americas/us/drivers/drivers/KyoceraLinuxPackages_${date}_tar_gz.download.gz"
43 "https://web.archive.org/web/20231021143259/https://www.kyoceradocumentsolutions.us/content/download-center-americas/us/drivers/drivers/KyoceraLinuxPackages_${date}_tar_gz.download.gz"
45 hash = "sha256-3h2acOmaQIiqe2Fd9QiqEfre5TrxzRrll6UlUruwj1o=";
49 # delete redundant Linux package dirs to reduce size in the Nix store; only keep Debian
50 rm -r $out/{CentOS,Fedora,OpenSUSE,Redhat,Ubuntu}
59 x86_64-linux = "amd64";
63 platforms.${stdenv.hostPlatform.system}
64 or (throw "unsupported system: ${stdenv.hostPlatform.system}");
67 ar p "$src/Debian/${region}/kyodialog_${platform}/kyodialog_${kyodialog_version}-0_${platform}.deb" data.tar.gz | tar -xz
72 python3Packages.wrapPython
73 ] ++ lib.optionals withQtGui [ qt5.wrapQtAppsHook ];
75 buildInputs = [ cups ] ++ lib.optionals withQtGui [ qt5.qtbase ];
77 # For lib/cups/filter/kyofilter_pre_H.
78 # The source already contains a copy of pypdf3, but we use the Nix package
79 propagatedBuildInputs = with python3Packages; [
87 # allow cups to find the ppd files
88 mkdir -p $out/share/cups/model
89 mv ./usr/share/kyocera${kyodialog_version}/ppd${kyodialog_version} $out/share/cups/model/Kyocera
91 # remove absolute path prefixes to filters in ppd
92 find $out -name "*.ppd" -exec sed -E -i "s:/usr/lib/cups/filter/::g" {} \;
95 mkdir -p $out/lib/cups/
96 mv ./usr/lib/cups/filter/ $out/lib/cups/
97 # for lib/cups/filter/kyofilter_pre_H
98 wrapPythonProgramsIn $out/lib/cups/filter "$propagatedBuildInputs"
101 install -Dm444 usr/share/doc/kyodialog/copyright $out/share/doc/${pname}/copyright
103 + lib.optionalString withQtGui ''
104 install -D usr/bin/kyoPPDWrite_H $out/bin/kyoPPDWrite_H
105 install -D usr/bin/kyodialog${kyodialog_version} $out/bin/kyodialog
107 install -Dm444 usr/share/kyocera${kyodialog_version}/appicon_H.png $out/share/${pname}/icons/appicon_H.png
109 install -Dm444 usr/share/applications/kyodialog${kyodialog_version}.desktop $out/share/applications/kyodialog.desktop
110 substituteInPlace $out/share/applications/kyodialog.desktop \
111 --replace Exec=\"/usr/bin/kyodialog${kyodialog_version}\" Exec=\"$out/bin/kyodialog\" \
112 --replace Icon=/usr/share/kyocera/appicon_H.png Icon=$out/share/${pname}/icons/appicon_H.png
116 description = "CUPS drivers for several Kyocera printers";
117 homepage = "https://www.kyoceradocumentsolutions.com";
118 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
119 license = licenses.unfree;
120 maintainers = [ maintainers.steveej ];