I’ve been using NixOS on the desktop for a few months and want to use it more for servers as well. I wondered if there are original cloud images floating around? I’d like to add them to my Proxmox cluster as a template.
Currently, my workflow for deploying a Debian or Ubuntu machine is this:
Clone the Debian official cloud image;
Set cloudinit details;
Make disk larger;
Start the VM.
For NixOS, I currently don’t have a workflow like that.
Instead, I’ve done one or two VMs with nixos-generate and the minimal ISO, but it isn’t ideal. The thing is I’d like to offer the template to multiple users and things like username, ssh key and network configuration are fluid and can change with every deployment. Simply building an image with nixos-generate with hard-coded settings doesn’t cut it.
How are other people doing it? Am I missing something obvious?
You don’t have to hardcode the settings. We have a pve module that will let you create VMA files that can be directly restored as preconfigured VMs using qmrestore
Here’s a sample flake that shows the whole process of building and importing these cloud images:
Update the parameters in the let block and run nix run .#deploy to test it out.
If you don’t want to have to build the VMA yourself, hydra builds them too. However, they don’t have cloud-init enabled, and are kinda useless out of the box. I’ll open a PR to enable cloud init by default.
I noticed you specified some VM specific settings in your config. Mainly a name and core count.
The goal is to create a Proxmox template that me and other users can clone, and get access to via the settings issued through cloud-init. This makes it very fast for everyone to spin up new NixOS VMs and is more akin to our current workflow for Debian and Ubuntu images.
Problem is that I don’t want to have to prepare images beforehand. They should come from NixOS themselves. I think this can really help with the adoption.
Ubuntu, Debian, Fedora and other distributions already offer ready-to-go Cloud Images.
Some day, long after we’ve all turned to dust and returned to the earth, I hope this PR will get merged. On that day, our descendants can go to hydra.nixos.org to download the image named nixos.proxmoxCloudImage.x86_64-linux. They can also run nix build .#nixosConfogurations.<machine name>.config.system.build.proxmoxCloudImage. Meanwhile we will have to explicitly import the version of the module from my PR to be able to build this output.
I wish the image would not be Proxmox specific and that the first configuration.nix gets made by the cloud-init process.
I also wish NixOS itself would supply these images just like other major Linux distributions do. Like Ubuntu, Debian, Fedora.
The absence of cloud-init images is why I am not currently offering NixOS as an option in my VPS portal. I just don’t have the time to research and maintain the current way Nix does cloud images. I really hope that will change someday.