Feature Specification: Entrypoint, Checks and Documentation
Created: 2026-09-22
Status: Implemented
Input: Reconstructed from the code at 3c0765d, default.nix, flake.nix, the .forgejo/workflows/, the md/ pages, the commit and pull request history of nix-tf-schema, and the Claude Code logs.
User Scenarios & Testing (mandatory)
User Story 1 - Use the library from a pin or from a flake (Priority: P1)
A consumer that pins nix-tf-schema with npins (or a plain fetchTarball)
calls it with its own pkgs, so that the helpers evaluate against the
consumer's nixpkgs. A flake consumer reads the same helpers from the flake
outputs.
Why this priority: a library that brings its own nixpkgs into the evaluation of a consumer makes a second nixpkgs instance and types that do not match.
Independent Test: evaluate (pkgs.callPackage ./. { }).lib with a given
pkgs, and (builtins.getFlake ...).lib. Both have the same helper names.
Acceptance Scenarios:
- Given a consumer
pkgs, When the consumer callsdefault.nixwith it, Then the helpers use thatpkgsand thatlib. - Given no arguments, When a user imports
default.nix, Thenpkgscomes from the localnpinspin. - Given the flake, When a consumer reads
lib, Then there is no system key, because the helpers are pure functions;checks,formatter,packagesanddevShellshave a system key.
User Story 2 - Check a change (Priority: P1)
A contributor opens a pull request. CI runs the nix-unit suite, the format
check and the documentation build.
Why this priority: the helpers are the public surface; a regression breaks every consumer.
Independent Test: run nix develop --command nix-unit ./conversion-test.nix
and nix build .#checks.x86_64-linux.treefmt .#checks.x86_64-linux.docs.
Acceptance Scenarios:
- Given the
nix-unitsuite, When CI runs it, Then it runs outside the build sandbox, becausetest-extractProviderSchemasuses import-from-derivation. - Given the flake checks, When a user runs
nix flake check, Then only sandbox-safe checks run (treefmt,docs). - Given the dev shell, When a contributor enters it, Then
nix-unitandspec-kitare available.
User Story 3 - Read the documentation (Priority: P2)
A user reads a site with an overview, a comparison with other tools, one section per helper rendered from its doc-comment, and the flake outputs.
Why this priority: the helpers have many parameters, and the doc-comments are the reference.
Independent Test: build .#packages.x86_64-linux.docs. The site has the
pages index, comparison, functions and flake-attributes, in that
order.
Acceptance Scenarios:
- Given a doc-comment on a function in
conversion.nixorlib.nix, When the site builds, Then the function has a section with the anchorfunction-library-tf-schema.<category>.<name>. - Given the flake outputs, When the site builds, Then the
flake-attributespage listspackages,checksanddevShellsfrom the entrypoint, so it cannot drift.
Edge Cases
libis not listed on theflake-attributespage, because its helpers have nometa.description; thefunctionspage documents them.- The CI workflow that publishes the site runs on
mainonly.
Requirements (mandatory)
Functional Requirements
- FR-001:
default.nixMUST be the one entrypoint, callable bycallPackagewithpkgsandlibfrom the consumer. - FR-002:
flake.nixMUST only add the system layer todefault.nixand MUST exposelibwithout a system key. - FR-003: All inputs MUST be pinned with
npins. - FR-004: The flake MUST give
checksfor the format and the documentation site, and a dev shell withnix-unitandspec-kit. - FR-005: CI MUST run the
nix-unitsuite, the format check and the documentation build on each pull request. - FR-006: The documentation site MUST render the doc-comment of each exported helper with
nixdoc, throughnix-docs-lib. - FR-007: Links between doc-comments MUST use the anchors that the site makes (
#function-library-tf-schema.<category>.<name>), and each link MUST have a target. - FR-008: The README and the landing page MUST NOT give counts or lists of helpers or tests that can go out of date. They describe the capabilities and link to the function reference on the site.
- FR-009: The documentation, comments and test data MUST describe the library by itself, not by a consumer (constitution principle I).
Key Entities
- Entrypoint:
default.nix, which returnslib,checks,packages,devShells,formatter,pkgs,sourcesandnix-unit. - Documentation site: the
ndgsite frommd/and the generated pages.
Success Criteria (mandatory)
Measurable Outcomes
- SC-001: The
nix-unit,treefmtanddocsCI jobs pass onmain. - SC-002: A consumer that passes its own
pkgsevaluates one nixpkgs instance.
Assumptions
nix-docs-libstays the documentation tool, shared with other projects.- CI runs on Forgejo Actions with runners that have Nix.