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.