Compose2nix: Generate a NixOS config from a Docker Compose project

I’ve been working on a CLI tool that takes a Docker Compose project and converts into a NixOS config file consisting of oci-containers (Podman or Docker) and associated systemd services. This file can then be imported as-is as part of your NixOS configuration.

This tool is still early in development, but the basic functionality works. I would appreciate any feedback or input on what features you’d want to see in a tool like this. Also, any thoughts on how best to test the output of the tool on NixOS, ideally via GH Actions, are welcome!

Repo: GitHub - aksiksi/compose2nix: A tool to automatically generate a NixOS config from a Docker Compose project.

Sample input and output: GitHub - aksiksi/compose2nix: A tool to automatically generate a NixOS config from a Docker Compose project.

Thanks!

16 Likes

Cool!
This is like the inverse of arion, which takes NixOS configurations and runs them via docker-compose. (NixOS or plain Nix)
It does have a module that runs docker-compose in a systemd service. Probably that could be improved by replacing docker compose with compose2nix.
That’s kind of going full circle: a nixos-containers alternative that also runs non-NixOS containers.

4 Likes

Thanks for the pointer! I’m new to the Nix world, so will need to dig into arion a bit more!

Interesting. Two very different approaches. And I might be looking for yet another one:

In the NixOS config point to a number of docker-compose files - or maybe even just point to github location. And the module would just make sure to run the docker-compose files.

That does not exist yet - does it?

1 Like