Perhaps a dumb question, but why are NixOs and Guix configured using a programming language and not with a configuration file?
As a basic example, I could have a list of basic packages that I want on all of my machines, and then depending on which machine my config is being deployed to, I might extend or shrink that list using actual code, because that list is represented as a an array or a linked list and I can directly manipulate that (though, at least in Nix I think everything's immutable, so you would technically only use that initial list to create a new list from it).