Repository navigation
feat(standards): add the pdfkiln wkhtmltopdf replacement - #85
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
packages/pdfkiln.nix:@pdfkiln/pdfkiln1.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 setsPDFKILN_CHROMIUM, which selects the browser, so pdfkiln never downloads one.flake.nix:packages = lib.mapAttrs (_: path: pkgs.callPackage path { }) (entries ./packages);next tochecks, using the existingentrieshelper.checks/pdfkiln.nix: builds the package. It requireswkhtmltopdf --versionto report "with patched qt". On Linux it also requires the wrapper to setPDFKILN_CHROMIUMto 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 thepackages/<name>.nixrule 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
chromium157.0.8103.50PDFKILN_CHROMIUM=.../bin/chromiumchromium(same)google-chrome157.0.8103.51, wrappergoogle-chrome-stablePDFKILN_CHROMIUM=.../bin/google-chrome-stableValidation
nix build .#packages.x86_64-linux.pdfkiln -LPDFKILN_CHROMIUMto the chromium store path.nix build .#packages.aarch64-linux.pdfkiln -L --no-linkextra-platforms = aarch64-linux, no remote builders). The emulatedwkhtmltopdf --versionprintswkhtmltopdf 0.12.6 (with patched qt), pdfkiln 1.3.0, Chromium 158.0.8127.36.nix eval --raw .#packages.aarch64-darwin.pdfkiln.drvPatherror: 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.drvNIXPKGS_ALLOW_UNFREE=1 nix eval --impure --raw .#packages.aarch64-darwin.pdfkiln.installPhase--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--versionand the "with patched qt" grep, the LinuxPDFKILN_CHROMIUMgrep, and the PDF render in the sandboxwkhtmltopdf --encoding utf-8 --footer-center '[page]/[topage]' page.html page.pdf, outside the sandbox, from the result%PDF.pdftotext(nixpkgs poppler-utils 26.10.0) shows1/1.nix fmt, thengit diff --exit-codeprek run --all-filesstatix checkonpackages/pdfkiln.nix,checks/pdfkiln.nix,flake.nixdeadnix --failon the same filesnix buildofnix-lint,check-names,ci-pins,dependabot,shared-config(x86_64-linux)nix flake check --no-buildgetExenotice for nixpkgs' wkhtmltopdf, fromtests/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.drvPathKnown gaps
google-chromeis unfree and this flake's nixpkgs does not allow unfree packages, sopackages.aarch64-darwin.pdfkilnandchecks.aarch64-darwin.pdfkilnrefuse to evaluate. WithNIXPKGS_ALLOW_UNFREE=1they evaluate, and the wrapper is as designed. This needs a decision: allowgoogle-chromein this flake, for example with anallowUnfreePredicatefor that one package, or use a free darwin browser. It is not changed here, because the design names google-chrome.meta.platformsislib.platforms.linux ++ lib.platforms.darwin, as designed. That list is wider than the three systems the flake outputs; for example it includesi686-linuxandarmv7l-linux.pdfkiln --versionreportsChromium 158.0.8127.36, but the wrapped browser is nixpkgs' chromium 157.0.8103.50 (chromium --versionprintsChromium 157.0.8103.50). The line does not report the browser that runs.nix flake checkwas not run here, because it includes the VM tests. Only the checks listed above were built.🤖 Generated with Claude Code