1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 unstableGitUpdater,
6 autoreconfHook,
7 autoconf-archive,
8 bison,
9 flex,
10 glib,
11 pkg-config,
12 json_c,
13 libvirt,
14
15 withVMIFS ? true,
16 fuse,
17
18 legacyKVM ? false,
19 libkvmi,
20
21 xenSupport ? true,
22 xen,
23}:
24
25let
26 pname = "libvmi";
27 version = "0.14.0-unstable-2025-04-09";
28 libVersion = "0.0.15";
29
30 src = fetchFromGitHub {
31 owner = "libvmi";
32 repo = "libvmi";
33 rev = "872ccc6efac607b83b603fef691c3641656fed34";
34 hash = "sha256-8rqcDU4y86Uq6I7LOOMhMYWLEt7TxvzHilddUoutMOw=";
35 };
36in
37
38stdenv.mkDerivation {
39 inherit pname version src;
40
41 outputs = [
42 "out"
43 "lib"
44 "dev"
45 ];
46
47 nativeBuildInputs = [
48 autoreconfHook
49 autoconf-archive
50 bison
51 flex
52 pkg-config
53 ];
54
55 buildInputs = [
56 glib
57 json_c
58 libvirt
59 ]
60 ++ lib.optionals xenSupport [ xen ]
61 ++ lib.optionals (!legacyKVM) [ libkvmi ]
62 ++ lib.optionals withVMIFS [ fuse ];
63
64 configureFlags =
65 lib.optionals (!xenSupport) [ "--disable-xen" ]
66 ++ lib.optionals legacyKVM [ "--enable-kvm-legacy" ]
67 ++ lib.optionals withVMIFS [ "--enable-vmifs" ];
68
69 # libvmi uses dlopen() for the xen libraries, however autoPatchelfHook doesn't work here
70 postFixup = lib.optionalString xenSupport ''
71 libvmi="$lib/lib/libvmi.so.${libVersion}"
72 oldrpath=$(patchelf --print-rpath "$libvmi")
73 patchelf --set-rpath "$oldrpath:${lib.makeLibraryPath [ xen ]}" "$libvmi"
74 '';
75
76 passthru = {
77 updateScript = unstableGitUpdater { tagPrefix = "v"; };
78 inherit libVersion;
79 };
80
81 meta = {
82 description = "C library for virtual machine introspection";
83 longDescription = ''
84 LibVMI is a C library with Python bindings that makes it easy to monitor the low-level
85 details of a running virtual machine by viewing its memory, trapping on hardware events,
86 and accessing the vCPU registers.
87 '';
88 homepage = "https://libvmi.com/";
89 license = with lib.licenses; [
90 gpl3Only
91 lgpl3Only
92 ];
93 platforms = [ "x86_64-linux" ];
94 maintainers = with lib.maintainers; [ sigmasquadron ];
95 };
96}