Skip to content

feat(standards): add the pdfkiln wkhtmltopdf replacement - #85

Merged
batonac merged 1 commit into
mainfrom
feat/pdfkiln-package
Nov 23, 2026
Merged

batonac merged 1 commit into
mainfrom
feat/pdfkiln-package

Conversation

@batonac

@batonac batonac commented Nov 23, 2026

Copy link
Copy Markdown
Member

Summary

Adds packages/pdfkiln.nix: @pdfkiln/pdfkiln 1.3.0 from the npm registry, pinned by its sha512 and unpacked as published. It is a drop-in replacement for wkhtmltopdf. Its three commands (wkhtmltopdf, wkhtmltoimage, pdfkiln) run on nixpkgs' Node.js 24. Each wrapper sets PDFKILN_CHROMIUM, which selects the browser, so pdfkiln never downloads one.

  • flake.nix: packages = lib.mapAttrs (_: path: pkgs.callPackage path { }) (entries ./packages); next to checks, using the existing entries helper.
  • checks/pdfkiln.nix: builds the package. It requires wkhtmltopdf --version to report "with patched qt". On Linux it also requires the wrapper to set PDFKILN_CHROMIUM to nixpkgs' chromium, and it renders a PDF inside the build sandbox with pdfkiln's own settings. No sandbox flags were added.
  • docs/library.md: a Packages entry, and the packages/<name>.nix rule in the directory paragraph.

No lock file and no build step of ours. The source is the npm tarball. nixpkgs is the flake's existing pin, d4f25a3e562008648d45bcf2d70bcc7422cad84e, which is the spike's rev. Hardening profiles and the consumer repos are unchanged.

Browser per platform

Platform Browser (nixpkgs) Wrapper sets Status here
x86_64-linux chromium 157.0.8103.50 PDFKILN_CHROMIUM=.../bin/chromium built; check builds and renders
aarch64-linux chromium (same) same built under binfmt emulation on the x86_64 host, not on native hardware; check not built
aarch64-darwin google-chrome 157.0.8103.51, wrapper google-chrome-stable PDFKILN_CHROMIUM=.../bin/google-chrome-stable not built; does not evaluate by default (see known gaps)

Validation

Command Result
nix build .#packages.x86_64-linux.pdfkiln -L pass (exit 0). The three wrappers export PDFKILN_CHROMIUM to the chromium store path.
nix build .#packages.aarch64-linux.pdfkiln -L --no-link pass (exit 0), under binfmt emulation (extra-platforms = aarch64-linux, no remote builders). The emulated wkhtmltopdf --version prints wkhtmltopdf 0.12.6 (with patched qt), pdfkiln 1.3.0, Chromium 158.0.8127.36.
nix eval --raw .#packages.aarch64-darwin.pdfkiln.drvPath fails: error: Refusing to evaluate package 'google-chrome-157.0.8103.51' in .../pkgs/by-name/go/google-chrome/package.nix:354 because it has an unfree license ('unfree')
NIXPKGS_ALLOW_UNFREE=1 nix eval --impure --raw .#packages.aarch64-darwin.pdfkiln.drvPath /nix/store/1pqr42jhim78r72ys1kqsmldv7q0z3zn-pdfkiln-1.3.0.drv
NIXPKGS_ALLOW_UNFREE=1 nix eval --impure --raw .#packages.aarch64-darwin.pdfkiln.installPhase wrapper line: --set PDFKILN_CHROMIUM /nix/store/7v06cqfcaz3phlw309aav4r6sii5ba9b-google-chrome-157.0.8103.51/bin/google-chrome-stable. No chromium reference.
nix build .#checks.x86_64-linux.pdfkiln -L --no-link pass (exit 0): --version and the "with patched qt" grep, the Linux PDFKILN_CHROMIUM grep, and the PDF render in the sandbox
Negative test: "with patched qt" grep changed to a string that is absent, rebuilt fails (exit 1), so a broken check is caught. The good version was restored.
wkhtmltopdf --encoding utf-8 --footer-center '[page]/[topage]' page.html page.pdf, outside the sandbox, from the result exit 0. The file starts with %PDF. pdftotext (nixpkgs poppler-utils 26.10.0) shows 1/1.
nix fmt, then git diff --exit-code pass (nothing changed)
prek run --all-files pass (all hooks)
statix check on packages/pdfkiln.nix, checks/pdfkiln.nix, flake.nix pass
deadnix --fail on the same files pass
nix build of nix-lint, check-names, ci-pins, dependabot, shared-config (x86_64-linux) pass
nix flake check --no-build pass for x86_64-linux. It prints an existing getExe notice for nixpkgs' wkhtmltopdf, from tests/nixos-hardening.nix, not from this change. The aarch64 outputs are omitted, as flake check does without --all-systems.
nix eval --raw .#checks.aarch64-linux.pdfkiln.drvPath pass (evaluates). The check was not built for aarch64-linux.

Known gaps

  1. darwin does not evaluate by default. google-chrome is unfree and this flake's nixpkgs does not allow unfree packages, so packages.aarch64-darwin.pdfkiln and checks.aarch64-darwin.pdfkiln refuse to evaluate. With NIXPKGS_ALLOW_UNFREE=1 they evaluate, and the wrapper is as designed. This needs a decision: allow google-chrome in this flake, for example with an allowUnfreePredicate for that one package, or use a free darwin browser. It is not changed here, because the design names google-chrome.
  2. darwin is not built or run. The browser, the wrapper's behavior at run time, and the render are all untested.
  3. aarch64-linux was built only under binfmt emulation on an x86_64 host, not on native hardware. Its check was not built, and no render was tried there.
  4. meta.platforms is lib.platforms.linux ++ lib.platforms.darwin, as designed. That list is wider than the three systems the flake outputs; for example it includes i686-linux and armv7l-linux.
  5. Version line. pdfkiln --version reports Chromium 158.0.8127.36, but the wrapped browser is nixpkgs' chromium 157.0.8103.50 (chromium --version prints Chromium 157.0.8103.50). The line does not report the browser that runs.
  6. Full nix flake check was not run here, because it includes the VM tests. Only the checks listed above were built.

🤖 Generated with Claude Code

Add packages/pdfkiln.nix: @pdfkiln/pdfkiln 1.3.0 from the npm registry,
pinned by its sha512 and unpacked as published, with its three commands
(wkhtmltopdf, wkhtmltoimage and pdfkiln) wrapped on nixpkgs' Node.js 24.
Each wrapper sets PDFKILN_CHROMIUM, which selects the browser pdfkiln
drives, so pdfkiln never downloads one:

- Linux: nixpkgs chromium (chromium/bin/chromium)
- darwin: nixpkgs google-chrome (google-chrome/bin/google-chrome-stable)

flake.nix exposes it as packages.<system>.pdfkiln, from the entries helper
that checks use. checks/pdfkiln.nix builds it and requires wkhtmltopdf
--version to report "with patched qt". On Linux it also requires the
wrapper to set PDFKILN_CHROMIUM, and renders a PDF inside the build
sandbox with pdfkiln's own settings. docs/library.md documents it.

Validation on x86_64-linux: the package and the check build. A check with
a broken grep fails the build. A page rendered outside the sandbox starts
with %PDF and shows the 1/1 footer. nix fmt, prek, statix, deadnix,
nix-lint, check-names, ci-pins, dependabot and shared-config pass, and
nix flake check --no-build evaluates the flake.

Not verified: aarch64-darwin. google-chrome is unfree and this flake's
nixpkgs does not allow unfree packages, so packages.aarch64-darwin.pdfkiln
does not evaluate by default. aarch64-linux built here only under binfmt
emulation, not on native hardware, and its check was not built.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AAw4Sw2knFZL7NYgFroq1Y
@batonac
batonac merged commit ae29cfe into main Nov 23, 2026
9 checks passed
@batonac
batonac deleted the feat/pdfkiln-package branch November 23, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant