Build an option index from a flake-parts evaluation #4

Open
opened 2026-09-12 02:38:51 +09:00 by natsukium · 1 comment
Owner

optionSymbols takes an evaluated options tree, and documents.nix produces
one with home-manager.lib.homeManagerConfiguration. A flake-parts repository
has no single such tree: modules are written as
flake.modules.<class>.<name> = module, and the option trees only exist once
each class is evaluated — nixos, darwin, homeManager, nixOnDroid — usually once
per host.

What is needed is the flake-parts equivalent of the home helper in
documents.nix: something that takes a flake's outputs and produces, per
class and per host, an evaluated options tree, plus a way to find which of
those evaluations a given source file participates in.

Depends on the decision in "Decide what a card shows when one file is evaluated
many times" (#3).

`optionSymbols` takes an evaluated `options` tree, and `documents.nix` produces one with `home-manager.lib.homeManagerConfiguration`. A flake-parts repository has no single such tree: modules are written as `flake.modules.<class>.<name> = module`, and the option trees only exist once each class is evaluated — nixos, darwin, homeManager, nixOnDroid — usually once per host. What is needed is the flake-parts equivalent of the `home` helper in `documents.nix`: something that takes a flake's outputs and produces, per class and per host, an evaluated `options` tree, plus a way to find which of those evaluations a given source file participates in. Depends on the decision in "Decide what a card shows when one file is evaluated many times" (#3).
Author
Owner

Follows the decision in #3 (group by value across evaluations).

Shape: a helper that takes a flake's outputs and returns { <class>.<host> = options; } from nixosConfigurations, darwinConfigurations and homeConfigurations (nixOnDroid when present). Which evaluations a file participates in is decided by whether any indexed option's files or declarations names that file, since the module system does not expose its collected module list (collectModules in lib/modules.nix is internal).

Prefixes per file come from the static side, see #2.

Follows the decision in #3 (group by value across evaluations). Shape: a helper that takes a flake's outputs and returns `{ <class>.<host> = options; }` from `nixosConfigurations`, `darwinConfigurations` and `homeConfigurations` (nixOnDroid when present). Which evaluations a file participates in is decided by whether any indexed option's `files` or `declarations` names that file, since the module system does not expose its collected module list (`collectModules` in `lib/modules.nix` is internal). Prefixes per file come from the static side, see #2.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
natsukium/gloss#4
No description provided.