I’m getting a bit deeper into Nix, and I’m trying to translate the following setup to Nix-land.
I have a small web backend that connects to a postgres database. Using docker-compose, I’d probably have something like this:
-
docker-compose.yml
:
version: "3.9"
services:
web:
depends_on: ["db"]
build: .
ports:
- "8000:8000"
db:
image: "postgres"
- a
Dockerfile
that builds my Rust image.
What I have now is the following:
- a
flake.nix
that defines a default package built withpkgs.dockerTools.buildImage
. This image works fine if I load it with docker normally - a
arion-pkgs.nix
that is copy-pasted from the repo - an
arion-compose.nix
that looks like this:
{
services.db = {
service.image = "postgres";
service.volumes = [ "${toString ./.}/postgres-data:/var/lib/postgresql/data" ];
service.environment.POSTGRES_PASSWORD = "password";
};
services.backend = {
service.depends_on = [ "db" ];
services.image = "???";
};
}
The question I have is: “how do I tell services.backend
to use the docker image defined in my flake.nix
?”
Any help much appreciated