-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't merge hierarchical options into submodule (or freeform option) #146882
Comments
I don't think this is a bug, but it's very much something we should make easier. If we implement this, we should also implement the same functionality for submodules nested in {
# Adding a submodule to `options.foo`, which is an `attrsOf (submodule ...)`
options.foo = mkOption {
type = attrsOf (submodule ...);
};
} It would be nice if something like {
options.foo._ = ...;
options.foo."*" = ...;
options.foo."<name>" = ...;
} was supported. This could then of course also be used to declare the option in the first place. |
I would prefer for
We could. We'll be removing restrictions and it's ok to do one at a time. We should certainly consider it though. |
Isn't that the same behavior as assigning |
Here I actually know a use case for this, which I've encountered in the pre-commit-hooks.nix project, where you can generally do everything in the part of the tree that builds the config file, but some hooks have interesting options that you want to model. These are currently unintuitive to write and I don't know if they'd even end up in the docs. It's like {
config.systemd.services.foo = { ... }: {
options.fooSpecific = lib.mkOption {};
};
} whereas more natural would be {
options.systemd.services.foo.fooSpecific = lib.mkOption {};
} |
@infinisil I forgot about this limitation today. We should be able to do this: #155883 |
Possible fix in #156533 |
... where a bare submodule is an option that has a type like `submoduleWith x`, as opposed to `attrsOf (submoduleWith x)`. This makes migration unnecessary when introducing a freeform type in an existing option tree. Closes NixOS#146882
Describe the bug
Part of an option tree may be free-form.
Extending the free-form part in a separate module is hard and prevents certain use cases and migrations.
Steps To Reproduce
The submodule only exists in order to provide a freeform type for that subtree, but it is conceptually still the same tree.
Expected behavior
Additional context
A semi-workaround is to make writing the unnecessary module boundary easier.
However, this is needlessly complicated and it does not help in situations where a freeform type is introduced in a decentralized scenario.
Notify maintainers
@infinisil
Metadata
Maintainer information:
The text was updated successfully, but these errors were encountered: