Check out NixOs, it does exaxctly that.
Yeah, but with a whole shidoodle of extra abstraction and complexity that people have to learn and manage.
The subject has been discussed at length on HN multiple times and (IIRC) the consensus is generally the same, the disadvantages introduced by the complexity of NixOs outweigh its benefits.
I'll stick to old-fashioned distros for now.
> I would love to have this for an entire OS, not just networking. The ability to capture the entire OS configuration in one file would be amazing.
When you can do exactly that with NixOS.
In my experience it’s not hard to set up a basic configuration on NixOS. But it’s too hard to set up all of my development requirements on NixOS.