How to refer to a item of a list by index in NixOS configuration

I have some service configurations like:

      services.sftpgo.settings.httpd.bindings = [
        { address = "0.0.0.0";
          port = 8080;
        }
      ];

Is there a way to refer to the port number via something like config.services.sftpgo.settings.httpd.bindings.0.port, e.g. in the firewall settings, in nginx reverse-proxy etc.?

(elemAt config.services.sftpgo.settings.httpd.bindings 0).port

Alternatively some combination of map and filter if you don’t want a specific binding.

3 Likes

Thanks! So, I didn’t miss any implicit nix syntax for list indexing.
PS: Actually, (builtins.elemAt ….

1 Like

Yeah, most functional languages don’t