Right now, there doesn’t seem to be a nice way to add or configure a system service programmatically, other than parsing the config file, making the changes, and exporting, which is generally not ideal.
It would be nice to have a standard config.d directory, that one could expect on any NixOS install, contents of which would be imported to config.nix.
That way, configuration could be fully modular, neatly programmatically installable, and potentially, could allow replacing the nix-env installation with a new command, that just adds a home-manager config file to a specific folder, which declares the package should be there.
It would be nice to have a standard config.d directory, that one could expect on any NixOS install, contents of which would be imported to config.nix.
This is possible to implement in pure Nix using builtins.readDir. Importing from readDir is banned in Nixpkgs so its hard to find examples, but you are free to do this for your own config.
Not all NixOS installs contain their own configuration expressions.
For example, you can deploy it from a different machine using nixos-rebuild --target-host, or with flakes, it resides wherever the flake is.
Of course you can equally well have such a convention for flakes and such.