Convert NixOS configuration into an image?

So we have nixos-container for generating a chroot container, pkgs.dockerTools.buildImage for building a Docker image with Nix expression, but is it possible to build an image with NixOS’s configuration?

For example, I was reading about services.vikunja, this configuration is well written, and to translate this into a docker image manually takes some work. I will be awesome if we can use that to create a docker image right away.

Not only would this make a deployment with Docker easy, and those images can be run on other distro as well?

You can have a look to Arion. It allows to run NixOS configuration in Docker with some constraints.

Yes actually I have tried this and asked the author directly. They don’t seem to have a NixOS module right now, and arion now is mainly used for deploying to Non-NixOS system, if I understand it correctly.