From 375a40c2beec5c0aaa56e5dd4bb62ded5e4f997f Mon Sep 17 00:00:00 2001 From: Kevin Shenk Date: Mon, 23 Nov 2026 09:44:14 -0500 Subject: [PATCH] fix(standards): allow google-chrome in the flake's package set, for darwin The darwin pdfkiln wrapper runs nixpkgs' google-chrome, which is unfree. The flake's nixpkgs allowed no unfree package, so packages.aarch64-darwin.pdfkiln refused to evaluate without NIXPKGS_ALLOW_UNFREE=1. The flake's perSystem package set now allows exactly one unfree package, google-chrome, through config.allowUnfreePredicate. allowUnfree stays unset, so nothing else is allowed. It is set as _module.args.pkgs, which is how flake-parts supplies perSystem's pkgs. checks/pdfkiln.nix gets a darwin branch that asserts PDFKILN_CHROMIUM names google-chrome-stable and skips the render, which stays Linux-only. The Linux check's derivation is unchanged. Verified: the darwin package and check evaluate with NIXPKGS_ALLOW_UNFREE unset, and the darwin installPhase sets PDFKILN_CHROMIUM to google-chrome-stable with no chromium path. The Linux package and check drvPaths match main, and the Linux check builds. nix flake check --no-build (x86_64-linux), nix fmt, statix, deadnix and prek pass. Darwin is not built or run. Co-Authored-By: Claude Haiku 5.5 Claude-Session: https://claude.ai/code/session_01AAw4Sw2knFZL7NYgFroq1Y --- checks/pdfkiln.nix | 25 ++++++++++++++++--------- flake.nix | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/checks/pdfkiln.nix b/checks/pdfkiln.nix index 6ede78d..d6fcfa6 100644 --- a/checks/pdfkiln.nix +++ b/checks/pdfkiln.nix @@ -1,6 +1,7 @@ # packages/pdfkiln.nix, built and run: wkhtmltopdf reports the patched Qt it is -# built with, and on Linux its wrapper points PDFKILN_CHROMIUM at nixpkgs' -# chromium, the browser the package is built against. +# built with, and its wrapper points PDFKILN_CHROMIUM at the browser the package +# is built against: nixpkgs' chromium on Linux, which the check renders with, and +# nixpkgs' google-chrome-stable on darwin, which the check only names. { pkgs, self }: let inherit (pkgs) lib; @@ -15,12 +16,18 @@ checks.script "pdfkiln" { tools = [ pdfkiln ]; } '' cat version grep -F 'with patched qt' version - ${lib.optionalString pkgs.stdenv.hostPlatform.isLinux '' - grep -F 'PDFKILN_CHROMIUM' ${pdfkiln}/bin/wkhtmltopdf - grep -F '${pkgs.chromium}/bin/chromium' ${pdfkiln}/bin/wkhtmltopdf + ${ + lib.optionalString pkgs.stdenv.hostPlatform.isLinux '' + grep -F 'PDFKILN_CHROMIUM' ${pdfkiln}/bin/wkhtmltopdf + grep -F '${pkgs.chromium}/bin/chromium' ${pdfkiln}/bin/wkhtmltopdf - printf '

pdfkiln check

' > page.html - wkhtmltopdf page.html page.pdf - test "$(head -c 4 page.pdf)" = %PDF - ''} + printf '

pdfkiln check

' > page.html + wkhtmltopdf page.html page.pdf + test "$(head -c 4 page.pdf)" = %PDF + '' + + lib.optionalString pkgs.stdenv.hostPlatform.isDarwin '' + grep -F 'PDFKILN_CHROMIUM' ${pdfkiln}/bin/wkhtmltopdf + grep -F '${pkgs.google-chrome}/bin/google-chrome-stable' ${pdfkiln}/bin/wkhtmltopdf + '' + } '' diff --git a/flake.nix b/flake.nix index 68fa32e..c56c3a2 100644 --- a/flake.nix +++ b/flake.nix @@ -53,6 +53,24 @@ "aarch64-darwin" ]; + # This flake's package set: nixpkgs that allows exactly one unfree + # package, google-chrome, which the darwin pdfkiln wrapper runs + # (packages/pdfkiln.nix). Nothing else here is unfree-allowed. + # `_module.args.pkgs` is how flake-parts sets perSystem's `pkgs`; its + # nixpkgs module only supplies the default, which this replaces. + imports = [ + { + perSystem = + { system, ... }: + { + _module.args.pkgs = import nixpkgs { + inherit system; + config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "google-chrome" ]; + }; + }; + } + ]; + flake = { # lib/.nix is `{ lib }: { … }` and becomes lib.: pure # functions that take `pkgs` and the product's names as arguments.