After everything was setup I found that most of the services are available as NixOS options, which made me ask: if a NixOS service is already available, when should docker be used?
I consider services that depend on sane/common dependencies, and only export some ports for communication as trivial. Examples are nginx, murmur, mpd, etc. Trivial services I’m alright with running as NixOS services. But non-trivial services — i.e., the HTPC environment listed above that expose web interfaces, depend on Mono/PHP, etc. — I consider running in Docker instead: because of their relative complexity I want these services only to access a bare minimum of system resources. A trivial service can also be a bad actor, but then I might as well dockerize all my services, and that offers up a lot of the convenience of using NixOS (unless there is some way to nest NixOS systems declaratively).
Thoughs? Are there any services you only run in a Docker? Why?
I use NixOS services as much as possible, because I can use socket communication and inspect services using systemctl and journalctl instead of having to go into the containers all the time. Also, I can have a much more declarative setup using all the NixOS options. AFAIK most of the containers only have a small subset of these options that are defined by environment variables.
The only thing I use containers for is gluetun which isolates other containers in a VPN network. So gluetun and services that use it are podman containers in my setup. Gluetun was easy to set up and I decided to save time here.
That should be possible with containers as well.
At least in a limited form.
E.g. I can inspect the logs of my Nextcloud container with journalctl -u docker-nextcloud.service.
NixOS services, because they are systemd services, also support some isolation features (NixOS policy regarding systemd-confinement, DynamicUser and a whole host of other options), but so far I’ve not found that particularly easy to use