How can I build a VM image with nix deployment tools?

I’m stuck in a time loop and I need some pointers.

I want to deploy NixOS to x86 and Raspberry Pi, but I want to load the image in a VM first, like QEMU, so that I can inspect the Window Manager, so I need a GUI.

I have built images with nixos-generator, but there was no path forward for deployment, like over SSH.

I also have tried using nixos-anywhere, but I’m stuck on getting help here unless some of you good folks have some pointers.

I heard about Nixinate, but found no starting point for a beginner.

I’m a bit stuck, so any other tools or tutorials I can give a shot?

Try the tutorials on nix.dev, possibly starting with the one on building VMs:

https://nix.dev/tutorials/nixos/nixos-configuration-on-vm

Feel free to make PRs if you find errors or come up with useful additions (such as meaningful links between tutorials).

This seems to lack the

deploy NixOS to x86 and Raspberry Pi

…part.

I have no problems creating an image and transferring it to the Pi, but I want something like nixos-anywhere, where I deploy with SSH. I assumed deploy meaning that you can script the deployment, like over the network, so sorry if that was not clear from the question.

Also, does this guide assist with deploying NixOS programmatically over the network to nodes on my network, like the Pi?

To answer your immediate question about deployment: Once you have an image built and tested, you should be able to install it with nixos-anywhere. That image should include authorised SSH keys, so then you can deploy by running nixos-rebuild --target $target_machine.

About the guides, we currently don’t have those, but contributions with tested workflows are highly appreciated. It will likely take a while until the documentation team gets to those issues given our current capacities, because conceptually this topic is advanced and there are multiple half-baked solutions full of holes out there that need to be evaluated and condensed to something that actually works and puts people on a sustainable path. For instance nixos-rebuild is really simple-minded and probably doesn’t scale well beyond a handful of machines.

This is about initial installation, right? Because if you just want to deploy new versions of your system config to the Pi without building it there, you might find it easier to copy the system closure (the set of store paths that make up the system) to the Pi over SSH or set up remote building on the Pi.

Case in point that there are many ways of doing things, with different trade-offs, setup complexity, support status, and quality of documentation.

1 Like