summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorNicolas Benes <nbenes.gh@xandea.de>2022-11-12 01:01:42 +0100
committerNicolas Benes <nbenes.gh@xandea.de>2022-12-01 23:53:34 +0100
commit909cfd2b8dd8bd43078975043c5deceeb1cae492 (patch)
tree03929b2f113a1700dade585c27ba485c5adb77f0 /pkgs
parent9d84f4fe59d0d5dfcef5f0baf980862653177b36 (diff)
downloadnixpkgs-909cfd2b8dd8bd43078975043c5deceeb1cae492.tar
nixpkgs-909cfd2b8dd8bd43078975043c5deceeb1cae492.tar.gz
nixpkgs-909cfd2b8dd8bd43078975043c5deceeb1cae492.tar.bz2
nixpkgs-909cfd2b8dd8bd43078975043c5deceeb1cae492.tar.lz
nixpkgs-909cfd2b8dd8bd43078975043c5deceeb1cae492.tar.xz
nixpkgs-909cfd2b8dd8bd43078975043c5deceeb1cae492.tar.zst
nixpkgs-909cfd2b8dd8bd43078975043c5deceeb1cae492.zip
cups-kyodialog: 8.1601 -> 9.2-20220928
  * Rename `cups-kyodialog3` -> `cups-kyodialog`
  * Update from 8.1601 (2016) to 9.2 (2022) with support for more and
    recent printer models (170 vs. 373 PPD files)
  * Make Qt GUI optional to reduce closure size, Qt4 -> Qt5
  * Avoid full paths to kyodialog filters in PPD files. A PPD file is
    copied to /etc/cups/ppd/ for each configured printer and is not
    updated when the cups-kyodialog package is updated, thus,
    potentially creating dangling references to /nix/store or invoking
    the old version of the cups filters.
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/misc/cups/drivers/kyodialog/default.nix106
-rw-r--r--pkgs/misc/cups/drivers/kyodialog3/default.nix62
-rw-r--r--pkgs/top-level/aliases.nix1
-rw-r--r--pkgs/top-level/all-packages.nix2
4 files changed, 108 insertions, 63 deletions
diff --git a/pkgs/misc/cups/drivers/kyodialog/default.nix b/pkgs/misc/cups/drivers/kyodialog/default.nix
new file mode 100644
index 00000000000..7137b5df56b
--- /dev/null
+++ b/pkgs/misc/cups/drivers/kyodialog/default.nix
@@ -0,0 +1,106 @@
+{ lib
+, stdenv
+, fetchzip
+, cups
+, autoPatchelfHook
+, python3Packages
+
+# Sets the default paper format: use "EU" for A4, or "Global" for Letter
+, region ? "EU"
+# optional GUI, quite redundant to CUPS admin web GUI
+, withQtGui ? false
+, qt5
+}:
+
+# Open issues:
+#
+# Printing in grayscale mode (e.g. the test page) generates a warning
+# > [Job 59] Grayscale/monochrome printing requested for this job but Poppler is not able to convert to grayscale/monochrome PostScript.
+# > [Job 59] Use \"pdftops-renderer\" option (see cups-filters README file) to use Ghostscript or MuPDF for the PDF -> PostScript conversion.
+#
+# This is related to https://github.com/OpenPrinting/cups-filters/issues/169.
+
+assert region == "Global" || region == "EU";
+
+let
+  kyodialog_version = "9.2";
+  date = "20220928";
+in
+stdenv.mkDerivation rec {
+  pname = "cups-kyodialog";
+  version = "${kyodialog_version}-${date}";
+
+  dontStrip = true;
+
+  src = fetchzip {
+    urls = [
+      "https://www.kyoceradocumentsolutions.us/content/download-center-americas/us/drivers/drivers/KyoceraLinuxPackages_${date}_tar_gz.download.gz"
+      "https://web.archive.org/web/20221122230412/https://www.kyoceradocumentsolutions.us/content/download-center-americas/us/drivers/drivers/KyoceraLinuxPackages_${date}_tar_gz.download.gz"
+    ];
+    sha256 = "sha256-WCHuAQO2T6S8JtRsI2Yf/ypeCLMH365Ax/qX+Ah2s3k=";
+    extension = "tar.gz";
+    stripRoot = false;
+    postFetch = ''
+      # delete redundant Linux package dirs to reduce size in the Nix store; only keep Debian
+      rm -r $out/{CentOS,Fedora,OpenSUSE,Redhat,Ubuntu}
+    '';
+  };
+
+  sourceRoot = ".";
+
+  unpackCmd = let
+    platforms = {
+      x86_64-linux = "amd64";
+      i686-linux = "i386";
+    };
+    platform = platforms.${stdenv.hostPlatform.system} or (throw "unsupported system: ${stdenv.hostPlatform.system}");
+  in ''
+    ar p "$src/Debian/${region}/kyodialog_${platform}/kyodialog_${kyodialog_version}-0_${platform}.deb" data.tar.gz | tar -xz
+  '';
+
+  nativeBuildInputs = [ autoPatchelfHook python3Packages.wrapPython ]
+  ++ lib.optionals withQtGui [ qt5.wrapQtAppsHook ];
+
+  buildInputs = [ cups ] ++ lib.optionals withQtGui [ qt5.qtbase ];
+
+  # For lib/cups/filter/kyofilter_pre_H.
+  # The source already contains a copy of pypdf3, but we use the Nix package
+  propagatedBuildInputs = with python3Packages; [ reportlab pypdf3 setuptools ];
+
+  installPhase = ''
+    # allow cups to find the ppd files
+    mkdir -p $out/share/cups/model
+    mv ./usr/share/kyocera${kyodialog_version}/ppd${kyodialog_version} $out/share/cups/model/Kyocera
+
+    # remove absolute path prefixes to filters in ppd
+    find $out -name "*.ppd" -exec sed -E -i "s:/usr/lib/cups/filter/::g" {} \;
+
+
+    mkdir -p $out/lib/cups/
+    mv ./usr/lib/cups/filter/ $out/lib/cups/
+    # for lib/cups/filter/kyofilter_pre_H
+    wrapPythonProgramsIn $out/lib/cups/filter "$propagatedBuildInputs"
+
+
+    install -Dm444 usr/share/doc/kyodialog/copyright $out/share/doc/${pname}/copyright
+  '' + lib.optionalString withQtGui ''
+    install -D usr/bin/kyoPPDWrite_H $out/bin/kyoPPDWrite_H
+    install -D usr/bin/kyodialog${kyodialog_version} $out/bin/kyodialog
+
+    install -Dm444 usr/share/kyocera${kyodialog_version}/appicon_H.png $out/share/${pname}/icons/appicon_H.png
+
+    install -Dm444 usr/share/applications/kyodialog${kyodialog_version}.desktop $out/share/applications/kyodialog.desktop
+    substituteInPlace $out/share/applications/kyodialog.desktop \
+      --replace Exec=\"/usr/bin/kyodialog${kyodialog_version}\" Exec=\"$out/bin/kyodialog\" \
+      --replace Icon=/usr/share/kyocera/appicon_H.png Icon=$out/share/${pname}/icons/appicon_H.png
+  '';
+
+  meta = with lib; {
+    description = "CUPS drivers for several Kyocera printers";
+    homepage = "https://www.kyoceradocumentsolutions.com";
+    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
+    license = licenses.unfree;
+    maintainers = [ maintainers.steveej ];
+    platforms = [ "i686-linux" "x86_64-linux" ];
+  };
+}
diff --git a/pkgs/misc/cups/drivers/kyodialog3/default.nix b/pkgs/misc/cups/drivers/kyodialog3/default.nix
deleted file mode 100644
index 7eeae6daa53..00000000000
--- a/pkgs/misc/cups/drivers/kyodialog3/default.nix
+++ /dev/null
@@ -1,62 +0,0 @@
-{ stdenv, lib, fetchzip, cups, autoPatchelfHook
-
-  # Can either be "EU" or "Global"; it's unclear what the difference is
-  , region ? "Global", qt4
-}:
-
-let
-  platform =
-    if stdenv.hostPlatform.system == "x86_64-linux" then "64bit"
-    else if stdenv.hostPlatform.system == "i686-linux" then "32bit"
-         else throw "Unsupported system: ${stdenv.hostPlatform.system}";
-  debPlatform =
-    if platform == "64bit" then "amd64"
-    else "i386";
-  debRegion = if region == "EU" then "EU." else "";
-in
-stdenv.mkDerivation rec {
-  pname = "cups-kyodialog3";
-  version = "8.1601";
-
-  dontStrip = true;
-
-  src = fetchzip {
-    url = "https://www.kyoceradocumentsolutions.us/content/download-center-americas/us/drivers/drivers/Kyocera_Linux_PPD_Ver_${lib.replaceChars ["."] ["_"] version}_tar_gz.download.gz";
-    sha256 = "11znnlkfssakml7w80gxlz1k59f3nvhph91fkzzadnm9i7a8yjal";
-  };
-
-  nativeBuildInputs = [ autoPatchelfHook ];
-
-  buildInputs = [ cups qt4 ];
-
-  installPhase = ''
-    mkdir -p $out
-    cd $out
-
-    # unpack the debian archive
-    ar p ${src}/KyoceraLinuxPackages/${region}/${platform}/kyodialog3.en${debRegion}_0.5-0_${debPlatform}.deb data.tar.gz | tar -xz
-    rm -Rf KyoceraLinuxPackages
-
-    # strip $out/usr
-    mv usr/* .
-    rmdir usr
-
-    # allow cups to find the ppd files
-    mkdir -p share/cups/model
-    mv share/ppd/kyocera share/cups/model/Kyocera
-    rmdir share/ppd
-
-    # prepend $out to all references in ppd and desktop files
-    find -name "*.ppd" -exec sed -E -i "s:/usr/lib:$out/lib:g" {} \;
-    find -name "*.desktop" -exec sed -E -i "s:/usr/lib:$out/lib:g" {} \;
-  '';
-
-  meta = with lib; {
-    description = "CUPS drivers for several Kyocera printers";
-    homepage = "https://www.kyoceradocumentsolutions.com";
-    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
-    license = licenses.unfree;
-    maintainers = [ maintainers.steveej ];
-    platforms = platforms.linux;
-  };
-}
diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix
index 3894b850d8e..9f559df75cd 100644
--- a/pkgs/top-level/aliases.nix
+++ b/pkgs/top-level/aliases.nix
@@ -301,6 +301,7 @@ mapAliases ({
   cloud-print-connector = throw "Google Cloudprint is officially discontinued since Jan 2021, more info https://support.google.com/chrome/a/answer/9633006";
   cquery = throw "cquery has been removed because it is abandoned by upstream. Consider switching to clangd or ccls instead"; # Added 2020-06-15
   cups-googlecloudprint = throw "Google Cloudprint is officially discontinued since Jan 2021, more info https://support.google.com/chrome/a/answer/9633006";
+  cups-kyodialog3 = cups-kyodialog; # Added 2022-11-12
   cupsBjnp = throw "'cupsBjnp' has been renamed to/replaced by 'cups-bjnp'"; # Converted to throw 2022-02-22
   cups_filters = throw "'cups_filters' has been renamed to/replaced by 'cups-filters'"; # Converted to throw 2022-02-22
   curlcpp = throw "curlcpp has been removed, no active maintainers and no usage within nixpkgs"; # Added 2022-05-10
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 561df7c4bea..be07a8a5051 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -36421,7 +36421,7 @@ with pkgs;
 
   cups-kyocera-ecosys-m552x-p502x = callPackage ../misc/cups/drivers/kyocera-ecosys-m552x-p502x {};
 
-  cups-kyodialog3 = callPackage ../misc/cups/drivers/kyodialog3 {};
+  cups-kyodialog = callPackage ../misc/cups/drivers/kyodialog {};
 
   cups-dymo = callPackage ../misc/cups/drivers/dymo {};