Skip to content

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

  • New Features
    • Introduces HTML documentation outputs in flake results, enabling per-package builds of browsable docs with consistent validation.
  • Chores
    • CI workflow updated to use a centralized nixpkgs reference for checks, reducing duplication and simplifying maintenance.

@coderabbitai
Copy link

coderabbitai bot commented Oct 2, 2025

Walkthrough

Adds an htmlDocsSchema to flake.nix that defines a package-first inventory producing HTML documentation derivations, exposes it as schemas.htmlDocs, and updates the CI workflow to use an env.nixpkgs variable in flake-check commands.

Changes

Cohort / File(s) Summary
Schema introduction & exposure
flake.nix
Adds htmlDocsSchema in outputs, uses derivationsInventoryByPackage to produce HTML documentation derivations (package-first htmlDocs.${package}.${system}), inherits what and isFlakeCheck, and exposes it as schemas.htmlDocs.
CI workflow update
.github/workflows/check.yml
Adds env.nixpkgs variable in the flake-check job and replaces hardcoded nixpkgs URLs with "${{ env.nixpkgs }}" in nix shell commands.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Dev as Developer
    participant Flake as flake.nix (outputs)
    participant Schema as htmlDocsSchema
    participant Inv as derivationsInventoryByPackage
    participant Systems as Systems
    participant Packages as Packages
    participant Docs as HTML Doc Derivations

    Dev->>Flake: Query outputs.schemas.htmlDocs
    Flake->>Schema: Initialize htmlDocsSchema
    Schema->>Inv: Request package-first inventory
    Inv->>Systems: Iterate systems
    Systems->>Packages: yield package sets
    Packages->>Inv: packages per system
    Inv->>Docs: Map package → HTML doc derivation
    Docs-->>Schema: return HTML docs inventory
    Schema-->>Flake: expose as schemas.htmlDocs
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I hop through flake and schema rows,
Mapping pages where HTML grows.
Packages line the burrowed track,
Docs assembled, stacked on stack.
A carrot-shaped inventory—snack! 🥕

Pre-merge checks and finishing touches

✅ 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 succinctly describes the primary change of adding a schema for the htmlDocs output, directly reflecting the pull request’s implementation of htmlDocsSchema in flake.nix and its exposure in the schemas map.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ 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

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

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

📒 Files selected for processing (2)
  • .github/workflows/check.yml (1 hunks)
  • flake.nix (3 hunks)
🔇 Additional comments (5)
.github/workflows/check.yml (2)

15-16: LGTM! Centralized nixpkgs version.

Consolidating the nixpkgs URL in an environment variable improves maintainability by making version updates simpler.


24-30: LGTM! Consistent use of centralized nixpkgs reference.

Both commands correctly use the env.nixpkgs variable, ensuring consistent nixpkgs versions across CI steps.

flake.nix (3)

339-361: LGTM! Well-structured schema for package-first output.

The htmlDocsSchema correctly handles the inverted htmlDocs.${package}.${system} structure with appropriate double mapping. The inclusion of isFlakeCheck = false (line 356) ensures documentation builds are excluded from nix flake check, and the inline comment (lines 347-348) clearly explains the structural rationale.


386-386: LGTM! Idiomatic use of inherit.

Using inherit isFlakeCheck what; is more concise and idiomatic than explicit assignment, improving code readability.


407-407: LGTM! Schema export follows established pattern.

The schemas.htmlDocs export correctly exposes the new schema, maintaining consistency with other schema declarations.


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.

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.

3 participants