NixOS Module System | 203 Members | |
| 48 Servers |
| Sender | Message | Time |
|---|---|---|
| 29 May 2026 | ||
| So I ran into a `nullOr submodule` option (pixelfed.nginx) and the only way I've found to get at its options is `(head (head (services.pixelfed.nginx.type.functor.payload | 10:26:46 | |
| .elemType.functor.payload.modules)).imports).options` | 10:26:50 | |
| Is there a better way? I've been avoiding getSubOptions because it claims to be for documentation. I started out using `optionAttrSetToDocList` but that was too focused on documentation, meaning I needed to parse descriptions to get integer bounds information and such. | 10:28:59 | |
| I've just opened https://github.com/NixOS/nixpkgs/pull/525519 | 10:29:37 | |
getSubOptions doesn't help you if you want access to the actual options' definitions, highestPrio, etc from the merged submodule. Because getSubOptions is intended for documentation purposes, it only merges modules from the type instantiation; modules from config definitions are not considered. | 10:31:31 | |
| E.g.
| 10:38:39 | |
* I've just opened https://github.com/NixOS/nixpkgs/pull/525519 to address nullOr's v2 support, but there are other wrapper types we need to address too. | 10:44:25 | |
* toonn I've just opened https://github.com/NixOS/nixpkgs/pull/525519 to address nullOr's v2 support, but there are other wrapper types we need to address too. | 10:44:48 | |
| 11:06:10 | ||
| I am only interested in the definition of options though. I don't care what options someone specifies as part of an open submodule. Though I am interested in any freeformType restricting such extra options. | 11:21:15 | |
| So without nullOr's v2 support I am in fact stuck digging in the functor.payload, right? | 11:21:58 | |
| I feel like there's a subtle confusion going on here with what we mean by "definition". A submodule is just another configuration, within a wider configuration, evaluated mostly in isolation. Both the outer and sub configurations have modules, and those modules can contain config definitions for their respective configurations. When I say | 11:24:55 | |
| * I feel like there's a subtle confusion going on here with what we mean by "definition". A submodule is just another configuration, within a wider configuration, evaluated mostly in isolation. The submodule type merges to its configuration's Both the outer and sub configurations have modules, and those modules can contain config definitions for their respective configurations. When I say | 11:27:52 | |
| To oversimplify, a submodule-type's lifecycle is:
| 11:34:29 | |
| OK, so when I say definition, I mean the options defined in <nixpkgs/nixos/modules>. | 11:36:49 | |
| I am trying to derive possible options and their types for NixOS modules. | 11:37:40 | |
Just to double check, are we also confusing declaration vs definition? options.foo = lib.mkOption {} is a declaration, config.foo = {} is a definition. | 11:37:57 | |
| Sure, I'm interested in declared options and their types. | 11:39:40 | |
| 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 | |