From 56bc902b236bac6db8211ac8c48e441a82d84feb Mon Sep 17 00:00:00 2001 From: Yarny0 <41838844+Yarny0@users.noreply.github.com> Date: Tue, 19 Jul 2022 19:07:36 +0200 Subject: [PATCH] cups-pdf-to-pdf: init at unstable-2021-12-22 Note that cups-pdf refuses to run without root privileges. To use the binary, one has to either convince cups to call it with root privileges, or install it suid root. Also note that currently, this cups-pdf-fork produces small pdfs with selectable text, as promised. However, copying the text produces "garbled" text (characters are randomly reassigned). This is a known issue and I don't know how to fix it: https://github.com/alexivkin/CUPS-PDF-to-PDF/issues/7 --- .../cups/drivers/cups-pdf-to-pdf/default.nix | 59 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 61 insertions(+) create mode 100644 pkgs/misc/cups/drivers/cups-pdf-to-pdf/default.nix diff --git a/pkgs/misc/cups/drivers/cups-pdf-to-pdf/default.nix b/pkgs/misc/cups/drivers/cups-pdf-to-pdf/default.nix new file mode 100644 index 000000000000..f85925ea956d --- /dev/null +++ b/pkgs/misc/cups/drivers/cups-pdf-to-pdf/default.nix @@ -0,0 +1,59 @@ +{ lib +, stdenv +, fetchFromGitHub +, cups +, coreutils +}: + +stdenv.mkDerivation rec { + pname = "cups-pdf-to-pdf"; + version = "unstable-2021-12-22"; + + src = fetchFromGitHub { + owner = "alexivkin"; + repo = "CUPS-PDF-to-PDF"; + rev = "c14428c2ca8e95371daad7db6d11c84046b1a2d4"; + hash = "sha256-pa4PFf8OAFSra0hSazmKUfbMYL/cVWvYA1lBf7c7jmY="; + }; + + buildInputs = [ cups ]; + + postPatch = '' + sed -r 's|(gscall, size, ")cp |\1${coreutils}/bin/cp |' cups-pdf.c -i + ''; + + # gcc command line is taken from original cups-pdf's README file + # https://fossies.org/linux/cups-pdf/README + # however, we replace gcc with $CC following + # https://nixos.org/manual/nixpkgs/stable/#sec-darwin + buildPhase = '' + runHook preBuild + $CC -O9 -s cups-pdf.c -o cups-pdf -lcups + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + install -Dt $out/lib/cups/backend cups-pdf + install -Dm 0644 -t $out/etc/cups cups-pdf.conf + install -Dm 0644 -t $out/share/cups/model *.ppd + runHook postInstall + ''; + + meta = with lib; { + description = "A CUPS backend that turns print jobs into searchable PDF files"; + homepage = "https://github.com/alexivkin/CUPS-PDF-to-PDF"; + license = licenses.gpl2Only; + maintainers = [ maintainers.yarny ]; + longDescription = '' + cups-pdf is a CUPS backend that generates a PDF file for each print job and puts this file + into a folder on the local machine such that the print job's owner can access the file. + + https://www.cups-pdf.de/ + + cups-pdf-to-pdf is a fork of cups-pdf which tries hard to preserve the original text of the print job by avoiding rasterization. + + Note that in order to use this package, you have to make sure that the cups-pdf program is called with root privileges. + ''; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a5b66dd4bc25..d1ee6af2f670 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -36497,6 +36497,8 @@ with pkgs; cups-dymo = callPackage ../misc/cups/drivers/dymo {}; + cups-pdf-to-pdf = callPackage ../misc/cups/drivers/cups-pdf-to-pdf {}; + cups-toshiba-estudio = callPackage ../misc/cups/drivers/estudio {}; cups-zj-58 = callPackage ../misc/cups/drivers/zj-58 { };