LXD on NixOS (containers with shell)


Yes, very nice stuff! I recently used nixos-generators to create an lxc image that starts up, performs a task, and shuts down again.

The image is intended to be deployed on a non-NixOS server later, but testing it locally on my NixOS machine with lxd was pretty straightforward.

My configuration so far is https://github.com/raboof/mastodon-bot-nixos/blob/78a656c9a5a864be7a19789edf49f1daa3a547dc/configuration.nix#L62. There is some complexity there, but that’s mostly due to building and compiling the (npm+clojurescript) program I want to run down to javascript.

Overall I found the experience very nice. Great how only the ‘run-time closure’ of the system as calculated by Nix needs to be included in the image. The default configuration is still a bit overkill (mostly systemd), but I didn’t see to override bootStage2 with something leaner (Replacing the bootStage2). Anyway it’s not too bad as it is :wink: .

I suspect this is missing the initial init step.