How to declare complexe type in options

I’m trying to have only one hyprland config for my 2 setups that are similar. All that changes is the deives/monitprs I use so I decided to handle them via options. It works great as all option are basic types.

But for my monitors Id’ like to give more info. For now the monitors option is a list of string like below:

options = {
    host = {
      # Some other options

      devices = {
        monitors = lib.mkOption {
          type = lib.types.listOf lib.types.str;

And I can reference it in my config with builtins.elemAt 0.

But I’d like for the option to be a list of complex type so i can call:
(builtins.elemAt 0).id
(builtins.elemAt 0).width
(builtins.elemAt 0).height.

I tried with type = lib.types.listOf lib.types.attrsOf lib.types.anything; but that does not work. From the doc it seems possible, but I don’t understand what I’m supposed to put after the attrsOf… How can I declare my custom type ?

It sounds like lib.types.submodule might be what you’re looking for. I’m using it here for a similar purpose.

1 Like

It’s probably that ! Thanks a lot