NixOS as a Proxmox LXC
It should be straightforward to setup NixOS on a Proxmox LXC, right? Well, apparently not.
For starters, the latest Proxmox documentation here flat out didn’t work for me but the out of date one here did after a few tweaks. Here are the steps I took for my future self.
Step 1 #
Get one of the latest, and appropriate, container builds from here and upload to Proxmox as an LXC template.
Step 2 #
Create a new container through PVE shell:
pct create $(pvesh get /cluster/nextid) \
--arch amd64 \
local:vztmpl/nixos-system-x86_64-linux.tar.xz \
--ostype unmanaged \
--net0 name=eth0,bridge=vmbr0,firewall=1,tag=20 \
--storage local-lvm \
--unprivileged 1 \
--features nesting=1 \
--cmode console \
--onboot 1
For me, even when I set static IP through Proxmox, the container ignored that and used DHCP. So, I plan to fix that through Nix configuration later.
Step 3 #
Fix resource configuration (for e.g., memory, disk space etc.) through Proxmox UI, if required, start the container, run the following inside it and reboot:
nix-channel --update
Step 5 #
Hold on, you aren’t done yet. While you can access the container through the console, you still can’t SSH into it.
Set a root password by:
passwd
Add the following by doing a nano /etc/nixos/configuration.nix
. (This is, of course, insecure. Do it temporarily, just to get SSH from personal machine working, and then update.)
services.openssh = {
enable = true;
settings.PasswordAuthentication = true;
settings.PermitRootLogin = "yes";
};
And then:
nixos-rebuild switch
Finally, do an ifconfig
to find the IP address and then SSH with:
ssh root@IP