mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-25 03:17:13 +00:00
4f0dadbf38
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
48 lines
1.8 KiB
Nix
48 lines
1.8 KiB
Nix
import ./make-test-python.nix (
|
|
{ lib, pkgs, ... }:
|
|
{
|
|
name = "cups-pdf";
|
|
|
|
nodes.machine =
|
|
{ pkgs, ... }:
|
|
{
|
|
imports = [ ./common/user-account.nix ];
|
|
environment.systemPackages = [ pkgs.poppler_utils ];
|
|
fonts.packages = [ pkgs.dejavu_fonts ]; # yields more OCR-able pdf
|
|
services.printing.cups-pdf.enable = true;
|
|
services.printing.cups-pdf.instances = {
|
|
opt = { };
|
|
noopt.installPrinter = false;
|
|
};
|
|
hardware.printers.ensurePrinters = [
|
|
{
|
|
name = "noopt";
|
|
model = "CUPS-PDF_noopt.ppd";
|
|
deviceUri = "cups-pdf:/noopt";
|
|
}
|
|
];
|
|
};
|
|
|
|
# we cannot check the files with pdftotext, due to
|
|
# https://github.com/alexivkin/CUPS-PDF-to-PDF/issues/7
|
|
# we need `imagemagickBig` as it has ghostscript support
|
|
|
|
testScript = ''
|
|
from subprocess import run
|
|
machine.wait_for_unit("multi-user.target")
|
|
for name in ("opt", "noopt"):
|
|
text = f"test text {name}".upper()
|
|
machine.wait_until_succeeds(f"lpstat -v {name}")
|
|
machine.succeed(f"su - alice -c 'echo -e \"\n {text}\" | lp -d {name}'")
|
|
# wait until the pdf files are completely produced and readable by alice
|
|
machine.wait_until_succeeds(f"su - alice -c 'pdfinfo /var/spool/cups-pdf-{name}/users/alice/*.pdf'")
|
|
machine.succeed(f"cp /var/spool/cups-pdf-{name}/users/alice/*.pdf /tmp/{name}.pdf")
|
|
machine.copy_from_vm(f"/tmp/{name}.pdf", "")
|
|
run(f"${pkgs.imagemagickBig}/bin/convert -density 300 $out/{name}.pdf $out/{name}.jpeg", shell=True, check=True)
|
|
assert text.encode() in run(f"${lib.getExe pkgs.tesseract} $out/{name}.jpeg stdout", shell=True, check=True, capture_output=True).stdout
|
|
'';
|
|
|
|
meta.maintainers = [ lib.maintainers.yarny ];
|
|
}
|
|
)
|