Shared documentation-site machinery based on ndg
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Kiara Grouwstra a9af4a6bf3
All checks were successful
checks-treefmt / treefmt (push) Successful in 4s
checks-smoke / smoke (push) Successful in 5m48s
flake: instantiate the entrypoint once per system (#3)
The flake wrapper applied the entrypoint once per `(attr, system)` pair. `import` memoizes the *file* value, not the *application*, so none of those applications shared any of the entrypoint's internal work -- each re-ran the whole `let`, including the `pkgs ? import sources.nixpkgs { ... }` default argument, i.e. a whole fresh nixpkgs.

Binding one instantiation per system in the `let` and reading every keyed output out of it collapses that.

Measured on `fediversity-ci`, `nix flake show --no-eval-cache`, warm store, second of two runs:

| | wall | user+sys | maxrss | nrThunks | gc.totalBytes |
|---|---|---|---|---|---|
| before | 2.08 s | 1.35 s | 198 MB | 607,339 | 149.4 MB |
| after | 1.06 s | 0.67 s | 93 MB | 178,316 | 42.5 MB |

Output is unchanged: `nix flake show --json --all-systems --no-eval-cache | jq -S .` is byte-identical before and after, and every `drvPath` is unmoved bar the `treefmt` check's, which hashes the project source and so moves with any edit to `flake.nix` itself.

This is the same defect that cost the fediversity monorepo far more (its entrypoints carry a whole deployment surface, not just a nixpkgs); the wrapper was copied from https://codeberg.org/kiara/poc-override-nix-deps, which is being fixed at the source too.

Reviewed-on: #3
2026-08-12 23:47:27 +02:00
.forgejo/workflows Trim CI runner labels: drop ram-<N>g, keep bare native 2026-07-13 14:55:46 +02:00
npins Initial import: shared nix docs library (ndg site machinery + describeCheck) 2026-07-12 13:33:20 +02:00
.envrc Initial import: shared nix docs library (ndg site machinery + describeCheck) 2026-07-12 13:33:20 +02:00
.gitignore Initial import: shared nix docs library (ndg site machinery + describeCheck) 2026-07-12 13:33:20 +02:00
check-describe.nix Initial import: shared nix docs library (ndg site machinery + describeCheck) 2026-07-12 13:33:20 +02:00
default.nix Wrap entrypoint param re-exports into args so flake show stops printing unknown 2026-07-13 11:04:22 +02:00
docs.nix docs: expose docs+describeCheck via lib.docs wrapper 2026-07-12 16:32:40 +02:00
flake.lock Initial import: shared nix docs library (ndg site machinery + describeCheck) 2026-07-12 13:33:20 +02:00
flake.nix flake: instantiate the entrypoint once per system (#3) 2026-08-12 23:47:27 +02:00
LICENSE Add LICENSE (EUPL-1.2) to match the fediversity monorepo 2026-07-13 10:07:32 +02:00
README.md docs: expose docs+describeCheck via lib.docs wrapper 2026-07-12 16:32:40 +02:00
shell.nix Initial import: shared nix docs library (ndg site machinery + describeCheck) 2026-07-12 13:33:20 +02:00
treefmt.nix Initial import: shared nix docs library (ndg site machinery + describeCheck) 2026-07-12 13:33:20 +02:00

nix-docs-lib

Shared ndg-based documentation machinery for rendering per-component option/prose sites, plus the describeCheck helper used to read each check's meta.description when building a flake-attributes page.

Extracted from the fediversity monorepo so its core/api/panel doc sites and the standalone nix-module-form widget can share one definition, each consuming it via an npins pin.

Usage

lib.docs is a function of { basePath ? null, repoPath ? "", ... } (pkgs, sources and lib default internally). Each consumer passes its own repo root (basePath) and Forgejo source URL (repoPath) so transformOptions rewrites option declarations into links on the consumer's own instance:

inherit
  ((import "${sources.nix-docs-lib}" { }).lib.docs {
    basePath = ./..;
    repoPath = "https://git.fediversity.eu/fediversity/fediversity/src/branch/main";
  })
  mkSite
  optionsCommonMark
  optionPage
  flakeAttributesPage
  ;

describeCheck lives in check-describe.nix (also re-exported from default.nix):

inherit ((import "${sources.nix-docs-lib}" { }).lib) describeCheck;

Development

nix flake show
nix build .#checks.x86_64-linux.treefmt
nix build .#checks.x86_64-linux.smoke