1{ lib
2, stdenv
3, fetchurl
4, fetchpatch
5, meson
6, ninja
7, pkg-config
8, gettext
9, vala
10, libcap_ng
11, libvirt
12, libxml2
13, buildPackages
14, withIntrospection ? stdenv.hostPlatform.emulatorAvailable buildPackages
15, gobject-introspection
16, withDocs ? stdenv.hostPlatform == stdenv.buildPlatform
17, gtk-doc
18, docbook-xsl-nons
19}:
20
21stdenv.mkDerivation rec {
22 pname = "libvirt-glib";
23 version = "4.0.0";
24
25 outputs = [ "out" "dev" ] ++ lib.optional withDocs "devdoc";
26
27 src = fetchurl {
28 url = "https://libvirt.org/sources/glib/${pname}-${version}.tar.xz";
29 sha256 = "hCP3Bp2qR2MHMh0cEeLswoU0DNMsqfwFIHdihD7erL0=";
30 };
31
32 patches = [
33 # Fix build with GLib 2.70
34 (fetchpatch {
35 url = "https://gitlab.com/libvirt/libvirt-glib/-/commit/9a34c4ea55e0246c34896e48b8ecd637bc559ac7.patch";
36 sha256 = "UU70uTi55EzPMuLYVKRzpVcd3WogeAtWAWEC2hWlR7k=";
37 })
38 ];
39
40 nativeBuildInputs = [
41 meson
42 ninja
43 pkg-config
44 gettext
45 vala
46 gobject-introspection
47 ] ++ lib.optionals withIntrospection [
48 gobject-introspection
49 ] ++ lib.optionals withDocs [
50 gtk-doc
51 docbook-xsl-nons
52 ];
53
54 buildInputs = [
55 libvirt
56 libxml2
57 ] ++ lib.optionals stdenv.isLinux [
58 libcap_ng
59 ];
60
61 strictDeps = true;
62
63 # The build system won't let us build with docs or introspection
64 # unless we're building natively, but will still do a mandatory
65 # check for the dependencies for those things unless we explicitly
66 # disable the options.
67 mesonFlags = [
68 (lib.mesonEnable "docs" withDocs)
69 (lib.mesonEnable "introspection" withIntrospection)
70 ];
71
72 # https://gitlab.com/libvirt/libvirt-glib/-/issues/4
73 env.NIX_CFLAGS_COMPILE = toString [ "-Wno-error=pointer-sign" ];
74
75 meta = with lib; {
76 description = "Library for working with virtual machines";
77 longDescription = ''
78 libvirt-glib wraps libvirt to provide a high-level object-oriented API better
79 suited for glib-based applications, via three libraries:
80
81 - libvirt-glib - GLib main loop integration & misc helper APIs
82 - libvirt-gconfig - GObjects for manipulating libvirt XML documents
83 - libvirt-gobject - GObjects for managing libvirt objects
84 '';
85 homepage = "https://libvirt.org/";
86 license = licenses.lgpl2Plus;
87 platforms = platforms.unix;
88 };
89}