Merge pull request #164078 from lovesegfault/libvirt-refactor

libvirt: refactor
This commit is contained in:
Bernardo Meurer 2022-03-14 10:11:03 -07:00 committed by GitHub
commit f7353740ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 273 additions and 181 deletions

View file

@ -1,4 +1,4 @@
From a896b0be849455edb83a9305dfec9b41447ef3e4 Mon Sep 17 00:00:00 2001 From a6593bf70dd5f91acc7c2795d658a49eb9d4f672 Mon Sep 17 00:00:00 2001
From: Euan Kemp <euank@euank.com> From: Euan Kemp <euank@euank.com>
Date: Thu, 14 Jan 2021 00:32:00 -0800 Date: Thu, 14 Jan 2021 00:32:00 -0800
Subject: [PATCH] meson: patch in an install prefix for building on nix Subject: [PATCH] meson: patch in an install prefix for building on nix
@ -8,20 +8,21 @@ the nix store, but read them from the root filesystem.
--- ---
meson.build | 9 +++++++++ meson.build | 9 +++++++++
meson_options.txt | 2 ++ meson_options.txt | 2 ++
src/ch/meson.build | 4 ++--
src/libxl/meson.build | 6 +++--- src/libxl/meson.build | 6 +++---
src/locking/meson.build | 8 ++++---- src/locking/meson.build | 8 ++++----
src/lxc/meson.build | 6 +++--- src/lxc/meson.build | 6 +++---
src/meson.build | 18 +++++++++--------- src/meson.build | 18 +++++++++---------
src/network/meson.build | 12 ++++++------ src/network/meson.build | 10 +++++-----
src/nwfilter/xml/meson.build | 2 +- src/nwfilter/xml/meson.build | 2 +-
src/qemu/meson.build | 14 +++++++------- src/qemu/meson.build | 14 +++++++-------
src/remote/meson.build | 6 +++--- src/remote/meson.build | 6 +++---
src/security/apparmor/meson.build | 8 ++++---- src/security/apparmor/meson.build | 8 ++++----
tools/meson.build | 4 ++-- tools/meson.build | 4 ++--
12 files changed, 53 insertions(+), 42 deletions(-) 13 files changed, 54 insertions(+), 43 deletions(-)
diff --git a/meson.build b/meson.build diff --git a/meson.build b/meson.build
index b5164f6..33719f1 100644 index ad0cd44aca..bdd87c926a 100644
--- a/meson.build --- a/meson.build
+++ b/meson.build +++ b/meson.build
@@ -39,6 +39,8 @@ if host_machine.system() == 'windows' @@ -39,6 +39,8 @@ if host_machine.system() == 'windows'
@ -48,7 +49,7 @@ index b5164f6..33719f1 100644
# sysconfdir as this makes a lot of things break in testing situations # sysconfdir as this makes a lot of things break in testing situations
if prefix == '/usr' if prefix == '/usr'
diff --git a/meson_options.txt b/meson_options.txt diff --git a/meson_options.txt b/meson_options.txt
index e5d79c2..081cd32 100644 index 5b43cdbd6b..e9dff18441 100644
--- a/meson_options.txt --- a/meson_options.txt
+++ b/meson_options.txt +++ b/meson_options.txt
@@ -1,3 +1,5 @@ @@ -1,3 +1,5 @@
@ -57,8 +58,22 @@ index e5d79c2..081cd32 100644
option('no_git', type: 'boolean', value: false, description: 'Disable git submodule update') option('no_git', type: 'boolean', value: false, description: 'Disable git submodule update')
option('packager', type: 'string', value: '', description: 'Extra packager name') option('packager', type: 'string', value: '', description: 'Extra packager name')
option('packager_version', type: 'string', value: '', description: 'Extra packager version') option('packager_version', type: 'string', value: '', description: 'Extra packager version')
diff --git a/src/ch/meson.build b/src/ch/meson.build
index e34974d56c..4767763c2c 100644
--- a/src/ch/meson.build
+++ b/src/ch/meson.build
@@ -68,7 +68,7 @@ if conf.has('WITH_CH')
}
virt_install_dirs += [
- localstatedir / 'lib' / 'libvirt' / 'ch',
- runstatedir / 'libvirt' / 'ch',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'ch',
+ install_prefix + runstatedir / 'libvirt' / 'ch',
]
endif
diff --git a/src/libxl/meson.build b/src/libxl/meson.build diff --git a/src/libxl/meson.build b/src/libxl/meson.build
index 3bb6cc5..78d7be0 100644 index 9793899106..4904387162 100644
--- a/src/libxl/meson.build --- a/src/libxl/meson.build
+++ b/src/libxl/meson.build +++ b/src/libxl/meson.build
@@ -84,8 +84,8 @@ if conf.has('WITH_LIBXL') @@ -84,8 +84,8 @@ if conf.has('WITH_LIBXL')
@ -74,7 +89,7 @@ index 3bb6cc5..78d7be0 100644
] ]
endif endif
diff --git a/src/locking/meson.build b/src/locking/meson.build diff --git a/src/locking/meson.build b/src/locking/meson.build
index 8a28310..9da81cc 100644 index 184d3c3f56..7ffd3740e3 100644
--- a/src/locking/meson.build --- a/src/locking/meson.build
+++ b/src/locking/meson.build +++ b/src/locking/meson.build
@@ -243,14 +243,14 @@ if conf.has('WITH_LIBVIRTD') @@ -243,14 +243,14 @@ if conf.has('WITH_LIBVIRTD')
@ -97,10 +112,10 @@ index 8a28310..9da81cc 100644
endif endif
endif endif
diff --git a/src/lxc/meson.build b/src/lxc/meson.build diff --git a/src/lxc/meson.build b/src/lxc/meson.build
index f8e2a88..96d6687 100644 index ad5c659dba..8010dfbf02 100644
--- a/src/lxc/meson.build --- a/src/lxc/meson.build
+++ b/src/lxc/meson.build +++ b/src/lxc/meson.build
@@ -182,8 +182,8 @@ if conf.has('WITH_LXC') @@ -181,8 +181,8 @@ if conf.has('WITH_LXC')
} }
virt_install_dirs += [ virt_install_dirs += [
@ -113,7 +128,7 @@ index f8e2a88..96d6687 100644
] ]
endif endif
diff --git a/src/meson.build b/src/meson.build diff --git a/src/meson.build b/src/meson.build
index 7c47821..d33d16a 100644 index 2bd88e6699..76df507968 100644
--- a/src/meson.build --- a/src/meson.build
+++ b/src/meson.build +++ b/src/meson.build
@@ -669,7 +669,7 @@ endforeach @@ -669,7 +669,7 @@ endforeach
@ -176,10 +191,10 @@ index 7c47821..d33d16a 100644
meson.add_install_script( meson.add_install_script(
diff --git a/src/network/meson.build b/src/network/meson.build diff --git a/src/network/meson.build b/src/network/meson.build
index 3ec598c..b02040b 100644 index d6fb624bb7..96b757b144 100644
--- a/src/network/meson.build --- a/src/network/meson.build
+++ b/src/network/meson.build +++ b/src/network/meson.build
@@ -79,9 +79,9 @@ if conf.has('WITH_NETWORK') @@ -78,9 +78,9 @@ if conf.has('WITH_NETWORK')
} }
virt_install_dirs += [ virt_install_dirs += [
@ -192,7 +207,7 @@ index 3ec598c..b02040b 100644
] ]
configure_file( configure_file(
@@ -89,12 +89,12 @@ if conf.has('WITH_NETWORK') @@ -88,12 +88,12 @@ if conf.has('WITH_NETWORK')
output: '@BASENAME@', output: '@BASENAME@',
copy: true, copy: true,
install: true, install: true,
@ -208,7 +223,7 @@ index 3ec598c..b02040b 100644
) )
diff --git a/src/nwfilter/xml/meson.build b/src/nwfilter/xml/meson.build diff --git a/src/nwfilter/xml/meson.build b/src/nwfilter/xml/meson.build
index 0d96c54..66c92a1 100644 index 0d96c54ebe..66c92a1016 100644
--- a/src/nwfilter/xml/meson.build --- a/src/nwfilter/xml/meson.build
+++ b/src/nwfilter/xml/meson.build +++ b/src/nwfilter/xml/meson.build
@@ -25,4 +25,4 @@ nwfilter_xml_files = [ @@ -25,4 +25,4 @@ nwfilter_xml_files = [
@ -218,7 +233,7 @@ index 0d96c54..66c92a1 100644
-install_data(nwfilter_xml_files, install_dir: sysconfdir / 'libvirt' / 'nwfilter') -install_data(nwfilter_xml_files, install_dir: sysconfdir / 'libvirt' / 'nwfilter')
+install_data(nwfilter_xml_files, install_dir: install_prefix + sysconfdir / 'libvirt' / 'nwfilter') +install_data(nwfilter_xml_files, install_dir: install_prefix + sysconfdir / 'libvirt' / 'nwfilter')
diff --git a/src/qemu/meson.build b/src/qemu/meson.build diff --git a/src/qemu/meson.build b/src/qemu/meson.build
index 90640b0..8802cec 100644 index 3898d23877..c2a2675187 100644
--- a/src/qemu/meson.build --- a/src/qemu/meson.build
+++ b/src/qemu/meson.build +++ b/src/qemu/meson.build
@@ -171,12 +171,12 @@ if conf.has('WITH_QEMU') @@ -171,12 +171,12 @@ if conf.has('WITH_QEMU')
@ -242,7 +257,7 @@ index 90640b0..8802cec 100644
] ]
endif endif
diff --git a/src/remote/meson.build b/src/remote/meson.build diff --git a/src/remote/meson.build b/src/remote/meson.build
index 9ad2f6a..429a15b 100644 index 0a188268b5..702822612e 100644
--- a/src/remote/meson.build --- a/src/remote/meson.build
+++ b/src/remote/meson.build +++ b/src/remote/meson.build
@@ -245,7 +245,7 @@ if conf.has('WITH_REMOTE') @@ -245,7 +245,7 @@ if conf.has('WITH_REMOTE')
@ -273,10 +288,10 @@ index 9ad2f6a..429a15b 100644
) )
endif endif
diff --git a/src/security/apparmor/meson.build b/src/security/apparmor/meson.build diff --git a/src/security/apparmor/meson.build b/src/security/apparmor/meson.build
index af43780..e2d6c81 100644 index 990f00b4f3..e5a7a14e1d 100644
--- a/src/security/apparmor/meson.build --- a/src/security/apparmor/meson.build
+++ b/src/security/apparmor/meson.build +++ b/src/security/apparmor/meson.build
@@ -17,22 +17,22 @@ foreach name : apparmor_gen_profiles @@ -19,22 +19,22 @@ foreach name : apparmor_gen_profiles
output: name, output: name,
configuration: apparmor_gen_profiles_conf, configuration: apparmor_gen_profiles_conf,
install: true, install: true,
@ -304,10 +319,10 @@ index af43780..e2d6c81 100644
rename: 'usr.lib.libvirt.virt-aa-helper', rename: 'usr.lib.libvirt.virt-aa-helper',
) )
diff --git a/tools/meson.build b/tools/meson.build diff --git a/tools/meson.build b/tools/meson.build
index b8c6802..dacd0ff 100644 index 3fba313e5f..a2b891b86c 100644
--- a/tools/meson.build --- a/tools/meson.build
+++ b/tools/meson.build +++ b/tools/meson.build
@@ -115,7 +115,7 @@ if conf.has('WITH_LOGIN_SHELL') @@ -120,7 +120,7 @@ if conf.has('WITH_LOGIN_SHELL')
install_rpath: libvirt_rpath, install_rpath: libvirt_rpath,
) )
@ -316,7 +331,7 @@ index b8c6802..dacd0ff 100644
endif endif
if host_machine.system() == 'windows' if host_machine.system() == 'windows'
@@ -274,7 +274,7 @@ configure_file( @@ -307,7 +307,7 @@ configure_file(
if init_script == 'systemd' if init_script == 'systemd'
install_data( install_data(
'libvirt-guests.sysconf', 'libvirt-guests.sysconf',
@ -324,3 +339,7 @@ index b8c6802..dacd0ff 100644
+ install_dir: install_prefix + sysconfdir / 'sysconfig', + install_dir: install_prefix + sysconfdir / 'sysconfig',
rename: 'libvirt-guests', rename: 'libvirt-guests',
) )
--
2.35.1

View file

@ -1,14 +0,0 @@
diff --git a/src/ch/meson.build b/src/ch/meson.build
index e34974d56c..4767763c2c 100644
--- a/src/ch/meson.build
+++ b/src/ch/meson.build
@@ -68,7 +68,7 @@ if conf.has('WITH_CH')
}
virt_install_dirs += [
- localstatedir / 'lib' / 'libvirt' / 'ch',
- runstatedir / 'libvirt' / 'ch',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'ch',
+ install_prefix + runstatedir / 'libvirt' / 'ch',
]
endif

View file

@ -1,81 +1,118 @@
{ lib { lib
, stdenv
, fetchurl
, fetchFromGitLab
, makeWrapper
, autoreconfHook , autoreconfHook
, fetchpatch , bash-completion
, bridge-utils
, cmake
, coreutils , coreutils
, libxml2 , curl
, gnutls , darwin
, perl , dbus
, python3 , dnsmasq
, attr
, glib
, docutils , docutils
, iproute2 , fetchFromGitLab
, readline , fetchurl
, lvm2
, util-linux
, systemd
, libpciaccess
, gettext , gettext
, libtasn1 , glib
, gnutls
, iproute2
, iptables , iptables
, libgcrypt , libgcrypt
, yajl
, pmutils
, libcap_ng
, libapparmor
, dnsmasq
, libnl
, libpcap , libpcap
, libtasn1
, libxml2
, libxslt , libxslt
, xhtml1 , makeWrapper
, numad
, numactl
, perlPackages
, curl
, libiconv
, gmp
, zfs
, parted
, bridge-utils
, dmidecode
, dbus
, libtirpc
, rpcsvc-proto
, darwin
, meson , meson
, ninja , ninja
, audit , perl
, cmake , perlPackages
, bash-completion
, pkg-config , pkg-config
, pmutils
, python3
, readline
, rpcsvc-proto
, stdenv
, xhtml1
, yajl
# Linux
, acl ? null
, attr ? null
, audit ? null
, dmidecode ? null
, fuse ? null
, kmod ? null
, libapparmor ? null
, libcap_ng ? null
, libnl ? null
, libpciaccess ? null
, libtirpc ? null
, lvm2 ? null
, numactl ? null
, numad ? null
, parted ? null
, systemd ? null
, util-linux ? null
# Darwin
, gmp ? null
, libiconv ? null
, Carbon ? null
, AppKit ? null
# Options
, enableCeph ? false
, ceph ? null
, enableGlusterfs ? false
, glusterfs ? null
, enableIscsi ? false
, openiscsi ? null
, libiscsi ? null
, enableXen ? false , enableXen ? false
, xen ? null , xen ? null
, enableIscsi ? false , enableZfs ? stdenv.isLinux
, openiscsi , zfs ? null
, enableCeph ? false
, ceph
, enableGlusterfs ? false
, glusterfs
, Carbon
, AppKit
}: }:
with lib; with lib;
# if you update, also bump <nixpkgs/pkgs/development/python-modules/libvirt/default.nix> and SysVirt in <nixpkgs/pkgs/top-level/perl-packages.nix>
let let
buildFromTarball = stdenv.isDarwin; inherit (stdenv) isDarwin isLinux isx86_64;
binPath = makeBinPath ([
dnsmasq
] ++ optionals isLinux [
bridge-utils
dmidecode
dnsmasq
iproute2
iptables
kmod
lvm2
numactl
numad
pmutils
systemd
] ++ optionals enableIscsi [
libiscsi
openiscsi
]);
in in
assert enableXen -> isLinux && isx86_64;
assert enableCeph -> isLinux;
assert enableGlusterfs -> isLinux;
assert enableZfs -> isLinux;
# if you update, also bump <nixpkgs/pkgs/development/python-modules/libvirt/default.nix> and SysVirt in <nixpkgs/pkgs/top-level/perl-packages.nix>
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "libvirt"; pname = "libvirt";
# NOTE: You must also bump:
# <nixpkgs/pkgs/development/python-modules/libvirt/default.nix>
# SysVirt in <nixpkgs/pkgs/top-level/perl-packages.nix>
version = "7.10.0"; version = "7.10.0";
src = src =
if buildFromTarball then if isDarwin then
fetchurl fetchurl
{ {
url = "https://libvirt.org/sources/${pname}-${version}.tar.xz"; url = "https://libvirt.org/sources/${pname}-${version}.tar.xz";
@ -93,70 +130,76 @@ stdenv.mkDerivation rec {
patches = [ patches = [
./0001-meson-patch-in-an-install-prefix-for-building-on-nix.patch ./0001-meson-patch-in-an-install-prefix-for-building-on-nix.patch
./0002-meson-patch-ch-install-prefix.patch
]; ];
# remove some broken tests
postPatch = ''
sed -i '/commandtest/d' tests/meson.build
sed -i '/virnetsockettest/d' tests/meson.build
# delete only the first occurrence of this
sed -i '0,/qemuxml2argvtest/{/qemuxml2argvtest/d;}' tests/meson.build
'';
nativeBuildInputs = [ nativeBuildInputs = [
ninja
meson meson
cmake cmake
makeWrapper
pkg-config
docutils docutils
] ++ optional (!stdenv.isDarwin) [ makeWrapper
rpcsvc-proto ninja
] ++ optionals stdenv.isDarwin [ pkg-config
darwin.developer_cmds # needed for rpcgen ]
]; ++ optional (!isDarwin) rpcsvc-proto
# NOTE: needed for rpcgen
++ optional isDarwin darwin.developer_cmds;
buildInputs = [ buildInputs = [
bash-completion bash-completion
pkg-config curl
libxml2 dbus
gettext
glib
gnutls gnutls
libgcrypt
libpcap
libtasn1
libxml2
libxslt
perl perl
perlPackages.XMLXPath
pkg-config
python3 python3
readline readline
gettext
libtasn1
libgcrypt
yajl
libxslt
xhtml1 xhtml1
perlPackages.XMLXPath yajl
curl ] ++ optionals isLinux [
libpcap acl
glib attr
dbus
] ++ optionals stdenv.isLinux [
audit audit
libpciaccess fuse
lvm2
util-linux
systemd
libnl
numad
zfs
libapparmor libapparmor
libcap_ng libcap_ng
numactl libnl
attr libpciaccess
parted
libtirpc libtirpc
] ++ optionals (enableXen && stdenv.isLinux && stdenv.isx86_64) [ lvm2
xen numactl
] ++ optionals enableIscsi [ numad
openiscsi parted
] ++ optionals enableCeph [ systemd
ceph util-linux
] ++ optionals enableGlusterfs [ ] ++ optionals isDarwin [
glusterfs
] ++ optionals stdenv.isDarwin [
libiconv
gmp
Carbon
AppKit AppKit
]; Carbon
gmp
libiconv
]
++ optionals enableCeph [ ceph ]
++ optionals enableGlusterfs [ glusterfs ]
++ optionals enableIscsi [ libiscsi openiscsi ]
++ optionals enableXen [ xen ]
++ optionals enableZfs [ zfs ];
preConfigure = preConfigure =
let let
@ -164,20 +207,23 @@ stdenv.mkDerivation rec {
QEMU_BRIDGE_HELPER = "/run/wrappers/bin/qemu-bridge-helper"; QEMU_BRIDGE_HELPER = "/run/wrappers/bin/qemu-bridge-helper";
QEMU_PR_HELPER = "/run/libvirt/nix-helpers/qemu-pr-helper"; QEMU_PR_HELPER = "/run/libvirt/nix-helpers/qemu-pr-helper";
}; };
patchBuilder = var: value: '' patchBuilder = var: value: ''
sed -i meson.build -e "s|conf.set_quoted('${var}',.*|conf.set_quoted('${var}','${value}')|" sed -i meson.build -e "s|conf.set_quoted('${var}',.*|conf.set_quoted('${var}','${value}')|"
''; '';
in in
'' ''
PATH=${lib.makeBinPath ([ dnsmasq ] ++ optionals stdenv.isLinux [ iproute2 iptables lvm2 systemd numad ] ++ optionals enableIscsi [ openiscsi ])}:$PATH PATH="${binPath}:$PATH"
# the path to qemu-kvm will be stored in VM's .xml and .save files # the path to qemu-kvm will be stored in VM's .xml and .save files
# do not use "''${qemu_kvm}/bin/qemu-kvm" to avoid bound VMs to particular qemu derivations # do not use "''${qemu_kvm}/bin/qemu-kvm" to avoid bound VMs to particular qemu derivations
substituteInPlace src/lxc/lxc_conf.c \ substituteInPlace src/lxc/lxc_conf.c \
--replace 'lxc_path,' '"/run/libvirt/nix-emulators/libvirt_lxc",' --replace 'lxc_path,' '"/run/libvirt/nix-emulators/libvirt_lxc",'
substituteInPlace build-aux/meson.build \ substituteInPlace build-aux/meson.build \
--replace "gsed" "sed" \ --replace "gsed" "sed" \
--replace "gmake" "make" \ --replace "gmake" "make" \
--replace "ggrep" "grep" --replace "ggrep" "grep"
patchShebangs . patchShebangs .
'' ''
+ (lib.concatStringsSep "\n" (lib.mapAttrsToList patchBuilder overrides)); + (lib.concatStringsSep "\n" (lib.mapAttrsToList patchBuilder overrides));
@ -186,58 +232,99 @@ stdenv.mkDerivation rec {
mesonFlags = mesonFlags =
let let
opt = option: enable: "-D${option}=${if enable then "enabled" else "disabled"}"; cfg = option: val: "-D${option}=${val}";
feat = option: enable: cfg option (if enable then "enabled" else "disabled");
driver = name: feat "driver_${name}";
storage = name: feat "storage_${name}";
in in
[ [
"--sysconfdir=/var/lib" "--sysconfdir=/var/lib"
"-Dinstall_prefix=${placeholder "out"}" (cfg "install_prefix" (placeholder "out"))
"-Dlocalstatedir=/var" (cfg "localstatedir" "/var")
"-Drunstatedir=/run" (cfg "runstatedir" "/run")
"-Dlibpcap=enabled"
"-Ddriver_qemu=enabled" (cfg "init_script" (if isDarwin then "none" else "systemd"))
"-Ddriver_vmware=enabled"
"-Ddriver_vbox=enabled" (feat "apparmor" isLinux)
"-Ddriver_test=enabled" (feat "attr" isLinux)
"-Ddriver_esx=enabled" (feat "audit" isLinux)
"-Ddriver_remote=enabled" (feat "bash_completion" true)
"-Dpolkit=enabled" (feat "blkid" isLinux)
(opt "storage_iscsi" enableIscsi) (feat "capng" isLinux)
] ++ optionals stdenv.isLinux [ (feat "curl" true)
(opt "storage_zfs" (zfs != null)) (feat "docs" true)
"-Dattr=enabled" (feat "expensive_tests" true)
"-Dapparmor=enabled" (feat "firewalld" isLinux)
"-Dsecdriver_apparmor=enabled" (feat "firewalld_zone" isLinux)
"-Dnumad=enabled" (feat "fuse" isLinux)
"-Dstorage_disk=enabled" (feat "glusterfs" enableGlusterfs)
(opt "glusterfs" enableGlusterfs) (feat "host_validate" true)
(opt "storage_rbd" enableCeph) (feat "libiscsi" enableIscsi)
] ++ optionals stdenv.isDarwin [ (feat "libnl" isLinux)
"-Dinit_script=none" (feat "libpcap" true)
(feat "libssh2" true)
(feat "login_shell" isLinux)
(feat "nss" isLinux)
(feat "numactl" isLinux)
(feat "numad" isLinux)
(feat "pciaccess" isLinux)
(feat "polkit" true)
(feat "readline" true)
(feat "secdriver_apparmor" isLinux)
(feat "tests" true)
(feat "udev" isLinux)
(feat "yajl" true)
(driver "ch" isLinux)
(driver "esx" true)
(driver "interface" isLinux)
(driver "libvirtd" true)
(driver "libxl" enableXen)
(driver "lxc" isLinux)
(driver "network" true)
(driver "openvz" isLinux)
(driver "qemu" true)
(driver "remote" true)
(driver "secrets" true)
(driver "test" true)
(driver "vbox" true)
(driver "vmware" true)
(storage "dir" true)
(storage "disk" isLinux)
(storage "fs" isLinux)
(storage "gluster" enableGlusterfs)
(storage "iscsi" enableIscsi)
(storage "iscsi_direct" enableIscsi)
(storage "lvm" isLinux)
(storage "mpath" isLinux)
(storage "rbd" enableCeph)
(storage "scsi" true)
(storage "vstorage" isLinux)
(storage "zfs" enableZfs)
]; ];
postInstall = doCheck = true;
let
binPath = [ iptables iproute2 pmutils numad numactl bridge-utils dmidecode dnsmasq ] ++ optionals enableIscsi [ openiscsi ];
in
''
substituteInPlace $out/bin/virt-xml-validate \
--replace xmllint ${libxml2}/bin/xmllint
substituteInPlace $out/libexec/libvirt-guests.sh \ postInstall = ''
--replace 'ON_BOOT="start"' 'ON_BOOT=''${ON_BOOT:-start}' \ substituteInPlace $out/bin/virt-xml-validate \
--replace 'ON_SHUTDOWN="suspend"' 'ON_SHUTDOWN=''${ON_SHUTDOWN:-suspend}' \ --replace xmllint ${libxml2}/bin/xmllint
--replace "$out/bin" '${gettext}/bin' \
--replace 'lock/subsys' 'lock' \ substituteInPlace $out/libexec/libvirt-guests.sh \
--replace 'gettext.sh' 'gettext.sh --replace 'ON_BOOT="start"' 'ON_BOOT=''${ON_BOOT:-start}' \
# Added in nixpkgs: --replace 'ON_SHUTDOWN="suspend"' 'ON_SHUTDOWN=''${ON_SHUTDOWN:-suspend}' \
gettext() { "${gettext}/bin/gettext" "$@"; } --replace "$out/bin" '${gettext}/bin' \
' --replace 'lock/subsys' 'lock' \
'' + optionalString stdenv.isLinux '' --replace 'gettext.sh' 'gettext.sh
substituteInPlace $out/lib/systemd/system/libvirtd.service --replace /bin/kill ${coreutils}/bin/kill # Added in nixpkgs:
rm $out/lib/systemd/system/{virtlockd,virtlogd}.* gettext() { "${gettext}/bin/gettext" "$@"; }
wrapProgram $out/sbin/libvirtd \ '
--prefix PATH : /run/libvirt/nix-emulators:${makeBinPath binPath} '' + optionalString isLinux ''
''; substituteInPlace $out/lib/systemd/system/libvirtd.service --replace /bin/kill ${coreutils}/bin/kill
rm $out/lib/systemd/system/{virtlockd,virtlogd}.*
wrapProgram $out/sbin/libvirtd \
--prefix PATH : /run/libvirt/nix-emulators:${binPath}
'';
meta = { meta = {
homepage = "https://libvirt.org/"; homepage = "https://libvirt.org/";
@ -248,6 +335,6 @@ stdenv.mkDerivation rec {
''; '';
license = licenses.lgpl2Plus; license = licenses.lgpl2Plus;
platforms = platforms.unix; platforms = platforms.unix;
maintainers = with maintainers; [ fpletz globin ]; maintainers = with maintainers; [ fpletz globin lovesegfault ];
}; };
} }