August 17th, 2024

Running NixOS on Proxmox LXC

Rui Carmo's article details running NixOS on Proxmox LXC, highlighting manual intervention needed for container creation, configuration adjustments for LXC, and plans for future enhancements like mDNS support.

Read original articleLink Icon
Running NixOS on Proxmox LXC

Rui Carmo's article discusses the process of running NixOS on Proxmox LXC, focusing on Intel machines. He chose to use a trunk image from Hydra, downloading the latest nixos-system-x86_64-linux.tar.xz tarball into the Proxmox cluster's shared storage. The container creation required manual intervention due to Proxmox's hooks not being present in the NixOS tarball. The author provided a command for creating the container, emphasizing the need to set the --ostype to unmanaged and adjust resource sizes and network settings. After creating the container, he encountered issues with the default configuration being set for LXD instead of LXC, necessitating the disabling of certain systemd units and editing the configuration.nix file. He updated the system, set a root password, and made necessary adjustments to the configuration, including enabling password-based SSH login for root and configuring networking settings. The article concludes with the author backing up the container for easier cloning and planning to revisit the setup for additional features like mDNS. He expressed surprise at the NixOS team's rapid shift towards LXD as the default container environment.

- The author documented the process of running NixOS on Proxmox LXC, focusing on Intel machines.

- Manual intervention was required during container creation due to missing Proxmox hooks in the NixOS tarball.

- The default configuration was set for LXD, requiring adjustments to work properly in LXC.

- The author updated the system and configured SSH and networking settings.

- Future plans include revisiting the setup for additional features.

Link Icon 5 comments
By @tylergetsay - 6 months
Its also possible to build the Proxmox container directly with nixos-generators, with the added bonus that you can configure the VM specs in nix as well

https://nixos.wiki/wiki/Proxmox_Virtual_Environment

By @pxc - 6 months
OrbStack (proprietary WSL and Docker Desktop clone for macOS with a GUI management application, very well made) uses LXC for all its 'Machine' guests, including NixOS.

Consequently, I can say that I use NixOS under LXC on aarch64 almost every day at work. :)

It runs perfectly well under LXC! NixOS also works well under WSL2 on Windows, though setting that up takes more footwork. If you're thinking about playing around with NixOS, virtualizing it— whether hardware or OS virtualization, whether on your laptop/desktop or in your homelab— is a great way to go.

By @Havoc - 6 months
Neat. Been meaning to try nixOS but couldn't figure out the LXC part
By @gallexme - 6 months
There is now also a project to run proxmox inside of Nixos

https://github.com/SaumonNet/proxmox-nixos