I’m currently in the process of moving my server from a docker-compose stack to NixOs. I’m seeing a lot of my services in the NixOs options. Let’s take for instance services.tandoor-recipes and services.nextcloud.
Those two services both need a postgresql database in order to work. I tried to search in their options but it felt like there was nothing to configure the access to the database so I came to the hypothesis that they deal with it themselves. Is that true ? In the instance of tandoor-recipes I tried to find a mention of this in the sources file linked from search.nixos.org but couln’t, where am I supposed to find this ?
Finally, using my docker-compose stack I used to have 1 database container per service, in our case for instance that would mean 1 postgresql for tandoor and one for nextcloud. Is it what is done here ? Or is it even at all possible to have multiple postgresql instances ?
By default, NixOS modules access the same PostgreSQL instance but have their own database. They connect through a unix socket and Postgres verifies database access through the service user that made the connection. If you really want each to have their own Postgres instance, you could have a look at NixOS Containers - NixOS Wiki (but I don’t think you’ll need it).
I will take a look to your link cause it’s highly probable that part of my stack won’t be available directly on NixOs, typically Penpot is not yet packaged.
Following what you explained, I guess that means that there is a dependency between the postgresql service and the tandoor-recipes service. How could I have spotted it in the source files for the nixpkg ? What should I be looking for ?
I see ! Thank you very much for those explanations. So I guess this answer my questions: we are not supposed to have multiple instances of postgresql running and if I need this I’ll fall back to running docker containers then.
It’s not that you’re “not supposed to”, it’s just that NixOS modules will go with the simpler default and if you need something a bit more complex you can do that too.
if you need something a bit more complex you can do that too.
Okay, so you mean I could potentially decide that I want another postgresql instance spawned for my tandoor-recipes service? How could I achieve that, do you have any pointers as to how I could do something a bit more complex if I needed it?
Oh no sorry you meant the link to running containers in Nixos. I thought you were initially saying that if I wanted to I could spawn multiple instances of postgresql directly in NixOs without resorting to containers. Got it, thanks!
You can write your own PostgreSQL module that can run multiple PostgreSQL services on the same machine. It’s just not supported by the PostgreSQL module in NixOS.
https://search.nixos.org links to the implementation of the module in the nixpkgs repo which you could adapt for your needs.