@voydus
I’m very new to Nixos, and I’m trying to get this whole cloud-init
image to work with Proxmox, but I can’t figure out where the configuration.nix
file is for this template, as it’s not in the normal /etc/nixos/
. Is it possible to use this as a barebones template and then after I’ve setup the VM, change the configuration file and switch to that configuration file?
What I’m trying to do is use the whole cloud-init structure to have a barebones nixos that I will then modify the configuration.nix
& hardware-configuration.nix
on after creation (scp
it up since I now have an available username and ssh key thanks to cloud-init
) to automate installing nixos with a bunch of stuff I want setup.
Anyway, the issue I’m having is I don’t know where to find the configuration.nix
file on this cloud-init
installation. I have a suspicion that there isn’t one, and this image is setup specifically “just” for what was setup in the flake, and I don’t know enough on how to modify the flake to do this (or if this is even possible)
Can anyone help out? Is what I want to do possible?
NOTES - If it helps anyone else (@MatthieuB ?), here’s the steps I did to build this image and get it running on proxmox:
# Build flake image
nix --experimental-features 'nix-command flakes' build .#image
# cd to the 'results' folder (that's where the image gets created)
cd results
# Get shell with 'qemu-img'
nix-shell -p qemu
# Convert the 'qcow2' to 'img'
qemu-img convert nixos.qcow2 -O raw nixos.img
Next you have to somehow get that image over to a folder in Proxmox (I just used Filezilla to grab it via ssh)
To create a template from the image (these commands run on Proxmox where you’ve uploaded the img
file):
qm create 9001 --memory 2048 --core 2 --name nixos-23.11-kvm --net0 virtio,bridge=vmbr0
qm importdisk 9001 nixos.img local-lvm
qm set 9001 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-9001-disk-0
qm set 9001 --ide2 local-lvm:cloudinit
qm set 9001 --boot c --bootdisk scsi0
qm set 9001 --serial0 socket --vga serial0
qm set 9001 --ipconfig0 ip=dhcp
qm template 9001
If I set the username when I create from template to ops
(the name setup in the above flake) I get it to work fine. Trying other usernames didn’t seem to work.
However, in the above, I can’t get to the VM via the Console
option in Proxmox, I think the flake needs to be modified somehow to add a serial socket connection or something. However, as long as you’ve setup an ssh key, you can access it via ssh fine.