Skip to content

Provide a schema for the htmlDocs output#44

Open
lucperkins wants to merge 11 commits intomainfrom
html-docs-schema
Open

Provide a schema for the htmlDocs output#44
lucperkins wants to merge 11 commits intomainfrom
html-docs-schema

Conversation

@lucperkins
Copy link
Member

@lucperkins lucperkins commented Oct 2, 2025

With this schema in place, nix flake show nixpkgs --all-systems displays this for htmlDocs:

├───htmlDocs
│   ├───nixosManual
│   │   ├───aarch64-linux: HTML documentation [nixos-manual-html]
│   │   └───x86_64-linux: HTML documentation [nixos-manual-html]
│   └───nixpkgsManual
│       ├───aarch64-darwin: HTML documentation [nixpkgs-manual]
│       ├───aarch64-linux: HTML documentation [nixpkgs-manual]
│       ├───armv6l-linux: HTML documentation [nixpkgs-manual]
│       ├───armv7l-linux: HTML documentation [nixpkgs-manual]
│       ├───i686-linux: HTML documentation [nixpkgs-manual]
│       ├───powerpc64le-linux: HTML documentation [nixpkgs-manual]
│       ├───riscv64-linux: HTML documentation [nixpkgs-manual]
│       ├───x86_64-darwin: HTML documentation [nixpkgs-manual]
│       ├───x86_64-freebsd: HTML documentation [nixpkgs-manual]
│       └───x86_64-linux: HTML documentation [nixpkgs-manual]

I'm not sure this will be used outside of Nixpkgs but it would be nice to be able to support all Nixpkgs outputs.

Summary by CodeRabbit

  • Chores
    • Added a new HTML documentation output schema to the build configuration to recognize and describe HTML docs artifacts.
    • Integrated the new schema into the top-level schemas map so HTML documentation outputs are exposed and handled consistently across builds.
    • Updated public schema exports so the HTML docs schema is available alongside existing schemas.

@coderabbitai
Copy link

coderabbitai bot commented Oct 2, 2025

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a new htmlDocsSchema to flake.nix outputs, defining an inventory layout for HTML documentation derivations and exposing it as schemas.htmlDocs in the top-level schemas map.

Changes

Cohort / File(s) Summary
HTML Documentation Schema
flake.nix
Adds htmlDocsSchema in outputs to describe htmlDocs.${package}.${system} derivations (mapping-based listing with isDerive and what = "HTML documentation"); registers it as schemas.htmlDocs in the final schemas map.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I sprouted a schema, neat and bright,
HTML pages lined up just right,
Packages first, systems next in view,
Docs hop into order — ready for review! ✨📚

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Provide a schema for the htmlDocs output' directly and clearly summarizes the main change: adding a schema definition for the htmlDocs output to flake.nix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch html-docs-schema

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lucperkins lucperkins requested a review from edolstra October 2, 2025 22:11
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
flake.nix (1)

349-354: Consider adding shortDescription for consistency.

Other derivation-based schemas (like packagesSchema and devShellsSchema) extract shortDescription from package metadata. Adding this field would provide useful context when inventorying HTML documentation packages.

Apply this diff to add shortDescription:

               children = builtins.mapAttrs (systemType: drv: {
                 forSystems = [ systemType ];
+                shortDescription = drv.meta.description or "";
                 derivation = drv;
                 evalChecks.isDerivation = checkDerivation drv;
                 what = "HTML documentation";
               }) systemsForPackage;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0e74ee and 668a214.

📒 Files selected for processing (1)
  • flake.nix (2 hunks)
🔇 Additional comments (1)
flake.nix (1)

411-411: LGTM!

The schema export is correctly added to the top-level schemas mapping.

@edolstra
Copy link
Collaborator

edolstra commented Oct 3, 2025

It's worth noting that the order of the attributes in htmlDocs is the opposite of what is customary (i.e. htmlDocs.nixpkgsManual.x86_64-linux instead of htmlDocs.x86_64-linux.nixpkgsManual). Maybe we don't want to enshrine that as the standard...

Since htmlDocs currently isn't widely adopted AFAIK, we could adopt the regular order in flake-schemas (i.e. htmlDocs.<system>.<package-name>) and then try to fix this in Nixpkgs.

htmlDocsSchema = {
version = 1;
doc = ''
The `htmlDocs` flake output defines packages providing static HTML output.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we had a convention/requirement about what the entry point to the docs should be (e.g. there should be an $out/index.html) that we could document here (and maybe even enforce in the schema, though I don't think the meta-schema currently supports that). That way, tools like FlakeHub could provide a link to the docs automatically.

Currently this doesn't seem to be the case for Nixpkgs (it has entry points like $out/share/doc/nixpkgs/index.html).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would indeed be a nice convention. If you think the Nixpkgs folks would be amenable I could propose that upstream, but I suspect that a lot of things probably depend on that directory structure at this point.

@lucperkins lucperkins requested a review from edolstra November 12, 2025 17:40
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@flake.nix`:
- Line 376: The identifier checkDerivation is undefined causing the eval
failure; replace the use of checkDerivation in the assignment to
evalChecks.isDerivation with the same pattern used elsewhere: evaluate
drv.attrs.type or null == "derivation" (or define a small helper if you prefer)
so change the line assigning evalChecks.isDerivation (which currently references
checkDerivation and drv) to use drv.attrs.type or null == "derivation" (or add a
local function named checkDerivation that returns attrs.type or null ==
"derivation" and call it with drv).

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e65b0bd and c9cdfb6.

📒 Files selected for processing (1)
  • flake.nix

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
flake.nix (2)

373-378: Consider adding shortDescription for tooling consistency.

Other derivation-based schemas (e.g., derivationsInventory at line 432, formatterSchema at line 177) include shortDescription = drv.meta.description or ""; to surface package descriptions in nix flake show output. This field is missing here.

📝 Proposed enhancement
               children = builtins.mapAttrs (systemType: drv: {
                 forSystems = [ systemType ];
                 derivation = drv;
+                shortDescription = drv.meta.description or "";
                 isFlakeCheck = false;
                 what = "HTML documentation";
               }) systemsForPackage;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@flake.nix` around lines 373 - 378, The HTML documentation derivation mapping
under children uses builtins.mapAttrs over systemsForPackage but omits
shortDescription; add a shortDescription attribute to each mapped object (e.g.,
inside the mapAttrs body where forSystems, derivation, isFlakeCheck, and what
are set) and set it to drv.meta.description or "" so tooling like nix flake show
surfaces package descriptions (reference symbols: children, builtins.mapAttrs,
systemsForPackage, derivation).

360-381: Add test fixtures for the new schema.

The test harness (per tests/flake.nix lines 72-90) automatically discovers test fixtures by scanning for tests/*.json files and expects a corresponding tests/<name>/flake.nix. Without these fixtures, the htmlDocsSchema won't be validated by CI.

Consider adding:

  • tests/htmlDocs/flake.nix — a minimal flake exposing htmlDocs.<package>.<system> outputs
  • tests/htmlDocs.json — the expected JSON from nix flake show

Would you like me to generate skeleton test fixtures following the pattern in tests/checks/flake.nix and tests/packages.json?

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@flake.nix` around lines 360 - 381, Add CI test fixtures for htmlDocsSchema by
creating a minimal test fixture named "htmlDocs": add a small flake that exposes
outputs in the form htmlDocs.<package>.<system> (so the harness can discover
htmlDocsSchema) and add the expected nix flake show JSON for that flake as the
accompanying expected-output JSON; follow the existing tests/checks/flake.nix
and packages.json patterns when constructing the flake and JSON so the test
harness will validate htmlDocsSchema correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@flake.nix`:
- Around line 373-378: The HTML documentation derivation mapping under children
uses builtins.mapAttrs over systemsForPackage but omits shortDescription; add a
shortDescription attribute to each mapped object (e.g., inside the mapAttrs body
where forSystems, derivation, isFlakeCheck, and what are set) and set it to
drv.meta.description or "" so tooling like nix flake show surfaces package
descriptions (reference symbols: children, builtins.mapAttrs, systemsForPackage,
derivation).
- Around line 360-381: Add CI test fixtures for htmlDocsSchema by creating a
minimal test fixture named "htmlDocs": add a small flake that exposes outputs in
the form htmlDocs.<package>.<system> (so the harness can discover
htmlDocsSchema) and add the expected nix flake show JSON for that flake as the
accompanying expected-output JSON; follow the existing tests/checks/flake.nix
and packages.json patterns when constructing the flake and JSON so the test
harness will validate htmlDocsSchema correctly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ac585713-1175-46d1-9b30-213eae7d5f33

📥 Commits

Reviewing files that changed from the base of the PR and between c9cdfb6 and b4c19f9.

📒 Files selected for processing (1)
  • flake.nix

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.

2 participants