Proxmox Virtual Environment: Difference between revisions

imported>Benley
Patching pve-container: pve-container 4.1-5 has been released with the nixos fixes
imported>Tpwrules
update for recent versions and show configuration
Line 1: Line 1:
<blockquote>As of the date of writing this page (6 March 2022) nixos-unstable has the necessary changes. The changes needed to proxmox for supporting NixOS LXCs have been merged upstream, but a new release of pve-container with these changes is not available yet. To patch an older version of proxmox to support nixos, see the “patching pve-container” section below.
<blockquote>These instructions should work for Proxmox 7.2 and later with NixOS 22.05 and later. Users of previous versions may need to patch pve-container to use NixOS LXC images (instructions are below too).
</blockquote>
</blockquote>
= KVM =
= KVM =
Line 54: Line 54:


= LXC =
= LXC =
== Generating LXC template ==
<pre>nix run github:nix-community/nixos-generators -- --format proxmox-lxc</pre>
== Privileged LXCs ==
While it’s not necessary, <code>proxmoxLXC.privileged</code> can be set to true to enable the DebugFS mount in privileged LXCs. If enabled on unprivileged LXCs, this will fail to mount.
== Network configuration ==
The proxmox LXC template uses systemd-networkd by default to allow network configuration by proxmox. <code>proxmoxLXC.manageNetwork</code> can be set to true to disable this.
== deploying on proxmox ==
Copy the tarball to proxmox, then create a new LXC with this template through the web UI or the CLI. The “nesting” feature needs to be enabled. Newer versions of proxmox will have it enabled by default.
As of now, not all of the configuration options on the web UI work for proxmox LXCs. Network configuration and adding SSH keys to root user work, while setting a password for the root user and setting hostname don’t.
The template built above without any options does not come with <code>/etc/nixos/configuration.nix</code>. A minimal working example is presented below. Be sure to run <code>nix-channel --update</code> before <code>nixos-rebuild switch</code>.
<pre>{ pkgs, modulesPath, ... }:
{
  imports = [
    (modulesPath + "/virtualisation/proxmox-lxc.nix")
  ];
  environment.systemPackages = [
    pkgs.vim
  ];
}</pre>


== Patching pve-container ==
== Patching pve-container ==
Line 124: Line 155:
<pre>root@pve:~# ls /usr/share/perl5/PVE/LXC/Setup/NixOS.pm
<pre>root@pve:~# ls /usr/share/perl5/PVE/LXC/Setup/NixOS.pm
/usr/share/perl5/PVE/LXC/Setup/NixOS.pm</pre>
/usr/share/perl5/PVE/LXC/Setup/NixOS.pm</pre>
== Generating LXC template ==
<pre>nix run github:nix-community/nixos-generators -- --format proxmox-lxc</pre>
== Privileged LXCs ==
While it’s not necessary, <code>proxmoxLXC.privileged</code> can be set to true to enable the DebugFS mount in privileged LXCs. If enabled on unprivileged LXCs, this will fail to mount.
== Network configuration ==
The proxmox LXC template uses systemd-networkd by default to allow network configuration by proxmox. <code>proxmoxLXC.manageNetwork</code> can be set to true to disable this.
== deploying on proxmox ==
Copy the tarball to proxmox, then create a new LXC with this template through the web UI or the CLI. The “nesting” feature needs to be enabled. Newer versions of proxmox will have it enabled by default.
As of now, not all of the configuration options on the web UI work for proxmox LXCs. Network configuration and adding SSH keys to root user work, while setting a password for the root user and setting hostname don’t.