1{ lib, fetchFromGitHub, python3, intltool, file, wrapGAppsHook, gtk-vnc
2, vte, avahi, dconf, gobject-introspection, libvirt-glib, system-libvirt
3, gsettings-desktop-schemas, gst_all_1, libosinfo, gnome, gtksourceview4, docutils, cpio
4, e2fsprogs, findutils, gzip, cdrtools, xorriso, fetchpatch
5, desktopToDarwinBundle, stdenv
6, spiceSupport ? true, spice-gtk ? null
7}:
8
9python3.pkgs.buildPythonApplication rec {
10 pname = "virt-manager";
11 version = "4.1.0";
12
13 src = fetchFromGitHub {
14 owner = pname;
15 repo = pname;
16 rev = "v${version}";
17 hash = "sha256-UgZ58WLXq0U3EDt4311kv0kayVU17In4kwnQ+QN1E7A=";
18 };
19
20 nativeBuildInputs = [
21 intltool file
22 gobject-introspection # for setup hook populating GI_TYPELIB_PATH
23 docutils
24 wrapGAppsHook
25 ] ++ lib.optional stdenv.isDarwin desktopToDarwinBundle;
26
27 buildInputs = [
28 gst_all_1.gst-plugins-base
29 gst_all_1.gst-plugins-good
30 libvirt-glib vte dconf gtk-vnc gnome.adwaita-icon-theme avahi
31 gsettings-desktop-schemas libosinfo gtksourceview4
32 ] ++ lib.optional spiceSupport spice-gtk;
33
34 propagatedBuildInputs = with python3.pkgs; [
35 pygobject3 libvirt libxml2 requests cdrtools
36 ];
37
38 postPatch = ''
39 sed -i 's|/usr/share/libvirt/cpu_map.xml|${system-libvirt}/share/libvirt/cpu_map.xml|g' virtinst/capabilities.py
40 sed -i "/'install_egg_info'/d" setup.py
41 '';
42
43 postConfigure = ''
44 ${python3.interpreter} setup.py configure --prefix=$out
45 '';
46
47 setupPyGlobalFlags = [ "--no-update-icon-cache" "--no-compile-schemas" ];
48
49 dontWrapGApps = true;
50
51 preFixup = ''
52 glib-compile-schemas $out/share/gsettings-schemas/${pname}-${version}/glib-2.0/schemas
53
54 gappsWrapperArgs+=(--set PYTHONPATH "$PYTHONPATH")
55 # these are called from virt-install in initrdinject.py
56 gappsWrapperArgs+=(--prefix PATH : "${lib.makeBinPath [ cpio e2fsprogs file findutils gzip ]}")
57
58 makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
59
60 # Fixes testCLI0051virt_install_initrd_inject on Darwin: "cpio: root:root: invalid group"
61 substituteInPlace virtinst/install/installerinject.py \
62 --replace "'--owner=root:root'" "'--owner=0:0'"
63 '';
64
65 nativeCheckInputs = with python3.pkgs; [
66 pytestCheckHook
67 cpio
68 cdrtools
69 xorriso
70 ];
71
72 disabledTests = [
73 "testAlterDisk"
74 "test_misc_nonpredicatble_generate"
75 "test_disk_dir_searchable" # does something strange with permissions
76 "testCLI0001virt_install_many_devices" # expects /var to exist
77 ];
78
79 preCheck = ''
80 export HOME=.
81 ''; # <- Required for "tests/test_urldetect.py".
82
83 postCheck = ''
84 $out/bin/virt-manager --version | grep -Fw ${version} > /dev/null
85 '';
86
87 meta = with lib; {
88 homepage = "https://virt-manager.org";
89 description = "Desktop user interface for managing virtual machines";
90 longDescription = ''
91 The virt-manager application is a desktop user interface for managing
92 virtual machines through libvirt. It primarily targets KVM VMs, but also
93 manages Xen and LXC (linux containers).
94 '';
95 license = licenses.gpl2;
96 platforms = platforms.unix;
97 mainProgram = "virt-manager";
98 maintainers = with maintainers; [ qknight offline fpletz globin ];
99 };
100}