Provisining from API?

I have a service documenting my network setup (netbox) which I’m currently using with Ansible to create configuration files for my Debian router. If I add a new subnet in netbox and run my Ansible playbook, I generate a new dnsmasq configuration containing this new subnet. I’m using netbox REST API for this.

What is a good way to do this in NixOS? I guess I can write a script that does the same thing, statically generating a configuration in nix format, but is there a preferred way? Any ideas or opinions?

I’ve been out of the Nix loop for a few years…