1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 python3,
6 meson,
7 ninja,
8 pkg-config,
9 wrapGAppsHook4,
10 docutils,
11 desktopToDarwinBundle,
12 gtk-vnc,
13 vte,
14 dconf,
15 gobject-introspection,
16 libvirt-glib,
17 gsettings-desktop-schemas,
18 libosinfo,
19 adwaita-icon-theme,
20 gtksourceview4,
21 xorriso,
22 spiceSupport ? true,
23 spice-gtk ? null,
24 gst_all_1 ? null,
25}:
26
27let
28 pythonDependencies = with python3.pkgs; [
29 pygobject3
30 libvirt
31 libxml2
32 requests
33 ];
34in
35stdenv.mkDerivation rec {
36 pname = "virt-manager";
37 version = "5.0.0";
38
39 src = fetchFromGitHub {
40 owner = pname;
41 repo = pname;
42 rev = "v${version}";
43 hash = "sha256-KtB2VspkA/vFu7I8y6M8WfAoZglxmCeb4Z3OzdsGuvk=";
44 };
45
46 strictDeps = true;
47 mesonFlags = [
48 (lib.mesonBool "compile-schemas" false)
49 (lib.mesonEnable "tests" false)
50 ];
51
52 nativeBuildInputs = [
53 meson
54 ninja
55 gobject-introspection # for setup hook populating GI_TYPELIB_PATH
56 docutils
57 wrapGAppsHook4
58 pkg-config
59 ]
60 ++ lib.optional stdenv.hostPlatform.isDarwin desktopToDarwinBundle;
61
62 buildInputs = [
63 python3
64 libvirt-glib
65 vte
66 dconf
67 gtk-vnc
68 adwaita-icon-theme
69 gsettings-desktop-schemas
70 libosinfo
71 gtksourceview4
72 ]
73 ++ lib.optionals spiceSupport [
74 gst_all_1.gst-plugins-base
75 gst_all_1.gst-plugins-good
76 spice-gtk
77 ];
78
79 postInstall = ''
80 if ! grep -q StartupWMClass= "$out/share/applications/virt-manager.desktop"; then
81 echo "StartupWMClass=.virt-manager-wrapped" >> "$out/share/applications/virt-manager.desktop"
82 else
83 echo "error: upstream desktop file already contains StartupWMClass=, please update Nix expr" >&2
84 exit 1
85 fi
86 '';
87
88 preFixup = ''
89 glib-compile-schemas $out/share/gsettings-schemas/${pname}-${version}/glib-2.0/schemas
90
91 gappsWrapperArgs+=(--set PYTHONPATH "${python3.pkgs.makePythonPath pythonDependencies}")
92 # these are called from virt-install in installerinject.py
93 gappsWrapperArgs+=(--prefix PATH : "${lib.makeBinPath [ xorriso ]}")
94
95 patchShebangs $out/bin
96 '';
97
98 meta = with lib; {
99 homepage = "https://virt-manager.org";
100 description = "Desktop user interface for managing virtual machines";
101 longDescription = ''
102 The virt-manager application is a desktop user interface for managing
103 virtual machines through libvirt. It primarily targets KVM VMs, but also
104 manages Xen and LXC (linux containers).
105 '';
106 license = licenses.gpl2;
107 platforms = platforms.unix;
108 mainProgram = "virt-manager";
109 maintainers = with maintainers; [
110 fpletz
111 globin
112 ];
113 };
114}