NixOS Module System | 204 Members | |
| 47 Servers |
| Sender | Message | Time |
|---|---|---|
| 29 May 2026 | ||
| For the purposes of discovering declared options, When defining a submodule (with a module), that module can declare additional options for use within the submodule. However, if you only care about options declared by modules available when the type was instantiated, then | 11:48:22 | |
| * For the purposes of discovering declared options, When defining a submodule (with a module), that module can declare additional options for use within the submodule. However, if you only care about options declared by modules available when the type was instantiated, then | 11:49:12 | |
| You may find it easier to actually leverage the doc's tooling and use
| 11:58:50 | |
| I mentioned the problem with optionAttrSetToDocList that I ran into, it means having to parse the types out of strings. | 12:17:09 | |
| With getSubOptions I just worry about running into a similar limitatation since it seems to also be targeted at documentation generation. | 12:17:45 | |
| I'd also still have to dig for the freeformType because _freeformOptions in getSubOptions does not (maybe not always?) include the information I need, it was {} when I was looking at a submodule with a freeformType that allows JSON. | 12:20:32 | |
| The core of
There are some additional option-visibility checks, partly to avoid infinite tree-recursion, partly to respect docs-visibility. While The options returned by | 12:24:20 | |
| OK, ill consider using getSubOptions. But that still leaves freeformType. | 12:27:20 | |
| What do you need to know about freeformType? Note that Luckily,
| 12:34:16 | |
| That's null because it's a nullOr submodule, no? | 12:38:20 | |
it's a nullOr deferredType. In this case I assume it's null because the services.pixelfed.nginx's submodule-type isn't freeform. | 12:39:24 | |
| You're right, that one's not freeform. | 12:40:24 | |
* it's a nullOr optionType. In this case I assume it's null because the services.pixelfed.nginx's submodule-type isn't freeform. | 12:40:29 | |
| OK, so if I want to treat things uniformly getSubOptions might be easier than figuring out where in the functor payloads the information can be found. I'll be trying that and probably run into more questions : ) Thank you! | 12:42:43 | |
the final merged configuration isn't visible to the functor. Because it only exists after merging option definitions. Option definitions can only exist once a type is used with an option. | 12:43:46 | |
*
the final merged configuration isn't visible to the functor. Because it only exists after merging option definitions. Option definitions can only exist once a type is used with an option. | 12:44:14 | |
| I'm starting from (nixos {}).options.services.<module>, IIUC those are merged option definitions, just may not be complete yet, missing some required definitions? | 12:46:26 | |
| The functor you referred to is The option itself has access to it's final merged value ( Once you return | 12:50:48 | |
| Except for the `loc` no? | 12:52:22 | |
| Sure, but that's just a list of strings, not an option. | 12:52:41 | |
| I don't think I have a need for that information once I recurse, since what I return will be under the <module> or whatever nested option. | 12:53:17 | |
* Sure, but that's just a list of strings, not an option. It's useful only for properly prefixing the sub-options' own locs, for user-facing clarity. | 12:53:20 | |
| getSubOptions doesn't return a flat structure of all nested options, right? So I don't need to sort them by loc to regain the structure? | 12:55:03 | |
| I always recommend trying to keep the prefix accurate, so that once you have your final list of options you can do In my interpretation of I'm not aware of any types that do that currently, but it's something to be aware of. | 12:59:57 | |
| * I always recommend trying to keep the prefix accurate, so that once you have your final list of options you can do This may be controversial, but in my interpretation of I'm not aware of any types that do that currently, but it's something to be aware of. | 13:00:23 | |
| You mean something like attrsOf (either submodule submodule)? | 13:24:25 | |
| Yeah. Although currently that's not very common because it's not easy to discriminate between submodule-specific module definitions. A more practical example may be
| 13:34:48 | |
| is it an axiom that merging a single definition just results in the first definition's value? | 18:35:04 | |
| merge functions can also transform definitions, but I'd say the value should always be derived from that definition's value. Unless the merge function throws or something. | 18:36:24 | |
| * merge functions can also transform definitions,* but I'd say the value should always be derived from that definition's value. Unless the merge function throws or something. * e.g. types.coercedTo | 18:36:49 | |