nixos-generators
nixos-generators copied to clipboard
auto-installer ISO?
This project seems like a nice way to install custom images on cloud services that don't allow image uploads (like vultr).
It would be nice if we could:
- make an ISO
- upload it to the cloud provider
- create a new VM with the ISO set as the boot drive
- if the VM disk isn't bootable:
- auto-install nixos by running a custom install script that does the partitioning etc (1)
- boot the VM (2)
The steps I don't know how to do are:
- Run a script before booting the VM
- Boot the VM when the ISO is set as boot drive
Thoughts?
If you can set the boot order to first boot on the HDD and then on the CD then it should work. The install script could be executed as a systemd unit on the ISO.
Vultr also support IPXE which might be an even nicer solution
maybe doing this via kexec would be more versatile? An iso upload function wouldn't be required then?
@zimbatm Hmm Vultr doesn't let you configure the boot order, so it would mean detaching the ISO after booting, which means some sort of back channel :( Maybe grub can be configured to auto-boot working hds?
IPXE does seem like an interesting option - is there a hosted nixos image somewhere to try it out?
@Lassulus For kexec, do you mean that the iso start script runs the hd image if possible? That would slow down the boot a little but it does mean full configurability 🤔
Ah, looks like grub can chain-load another grub.
Furthermore, it has if..then..else, meaning that it can probably be configured to try booting from the hd or maybe even reading the hd configuration, and if that fails boot into the auto-installer image…
Summoning @grahamc, the king of IPXE. See his work at https://github.com/grahamc/packet-nix-builder
I think the IPXE route is cleaner since it's really meant for that use-case. The ISO is probably there mostly for the manual install route where a stock ISO is needed. It also means that the ISO would stay attached as a device once the install is finished, not sure if that has some implications like creating a lock on the ISO file. I remember that there was some limit number of ISO (3?) that could be uploaded per account on Vultr.