cups-pdf(-to-pdf): init#182360
Conversation
There was a problem hiding this comment.
Consider registrating as cups-pdf-to-pdf instead.
|
Dear @nrdsp , adding a |
There was a problem hiding this comment.
The package seems to build on my machine, even if it complained about some functions being deprecated (opened issue upstream).
I would rather use the |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review/3032/1070 |
425b383 to
e758e01
Compare
|
Thanks @SuperSandro2000 for your suggestions. The most recent branch should now incorporate all of them. |
Rebased onto current |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
There was a problem hiding this comment.
Isn't this relative to root or your current user?
There was a problem hiding this comment.
I'm not sure what you mean with this question.
The cups-pdf documentation of this config directive doesn't say anything specific about relative paths. From looking at the code, I suspect a relative path would just be interpreted relative to the CWD. According to the documentation (and code), ${HOME} and ${USER} are special tokens that will be expanded to the print job owner's home directory and name, respectively. I expanded the documentation of that option a bit to explain it better.
|
Thanks again for your review, @SuperSandro2000 . I hope I could answer all your questions. The brach is also rebased onto current |
|
Can you move the release notes to 23.05 ? |
d065a54 to
fee623a
Compare
Done. Also rebased onto current |
There was a problem hiding this comment.
This fails on Darwin, which is definitely something that can be used there I think.
There was a problem hiding this comment.
Hmmmm, I don't know much about Darwin. Following the first hint in https://nixos.org/manual/nixpkgs/stable/#sec-darwin , I replaced gcc with $CC. Hopefully, this calls clang and the command line still works. On x86_64-linux, the package still builds fine with this change (and the test passes).
Can you try if this works on Darwin.
There was a problem hiding this comment.
According to OfBorg, this works on Darwin: https://logs.nix.ci/?key=nixos/nixpkgs.182360&attempt_id=e17af287-4a25-4e81-bc11-09cf5d8e3f13
|
Alas, release notes conflicts :'( ; please fix the conflicts and I think we are good to merge. |
|
Rebased onto current |
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: alexivkin/CUPS-PDF-to-PDF#7
Some implementation notes:
* cups-pdf, and cups-pdf-to-pdf,
support multiple instances with differing configurations.
This can be accomplished by creating multiple configuration
files with names `cups-pdf-{instance-name}.conf`.
The Nixos module supports this feature by providing
the option `instances` which is an attrset
mapping instance names to instance configurations.
To simplify module usage,
an instance `pdf` is created by default.
* To use a cups-pdf instance, one also needs
a cups queue that connects to the backend.
The module does this automatically by default,
using the `hardware.printers.ensurePrinters`.
It uses one of the ppd files which is
included in the cups-pdf package.
If this isn't desired (e.g. because printer queues
should be created by hand, or configured differently),
the `installPrinter` option can be turned off
(for each instance separately).
* In our configuration, cups calls external programs
using the `cups` account and the `lp` group.
cups-pdf refuses to operate without root privileges,
likely because it needs to change the
ownership of it output pdf files so that
(only) the print job's owner can access them.
The module installs a suid root wrapper for the backend
program that can only be called by the `lp` group.
The cups-pdf package is replaced by a wrapper
package which calls the suid root wrapper.
So cups can call its backend programs as usual.
|
Rebased onto |
|
BTW, naive question but, you wrote:
Does that mean this package provide zero value with respect to its main feature? |
This depends on what is considered the main feature, but if the main feature is text-searchable pdf-files, then sadly yes. |
|
This is a good candidate for a more general nixpkgs warning (NixOS/rfcs#127), but I think it's fine. |
Description of changes
Implements the package request in #173745
cups-pdf is a cups printer backend that turns print jobs into pdf files.
This does not package cups-pdf from https://www.cups-pdf.de/, but a fork cups-pdf-to-pdf from https://github.com/alexivkin/CUPS-PDF-to-PDF . It claims to try harder to preserve searchable text in pdf files where the original cups-pdf rasterizes pdf files producing large pdf files with embedded images.
https://github.com/alexivkin/CUPS-PDF-to-PDF/blob/c14428c2ca8e95371daad7db6d11c84046b1a2d4/README.md
https://bugs.launchpad.net/ubuntu/+source/cups-pdf/+bug/366949
A NixOS module is included that, if enabled, installs a cups-pdf printer backend and a cups queue for that printer so that one can print to pdf without further ado. The module is quite flexible: It permits to install several cups-pdf backend "instances" (so one can use different configurations), and it can be told not to install a cups queue, so the user can install one or even several queues (again with varying configurations) if needed.
Note that cups calls its backend processes with an ordinary user account, but cups-pdf wants to be called with root privileges because it assigns the print job's owner as ownership to the produced files. Since we don't want to change the cups configuration so that it calls every program with root privileges, this NixOS module installs a suid root wrapper. The wrapper is configured such that only cups (only the
lpgroup) can call it.A NixOS test is also added that uses cups-pdf to generate pdf files, then checks if they contain the printed text.
Note that currently, cups-pdf-to-pdf produces small and searchable pdf files, but the text is "garbled", i.e., characters are reassigned randomly. This is a known issue and I don't know how to fix it:
Again garbled text also with the current code base alexivkin/CUPS-PDF-to-PDF#7
So the test checks the pdf by rasterizing it, then applies OCR.
As there is already a package request (see above), this change might warrant a mention in the release notes.
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)nixos/doc/manual/md-to-db.shto update generated release notesResult of
nixpkgs-reviewrun on x86_64-linux 11 package blacklisted:
1 package built:
References