NixOS Module System | 211 Members | |
| 51 Servers |
| Sender | Message | Time |
|---|---|---|
| 22 May 2026 | ||
I found where my error is. I need to override typeMerge as well since shallowing functor after the mkOptionType call won't affect the typeMerge field. | 21:53:07 | |
| Here is the updated working example in case it helps anyone in the future:
| 21:54:16 | |
| https://github.com/NixOS/nixpkgs/issues/396021 This limitation of addCheck is known. Fyi the more "idiomatic" way is to use mkOptionType to create a custom type such as it is done in lib/types.nix itself. | 22:06:04 | |
| Ah, for some reason I skipped over the link to that issue in the comment when reading. Thanks for the pointer. | 22:16:22 | |
| I haven't done a lot of thinking on this but is it possible to overcome this limitation by using some fixpoint mechanism like overlays? The problem seems to be that the type functor only has access to the type when it is defined (at the mkOptionType call site), not the type that is actually materalized (after all // updates). If the materialized type is accessible to the type functor, I think we can create a replica of the type. | 22:31:18 | |
| 23 May 2026 | ||
Maybe | 20:30:14 | |
| 24 May 2026 | ||
| 18:17:10 | ||
| 26 May 2026 | ||
| 05:42:37 | ||
| 11:41:58 | ||
| 27 May 2026 | ||
| 21:17:16 | ||
| 28 May 2026 | ||
| 02:06:27 | ||
| 29 May 2026 | ||
| 09:16:41 | ||
| 09:52:55 | ||
| 10:16:32 | ||
| 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 | |