From e1ae98f979fb5360ec025277e19ea82719a37d5a Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Sun, 4 May 2025 03:40:30 +0100 Subject: [PATCH] doc: ensure `pkgs` is not used in option docs Providing a stub `pkgs` instance that has no contents ensures the docs does not _read_ `pkgs` anywhere. --- doc/default.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/default.nix b/doc/default.nix index 1253c33c..1b887713 100644 --- a/doc/default.nix +++ b/doc/default.nix @@ -14,11 +14,24 @@ let # Prefix to remove from option declaration file paths. rootPrefix = toString ../. + "/"; + # A stub pkgs used while evaluating the stylix modules for the docs + noPkgs = { + # Needed for type-checking + inherit (pkgs) _type; + + # Permit access to (pkgs.formats.foo { }).type + formats = builtins.mapAttrs (_: fmt: args: { + inherit (fmt args) type; + }) pkgs.formats; + }; + evalDocs = module: lib.evalModules { modules = [ ./eval_compat.nix ] ++ lib.toList module; - specialArgs = { inherit pkgs; }; + specialArgs = { + pkgs = noPkgs; + }; }; # TODO: Include Nix Darwin options