Shameless plug: Alternatively, if you are on NixOS, you can just use compose2nix.
https://github.com/aksiksi/compose2nix