Deploying existing nix-managed docker image using arion

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"
    depends_on: ["db"]
    build: .
      - "8000:8000"
    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 with pkgs.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 :grin:

Did you ever figure this out? I’m in the same spot.

The author opened an issue in github and got a response there.

What I ended up putting in configuration.nix:

  virtualisation.arion = {
    backend = "docker";
    projects.appName.settings = {
      # Specify you project here, or import it from a file.
      # NOTE: This does NOT use ./arion-pkgs.nix, but defaults to NixOS' pkgs.
      imports = [ ./arion-compose.nix ];

This works with using flakes for system configuration.