Datacenter abstraction/Service discovery?

I have all my systems in one flake. GitHub - tbaumann/nix-conf: My nix config

I was wondering if there is a way to refer to other systems in the flake, and perhaps a generic way to discover services and ports.

The nix-topology module does some of it. But especially the service discovery is entirely manual.

For example. I have prometheus-node-exporter enabled on all my systems. I would like to have a scrape entry for every system automatically.
Right now I do this. nix-conf/hosts/nas/default.nix at ada81cf338e9cc2d41664d356da9096ef1b750dd · tbaumann/nix-conf · GitHub but it’s not exactly elegant.

In this case I would for example like to iterate all hosts and iterate all exporters that are enabled = true and use the port attribute.

Similar with this nonsense. nix-conf/common/services/homepage.nix at ada81cf338e9cc2d41664d356da9096ef1b750dd · tbaumann/nix-conf · GitHub

Looks like this guy did it via NixOps. GitHub - mayflower/nixexprs: Public, Opinionated Mayflower NixOS Modules/Packages and other Expressions

Not sure I can easily copy his homework. But maybe…