Virt-manager: Difference between revisions

From NixOS Wiki
imported>The-furry-hubofeverything
m Added note to explain dconf, numerous issues were created on nixpkgs were related to this
imported>The-furry-hubofeverything
Module upstreamed and available for unstable
Line 2: Line 2:


=== NixOS ===
=== NixOS ===
Before 23.11:
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
virtualisation.libvirtd.enable = true;
virtualisation.libvirtd.enable = true;
Line 7: Line 8:
environment.systemPackages = with pkgs; [ virt-manager ];
environment.systemPackages = with pkgs; [ virt-manager ];
</syntaxhighlight>
</syntaxhighlight>
After 23.11:
<syntaxhighlight lang="nix">
virtualisation.libvirtd.enable = true;
programs.virt-manager.enable = true;
</syntaxhighlight>
See [https://github.com/NixOS/nixpkgs/pull/261474 relevant merge request]


You will get a warning when you open it for the first time
You will get a warning when you open it for the first time

Revision as of 09:38, 25 October 2023

Installation

NixOS

Before 23.11:

virtualisation.libvirtd.enable = true;
programs.dconf.enable = true; # virt-manager requires dconf to remember settings
environment.systemPackages = with pkgs; [ virt-manager ];

After 23.11:

virtualisation.libvirtd.enable = true;
programs.virt-manager.enable = true;

See relevant merge request


You will get a warning when you open it for the first time

Could not detect a default hypervisor. Make sure the appropriate QEMU/KVM virtualization packages are installed to manage virtualization on this host.

A virtualization connection can be manually added via File->Add Connection

To resolve

File (in the menu bar) -> Add connection

HyperVisor = QEMU/KVM
Autoconnect = checkmark

Connect

The same can also be achieved decoratively by setting the corresponding dconf settings with home-manager. If you want to do this instead of the imperative configuration described above, add the following snippet to your home-manager configuration:

dconf.settings = {
  "org/virt-manager/virt-manager/connections" = {
    autoconnect = ["qemu:///system"];
    uris = ["qemu:///system"];
  };
};

You can get the following error :

authentication unavailable: no polkit agent available to authenticate action 'org.libvirt.unix.manage'

To resolve, add the user to the libvirtd group.

{
  users.users.<myuser>.extraGroups = [ "libvirtd" ];
}