nixos-module: use playwright's chromium-headless-shell instead of pkgs.chromium for PDF generation
snappdf only ever shells out to `$SNAPPDF_CHROMIUM_PATH --headless --print-to-pdf=...`, so the full browser UI/GPU stack pkgs.chromium ships is unnecessary. Google's official "Chrome for Testing" headless-only build (packaged by nixpkgs' playwright-driver, selected via `browsers.override` with every other browser/ffmpeg disabled) does the same job for a ~1.45GB smaller closure (431MB vs 1.88GB), needs no allowUnfree, and PDF generation is noticeably faster in the VM test (~2.5s vs ~10s per request). Drops the now-unnecessary allowUnfree wiring from the interactive VM and automated test configs, which existed solely to build pkgs.chromium. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -47,8 +47,22 @@ let
|
||||
extraConfig = "memory_limit = 1024M";
|
||||
};
|
||||
|
||||
# Chromium is required for PDF invoice generation
|
||||
chromium = pkgs.chromium;
|
||||
# A headless browser is required for PDF invoice generation (PDF_GENERATOR=snappdf). snappdf
|
||||
# just shells out to `$SNAPPDF_CHROMIUM_PATH --headless --print-to-pdf=... <url>`, so a full
|
||||
# browser UI/GPU stack isn't needed -- Google's own "Chrome for Testing" headless-only build
|
||||
# (as packaged by nixpkgs' playwright-driver) does the same job for a ~1.45GB smaller closure
|
||||
# than pkgs.chromium, with no allowUnfree requirement.
|
||||
chromiumHeadlessShellBrowsers = pkgs.playwright-driver.browsers.override {
|
||||
withChromium = false;
|
||||
withFirefox = false;
|
||||
withWebkit = false;
|
||||
withFfmpeg = false;
|
||||
withChromiumHeadlessShell = true;
|
||||
};
|
||||
chromium = pkgs.runCommand "chromium-headless-shell" { } ''
|
||||
mkdir -p $out/bin
|
||||
ln -s ${chromiumHeadlessShellBrowsers}/chromium_headless_shell-*/chrome-headless-shell-linux64/chrome-headless-shell $out/bin/chromium
|
||||
'';
|
||||
extraPrograms = [ chromium ];
|
||||
|
||||
# Management script
|
||||
|
||||
Reference in New Issue
Block a user