-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
Description
Project description
Option declarations are currently of a fairly closed form, as we can't add arbitrary metadata to them.
This could provide an avenue for both implementing features externally when they are not desirable or controversial in NixOS itself, e.g.
... and this could also allow currently "core" features such as internal or visible to be moved out of the hot path, improving performance. Crucially, for the performance improvement to work, config must never evaluate opt.meta, based solely on the module system itself. (Modules such as documentation.nix will evaluate them, and that's ok.)
Proposal:
- Add a
metafield tomkOption - Expose
metain the evaluatedoptions - Add
meta = throw "module evaluation must be lazy in meta";in a number of tests - Migrate
visibleandinternal (and more?) intometa`- Make the
mkOptionparameters write to bothmetaand the option attrset - Wait (1) is available in all supported releases
- Warn when legacy arguments are passed to
mkOption, and warn when legacy option attrs are used - Wait one release
- Turn the warnings into errors.
- Wait one release
- Remove the legacy attrs
- Performance will improve
- Make the
Note that after (2), applications can already start using this for their own purposes.
Example:
lib.mkOption {
type = ...;
description = ...; # technically meta, but we might want to keep this here for historic consistency and convenience
meta = {
visible = "shallow";
internal = true;
# implementation-specific attrs
advanced = true; # possible emerging standard among some applications
arion-docker-compose-equivalent = "entrypoint"; # something I'm making up, but is relevant to the arion application (not actually the motivation for this proposal)
};
}
I've chosen meta in my examples, although meta in packages is closed, unlike this proposal which is open.
That might be a reason to pick labels instead? I'm undecided.
I'd be happy to implement this without moving anything, but candidates for moving are:
descriptiondefaultTextexamplerelatedPackagesinternalvisible
Add a 👍 reaction to issues you find important.
Metadata
Metadata
Assignees
Labels
Projects
Status