I want to run some other linuxes on my host NixOS system, using lxd/lxc containers. I don’t see much documentation or examples on this, besides one blog post linked from wiki, which doesn’t answer all my questions.
For example, when I first install and run lxd and lxc, they advise to run lxd init if this is the first time running them on this system, which it is.
Is that the proper way to setup lxd in NixOS, or should that be done in configuration.nix instead? Seems too imperative, and like there should be a declarative config option.
AFAIK, currently in NixOS there is no proper (declarative) way to set up LXD. However, after some trial and error I have found a solution that seems to work reliably:
The trick is: lxd init can take a --preseed argument. Nix generates the preseed config and feeds this into lxd init as soon as the lxd.socket is available. Doing the lxd init again on an already initialized system seems to have no effect, just like I want it.