A few notes on running NixOS VMs and containers

After many years, I recently rediscovered NixOS. It has come a long way and I am impressed with the project. It is a natural fit for me and my technology stack. In particular, it is replacing distrobuilder, debian and cloud-init. Together with OpenToFu everything is now just code.

There were a few things that took me a while to figure out, though.

When you deploy a container from the public image server for Incus and LXC you have to enable nesting. When you deploy a VM you have to disable secure boot.

For both of them, after the instance first boots you have to run nixos-rebuild switch then reboot the instance.

With that working, now you can configure the entire system by editing a single NixOS configuration file and rebuilding.

Is anyone else also working with NixOS? There might be some other topics worth mentioning.

Yes, i am using OpenTofu and NixOS too. Migrated my homeserver setup to terranix just a few months ago.

Replaced my Debian instances with NixOS instances.

The “killer”-feature would be the same logic cloud-init is using and make it possible to supply the configuration.nix and trigger nixos-rebuild switch on instance start :wink:

1 Like

Thanks for the link. That is a new one for me. :slight_smile: I bet there are other tools and projects out there to discover. I will post here if I find anything else Incus and NixOS related.