push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,479 @@
From 58c07f1d59ef683faf8b747e40bd75401306acf4 Mon Sep 17 00:00:00 2001
From: Euan Kemp <euank@euank.com>
Date: Mon, 24 Jun 2024 15:59:48 +0200
Subject: [PATCH] meson: patch in an install prefix for building on nix
Used in the nixpkgs version of libvirt so that we can install things in
the nix store, but read them from the root filesystem.
---
meson.build | 9 +++++++
meson_options.txt | 2 ++
src/ch/meson.build | 6 ++---
src/interface/meson.build | 2 +-
src/libxl/meson.build | 18 +++++++-------
src/locking/meson.build | 8 +++----
src/lxc/meson.build | 10 ++++----
src/meson.build | 18 +++++++-------
src/network/meson.build | 14 +++++------
src/node_device/meson.build | 2 +-
src/nwfilter/meson.build | 6 ++---
src/nwfilter/xml/meson.build | 2 +-
src/qemu/meson.build | 40 +++++++++++++++----------------
src/remote/meson.build | 10 ++++----
src/secret/meson.build | 4 ++--
src/security/apparmor/meson.build | 8 +++----
src/storage/meson.build | 6 ++---
tools/meson.build | 2 +-
tools/ssh-proxy/meson.build | 2 +-
19 files changed, 90 insertions(+), 79 deletions(-)
diff --git a/meson.build b/meson.build
index e98ab0d5ac..376f241c07 100644
--- a/meson.build
+++ b/meson.build
@@ -47,6 +47,8 @@ if host_machine.system() == 'windows'
conf.set('WINVER', '0x0600') # Win Vista / Server 2008
endif
+# patched in for nix
+install_prefix = get_option('install_prefix')
# set various paths
@@ -65,6 +67,13 @@ else
sysconfdir = prefix / get_option('sysconfdir')
endif
+# nix: don't prefix the localstatedir; some things need to write to it, so it
+# can't be in the nix store, and that's what the prefix is.
+# We'll prefix things ourselves where needed
+localstatedir = get_option('localstatedir')
+# Same for sysconfidr
+sysconfdir = get_option('sysconfdir')
+
# if --prefix is /usr, don't use /usr/var for localstatedir or /usr/etc for
# sysconfdir as this makes a lot of things break in testing situations
if prefix == '/usr'
diff --git a/meson_options.txt b/meson_options.txt
index cdc8687795..c2b6da140c 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,3 +1,5 @@
+option('install_prefix', type: 'string', value: '', description: 'prefix for nix store installation')
+
option('no_git', type: 'boolean', value: false, description: 'Disable git submodule update')
option('packager', type: 'string', value: '', description: 'Extra packager name')
option('packager_version', type: 'string', value: '', description: 'Extra packager version')
diff --git a/src/ch/meson.build b/src/ch/meson.build
index 633966aac7..c0ce823345 100644
--- a/src/ch/meson.build
+++ b/src/ch/meson.build
@@ -74,8 +74,8 @@ if conf.has('WITH_CH')
}
virt_install_dirs += [
- localstatedir / 'lib' / 'libvirt' / 'ch',
- localstatedir / 'log' / 'libvirt' / 'ch',
- runstatedir / 'libvirt' / 'ch',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'ch',
+ install_prefix + localstatedir / 'log' / 'libvirt' / 'ch',
+ install_prefix + runstatedir / 'libvirt' / 'ch',
]
endif
diff --git a/src/interface/meson.build b/src/interface/meson.build
index 3d2991315e..20f3266738 100644
--- a/src/interface/meson.build
+++ b/src/interface/meson.build
@@ -59,6 +59,6 @@ if conf.has('WITH_INTERFACE')
}
virt_install_dirs += [
- runstatedir / 'libvirt' / 'interface',
+ install_prefix + runstatedir / 'libvirt' / 'interface',
]
endif
diff --git a/src/libxl/meson.build b/src/libxl/meson.build
index e75a8f2fdb..d1800b4ea5 100644
--- a/src/libxl/meson.build
+++ b/src/libxl/meson.build
@@ -81,14 +81,14 @@ if conf.has('WITH_LIBXL')
}
virt_install_dirs += [
- confdir / 'libxl',
- confdir / 'libxl' / 'autostart',
- localstatedir / 'lib' / 'libvirt' / 'libxl',
- localstatedir / 'lib' / 'libvirt' / 'libxl' / 'channel',
- localstatedir / 'lib' / 'libvirt' / 'libxl' / 'channel' / 'target',
- localstatedir / 'lib' / 'libvirt' / 'libxl' / 'dump',
- localstatedir / 'lib' / 'libvirt' / 'libxl' / 'save',
- localstatedir / 'log' / 'libvirt' / 'libxl',
- runstatedir / 'libvirt' / 'libxl',
+ install_prefix + confdir / 'libxl',
+ install_prefix + confdir / 'libxl' / 'autostart',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'libxl',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'libxl' / 'channel',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'libxl' / 'channel' / 'target',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'libxl' / 'dump',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'libxl' / 'save',
+ install_prefix + localstatedir / 'log' / 'libvirt' / 'libxl',
+ install_prefix + runstatedir / 'libvirt' / 'libxl',
]
endif
diff --git a/src/locking/meson.build b/src/locking/meson.build
index c3dfcf2961..cdc1442775 100644
--- a/src/locking/meson.build
+++ b/src/locking/meson.build
@@ -249,14 +249,14 @@ if conf.has('WITH_LIBVIRTD')
}
virt_install_dirs += [
- localstatedir / 'lib' / 'libvirt' / 'lockd',
- localstatedir / 'lib' / 'libvirt' / 'lockd' / 'files',
- runstatedir / 'libvirt' / 'lockd',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'lockd',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'lockd' / 'files',
+ install_prefix + runstatedir / 'libvirt' / 'lockd',
]
if conf.has('WITH_SANLOCK')
virt_install_dirs += [
- localstatedir / 'lib' / 'libvirt' / 'sanlock',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'sanlock',
]
endif
endif
diff --git a/src/lxc/meson.build b/src/lxc/meson.build
index bf9afabc0f..6e9547000a 100644
--- a/src/lxc/meson.build
+++ b/src/lxc/meson.build
@@ -190,10 +190,10 @@ if conf.has('WITH_LXC')
}
virt_install_dirs += [
- confdir / 'lxc',
- confdir / 'lxc' / 'autostart',
- localstatedir / 'lib' / 'libvirt' / 'lxc',
- localstatedir / 'log' / 'libvirt' / 'lxc',
- runstatedir / 'libvirt' / 'lxc',
+ install_prefix + confdir / 'lxc',
+ install_prefix + confdir / 'lxc' / 'autostart',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'lxc',
+ install_prefix + localstatedir / 'log' / 'libvirt' / 'lxc',
+ install_prefix + runstatedir / 'libvirt' / 'lxc',
]
endif
diff --git a/src/meson.build b/src/meson.build
index dd2682ec19..b330d1159e 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -220,7 +220,7 @@ openrc_init_files = []
# virt_install_dirs:
# list of directories to create during installation
-virt_install_dirs = [ confdir ]
+virt_install_dirs = [ install_prefix + confdir ]
# driver_source_files:
# driver source files to check
@@ -697,7 +697,7 @@ endforeach
virt_conf_files += 'libvirt.conf'
-install_data(virt_conf_files, install_dir: confdir)
+install_data(virt_conf_files, install_dir: install_prefix + confdir)
install_data(virt_aug_files, install_dir: virt_aug_dir)
# augeas_test_data:
@@ -760,7 +760,7 @@ foreach data : virt_daemon_confs
output: '@0@.conf'.format(data['name']),
configuration: daemon_conf,
install: true,
- install_dir: confdir,
+ install_dir: install_prefix + confdir,
)
if data.get('with_ip', false)
@@ -910,7 +910,7 @@ if conf.has('WITH_LIBVIRTD')
install_data(
init_file,
- install_dir: sysconfdir / 'init.d',
+ install_dir: install_prefix + sysconfdir / 'init.d',
install_mode: 'rwxr-xr-x',
rename: [ init['name'] ],
)
@@ -918,7 +918,7 @@ if conf.has('WITH_LIBVIRTD')
if init.has_key('confd')
install_data(
init['confd'],
- install_dir: sysconfdir / 'conf.d',
+ install_dir: install_prefix + sysconfdir / 'conf.d',
rename: [ init['name'] ],
)
endif
@@ -945,10 +945,10 @@ endif
# Install empty directories
virt_install_dirs += [
- localstatedir / 'cache' / 'libvirt',
- localstatedir / 'lib' / 'libvirt' / 'images',
- localstatedir / 'lib' / 'libvirt' / 'filesystems',
- localstatedir / 'lib' / 'libvirt' / 'boot',
+ install_prefix + localstatedir / 'cache' / 'libvirt',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'images',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'filesystems',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'boot',
]
meson.add_install_script(
diff --git a/src/network/meson.build b/src/network/meson.build
index 07cd5cda55..699309bb66 100644
--- a/src/network/meson.build
+++ b/src/network/meson.build
@@ -115,11 +115,11 @@ if conf.has('WITH_NETWORK')
}
virt_install_dirs += [
- confdir / 'qemu' / 'networks',
- confdir / 'qemu' / 'networks' / 'autostart',
- localstatedir / 'lib' / 'libvirt' / 'network',
- localstatedir / 'lib' / 'libvirt' / 'dnsmasq',
- runstatedir / 'libvirt' / 'network',
+ install_prefix + confdir / 'qemu' / 'networks',
+ install_prefix + confdir / 'qemu' / 'networks' / 'autostart',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'network',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'dnsmasq',
+ install_prefix + runstatedir / 'libvirt' / 'network',
]
configure_file(
@@ -127,12 +127,12 @@ if conf.has('WITH_NETWORK')
output: '@BASENAME@',
configuration: configmake_conf,
install: true,
- install_dir: confdir / 'qemu' / 'networks',
+ install_dir: install_prefix + confdir / 'qemu' / 'networks',
)
meson.add_install_script(
meson_python_prog.full_path(), python3_prog.full_path(), meson_install_symlink_prog.full_path(),
- confdir / 'qemu' / 'networks' / 'autostart',
+ install_prefix + confdir / 'qemu' / 'networks' / 'autostart',
'../default.xml', 'default.xml',
)
diff --git a/src/node_device/meson.build b/src/node_device/meson.build
index d66c02a0e2..f883b65431 100644
--- a/src/node_device/meson.build
+++ b/src/node_device/meson.build
@@ -67,6 +67,6 @@ if conf.has('WITH_NODE_DEVICES')
}
virt_install_dirs += [
- runstatedir / 'libvirt' / 'nodedev',
+ install_prefix + runstatedir / 'libvirt' / 'nodedev',
]
endif
diff --git a/src/nwfilter/meson.build b/src/nwfilter/meson.build
index de3d202267..346c435ee7 100644
--- a/src/nwfilter/meson.build
+++ b/src/nwfilter/meson.build
@@ -65,9 +65,9 @@ if conf.has('WITH_NWFILTER')
}
virt_install_dirs += [
- confdir / 'nwfilter',
- runstatedir / 'libvirt' / 'nwfilter-binding',
- runstatedir / 'libvirt' / 'nwfilter',
+ install_prefix + confdir / 'nwfilter',
+ install_prefix + runstatedir / 'libvirt' / 'nwfilter-binding',
+ install_prefix + runstatedir / 'libvirt' / 'nwfilter',
]
subdir('xml')
diff --git a/src/nwfilter/xml/meson.build b/src/nwfilter/xml/meson.build
index 0d96c54ebe..66c92a1016 100644
--- a/src/nwfilter/xml/meson.build
+++ b/src/nwfilter/xml/meson.build
@@ -25,4 +25,4 @@ nwfilter_xml_files = [
'qemu-announce-self.xml',
]
-install_data(nwfilter_xml_files, install_dir: 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
index 907893d431..99b62c8955 100644
--- a/src/qemu/meson.build
+++ b/src/qemu/meson.build
@@ -218,25 +218,25 @@ if conf.has('WITH_QEMU')
endif
virt_install_dirs += [
- confdir / 'qemu',
- confdir / 'qemu' / 'autostart',
- localstatedir / 'cache' / 'libvirt' / 'qemu',
- localstatedir / 'lib' / 'libvirt' / 'qemu',
- localstatedir / 'lib' / 'libvirt' / 'qemu' / 'channel',
- localstatedir / 'lib' / 'libvirt' / 'qemu' / 'channel' / 'target',
- localstatedir / 'lib' / 'libvirt' / 'qemu' / 'checkpoint',
- localstatedir / 'lib' / 'libvirt' / 'qemu' / 'dump',
- localstatedir / 'lib' / 'libvirt' / 'qemu' / 'nvram',
- localstatedir / 'lib' / 'libvirt' / 'qemu' / 'ram',
- localstatedir / 'lib' / 'libvirt' / 'qemu' / 'save',
- localstatedir / 'lib' / 'libvirt' / 'qemu' / 'snapshot',
- localstatedir / 'lib' / 'libvirt' / 'swtpm',
- localstatedir / 'log' / 'libvirt' / 'qemu',
- localstatedir / 'log' / 'swtpm' / 'libvirt' / 'qemu',
- runstatedir / 'libvirt' / 'qemu',
- runstatedir / 'libvirt' / 'qemu' / 'dbus',
- runstatedir / 'libvirt' / 'qemu' / 'passt',
- runstatedir / 'libvirt' / 'qemu' / 'slirp',
- runstatedir / 'libvirt' / 'qemu' / 'swtpm',
+ install_prefix + confdir / 'qemu',
+ install_prefix + confdir / 'qemu' / 'autostart',
+ install_prefix + localstatedir / 'cache' / 'libvirt' / 'qemu',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'channel',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'channel' / 'target',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'checkpoint',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'dump',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'nvram',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'ram',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'save',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'snapshot',
+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'swtpm',
+ install_prefix + localstatedir / 'log' / 'libvirt' / 'qemu',
+ install_prefix + localstatedir / 'log' / 'swtpm' / 'libvirt' / 'qemu',
+ install_prefix + runstatedir / 'libvirt' / 'qemu',
+ install_prefix + runstatedir / 'libvirt' / 'qemu' / 'dbus',
+ install_prefix + runstatedir / 'libvirt' / 'qemu' / 'passt',
+ install_prefix + runstatedir / 'libvirt' / 'qemu' / 'slirp',
+ install_prefix + runstatedir / 'libvirt' / 'qemu' / 'swtpm',
]
endif
diff --git a/src/remote/meson.build b/src/remote/meson.build
index 831acaaa01..0ba34d3bad 100644
--- a/src/remote/meson.build
+++ b/src/remote/meson.build
@@ -261,9 +261,9 @@ if conf.has('WITH_REMOTE')
}
virt_install_dirs += [
- localstatedir / 'log' / 'libvirt',
- runstatedir / 'libvirt',
- runstatedir / 'libvirt' / 'common',
+ install_prefix + localstatedir / 'log' / 'libvirt',
+ install_prefix + runstatedir / 'libvirt',
+ install_prefix + runstatedir / 'libvirt' / 'common',
]
logrotate_conf = configuration_data({
@@ -278,7 +278,7 @@ if conf.has('WITH_REMOTE')
)
install_data(
log_file,
- install_dir: sysconfdir / 'logrotate.d',
+ install_dir: install_prefix + sysconfdir / 'logrotate.d',
rename: [ name ],
)
endforeach
@@ -328,7 +328,7 @@ endif
if conf.has('WITH_SASL')
install_data(
'libvirtd.sasl',
- install_dir: sysconfdir / 'sasl2',
+ install_dir: install_prefix + sysconfdir / 'sasl2',
rename: [ 'libvirt.conf' ],
)
endif
diff --git a/src/secret/meson.build b/src/secret/meson.build
index 3b859ea7b4..ccddb3e805 100644
--- a/src/secret/meson.build
+++ b/src/secret/meson.build
@@ -48,7 +48,7 @@ if conf.has('WITH_SECRETS')
}
virt_install_dirs += [
- confdir / 'secrets',
- runstatedir / 'libvirt' / 'secrets',
+ install_prefix + confdir / 'secrets',
+ install_prefix + runstatedir / 'libvirt' / 'secrets',
]
endif
diff --git a/src/security/apparmor/meson.build b/src/security/apparmor/meson.build
index 09d9fac02c..ee0c74ceec 100644
--- a/src/security/apparmor/meson.build
+++ b/src/security/apparmor/meson.build
@@ -20,16 +20,16 @@ foreach name : apparmor_gen_profiles
output: name,
configuration: apparmor_gen_profiles_conf,
install: true,
- install_dir: apparmor_dir,
+ install_dir: install_prefix + apparmor_dir,
)
endforeach
install_data(
[ 'libvirt-qemu', 'libvirt-lxc' ],
- install_dir: apparmor_dir / 'abstractions',
+ install_dir: install_prefix + apparmor_dir / 'abstractions',
)
install_data(
[ 'TEMPLATE.qemu', 'TEMPLATE.lxc' ],
- install_dir: apparmor_dir / 'libvirt',
+ install_dir: install_prefix + apparmor_dir / 'libvirt',
)
diff --git a/src/storage/meson.build b/src/storage/meson.build
index 404d6a6941..fb4e67a0a8 100644
--- a/src/storage/meson.build
+++ b/src/storage/meson.build
@@ -126,9 +126,9 @@ if conf.has('WITH_STORAGE')
}
virt_install_dirs += [
- confdir / 'storage',
- confdir / 'storage' / 'autostart',
- runstatedir / 'libvirt' / 'storage',
+ install_prefix + confdir / 'storage',
+ install_prefix + confdir / 'storage' / 'autostart',
+ install_prefix + runstatedir / 'libvirt' / 'storage',
]
endif
diff --git a/tools/meson.build b/tools/meson.build
index a099148d3c..d0d6510f17 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -123,12 +123,12 @@ if conf.has('WITH_LOGIN_SHELL')
install_rpath: libvirt_rpath,
)
- install_data('virt-login-shell.conf', install_dir: sysconfdir / 'libvirt')
+ install_data('virt-login-shell.conf', install_dir: install_prefix + sysconfdir / 'libvirt')
# Install the sysuser config for the setgid binary
install_data(
'libvirt-login-shell.sysusers.conf',
- install_dir: sysusersdir,
+ install_dir: install_prefix + sysusersdir,
rename: [ 'libvirt-login-shell.conf' ],
)
endif
diff --git a/tools/ssh-proxy/meson.build b/tools/ssh-proxy/meson.build
index e9f312fa25..95d5d8fe0b 100644
--- a/tools/ssh-proxy/meson.build
+++ b/tools/ssh-proxy/meson.build
@@ -20,6 +20,6 @@ if conf.has('WITH_SSH_PROXY')
output: '@BASENAME@',
configuration: tools_conf,
install: true,
- install_dir : sshconfdir,
+ install_dir : install_prefix + sshconfdir,
)
endif
--
2.45.1

View File

@@ -0,0 +1,27 @@
From dc5e3df2fd29a547ef0f9545e190a0ce3a73c95c Mon Sep 17 00:00:00 2001
From: Tako Marks <me@github.tako.mx>
Date: Tue, 6 Sep 2022 20:19:26 +0200
Subject: [PATCH] substitute zfs and zpool commands
---
src/storage/storage_backend_zfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backend_zfs.c
index 2a5d74357d..460b3025c4 100644
--- a/src/storage/storage_backend_zfs.c
+++ b/src/storage/storage_backend_zfs.c
@@ -33,8 +33,8 @@
VIR_LOG_INIT("storage.storage_backend_zfs");
-#define ZFS "zfs"
-#define ZPOOL "zpool"
+#define ZFS "@zfs@"
+#define ZPOOL "@zpool@"
/*
* Some common flags of zfs and zpool commands we use:
--
2.36.2

View File

@@ -0,0 +1,419 @@
{
lib,
bash,
bash-completion,
bridge-utils,
coreutils,
curl,
darwin,
dbus,
dnsmasq,
docutils,
fetchFromGitLab,
gettext,
glib,
gnutls,
iproute2,
iptables,
libgcrypt,
libpcap,
libtasn1,
libxml2,
libxslt,
makeWrapper,
meson,
nftables,
ninja,
openssh,
perl,
perlPackages,
polkit,
pkg-config,
pmutils,
python3,
readline,
rpcsvc-proto,
stdenv,
replaceVars,
xhtml1,
json_c,
writeScript,
nixosTests,
# Linux
acl ? null,
attr ? null,
audit ? null,
dmidecode ? null,
fuse3 ? 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,
libiconv,
qemu,
# Options
enableCeph ? false,
ceph,
enableGlusterfs ? false,
glusterfs,
enableIscsi ? false,
openiscsi,
libiscsi,
enableXen ? stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isx86_64,
xen,
enableZfs ? stdenv.hostPlatform.isLinux,
zfs,
}:
let
inherit (stdenv.hostPlatform) isDarwin isLinux isx86_64;
binPath = lib.makeBinPath (
[
dnsmasq
]
++ lib.optionals isLinux [
bridge-utils
dmidecode
dnsmasq
iproute2
iptables
kmod
lvm2
nftables
numactl
numad
openssh
pmutils
systemd
]
++ lib.optionals enableIscsi [
libiscsi
openiscsi
]
++ lib.optionals enableZfs [
zfs
]
);
in
assert enableXen -> isLinux && isx86_64;
assert enableCeph -> isLinux;
assert enableGlusterfs -> isLinux;
assert enableZfs -> isLinux;
stdenv.mkDerivation rec {
pname = "libvirt";
# if you update, also bump <nixpkgs/pkgs/development/python-modules/libvirt/default.nix> and SysVirt in <nixpkgs/pkgs/top-level/perl-packages.nix>
version = "11.7.0";
src = fetchFromGitLab {
owner = "libvirt";
repo = "libvirt";
tag = "v${version}";
fetchSubmodules = true;
hash = "sha256-BLPuqKvKW3wk4ij8ag4V4odgzZXGfn7692gkeJ03xZw=";
};
patches = [
./0001-meson-patch-in-an-install-prefix-for-building-on-nix.patch
]
++ lib.optionals enableZfs [
(replaceVars ./0002-substitute-zfs-and-zpool-commands.patch {
zfs = "${zfs}/bin/zfs";
zpool = "${zfs}/bin/zpool";
})
];
# 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,/qemuxmlconftest/{/qemuxmlconftest/d;}' tests/meson.build
''
+ lib.optionalString isLinux ''
for binary in mount umount mkfs; do
substituteInPlace meson.build \
--replace "find_program('$binary'" "find_program('${lib.getBin util-linux}/bin/$binary'"
done
''
+ ''
substituteInPlace meson.build \
--replace "'dbus-daemon'," "'${lib.getBin dbus}/bin/dbus-daemon',"
''
+ lib.optionalString isLinux ''
sed -i 's,define PARTED "parted",define PARTED "${parted}/bin/parted",' \
src/storage/storage_backend_disk.c \
src/storage/storage_util.c
''
+ lib.optionalString isDarwin ''
# Darwin doesnt support -fsemantic-interposition, but the problem doesnt seem to affect Mach-O.
# See https://gitlab.com/libvirt/libvirt/-/merge_requests/235
sed -i "s/not supported_cc_flags.contains('-fsemantic-interposition')/false/" meson.build
sed -i '/qemufirmwaretest/d' tests/meson.build
sed -i '/qemuhotplugtest/d' tests/meson.build
sed -i '/qemuvhostusertest/d' tests/meson.build
sed -i '/qemuxml2xmltest/d' tests/meson.build
sed -i '/domaincapstest/d' tests/meson.build
# virshtest frequently times out on Darwin
substituteInPlace tests/meson.build \
--replace-fail "data.get('timeout', 30)" "data.get('timeout', 120)"
''
+ lib.optionalString enableXen ''
# Has various hardcoded paths that don't exist outside of a Xen dom0.
sed -i '/libxlxml2domconfigtest/d' tests/meson.build
substituteInPlace src/libxl/libxl_capabilities.h \
--replace-fail /usr/lib/xen ${xen}/libexec/xen
'';
strictDeps = true;
nativeBuildInputs = [
meson
docutils
libxml2 # for xmllint
libxslt # for xsltproc
gettext
makeWrapper
ninja
pkg-config
perl
perlPackages.XMLXPath
]
++ lib.optional (!isDarwin) rpcsvc-proto
# NOTE: needed for rpcgen
++ lib.optional isDarwin darwin.developer_cmds;
buildInputs = [
bash
bash-completion
curl
dbus
glib
gnutls
libgcrypt
libpcap
libtasn1
libxml2
python3
readline
xhtml1
json_c
]
++ lib.optionals isLinux [
acl
attr
audit
fuse3
libapparmor
libcap_ng
libnl
libpciaccess
libtirpc
lvm2
numactl
numad
parted
systemd
util-linux
]
++ lib.optionals isDarwin [
gmp
libiconv
]
++ lib.optionals enableCeph [ ceph ]
++ lib.optionals enableGlusterfs [ glusterfs ]
++ lib.optionals enableIscsi [
libiscsi
openiscsi
]
++ lib.optionals enableXen [ xen ]
++ lib.optionals enableZfs [ zfs ];
preConfigure =
let
overrides = {
QEMU_BRIDGE_HELPER = "/run/wrappers/bin/qemu-bridge-helper";
QEMU_PR_HELPER = "/run/libvirt/nix-helpers/qemu-pr-helper";
};
patchBuilder = var: value: ''
sed -i meson.build -e "s|conf.set_quoted('${var}',.*|conf.set_quoted('${var}','${value}')|"
'';
in
''
PATH="${binPath}:$PATH"
# 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
substituteInPlace src/lxc/lxc_conf.c \
--replace 'lxc_path,' '"/run/libvirt/nix-emulators/libvirt_lxc",'
substituteInPlace build-aux/meson.build \
--replace "gsed" "sed" \
--replace "gmake" "make" \
--replace "ggrep" "grep"
substituteInPlace src/util/virpolkit.h \
--replace '"/usr/bin/pkttyagent"' '"${if isLinux then polkit.bin else "/usr"}/bin/pkttyagent"'
substituteInPlace src/util/virpci.c \
--replace '/lib/modules' '${
if isLinux then "/run/booted-system/kernel-modules" else ""
}/lib/modules'
patchShebangs .
''
+ (lib.concatStringsSep "\n" (lib.mapAttrsToList patchBuilder overrides));
mesonAutoFeatures = "disabled";
mesonFlags =
let
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
[
"--sysconfdir=/var/lib"
(cfg "install_prefix" (placeholder "out"))
(cfg "localstatedir" "/var")
(cfg "runstatedir" (if isDarwin then "/var/run" else "/run"))
(cfg "sshconfdir" "/etc/ssh/ssh_config.d")
(cfg "init_script" (if isDarwin then "none" else "systemd"))
(cfg "qemu_datadir" (lib.optionalString isDarwin "${qemu}/share/qemu"))
(feat "apparmor" isLinux)
(feat "attr" isLinux)
(feat "audit" isLinux)
(feat "bash_completion" true)
(feat "blkid" isLinux)
(feat "capng" isLinux)
(feat "curl" true)
(feat "docs" true)
(feat "expensive_tests" true)
(feat "firewalld" isLinux)
(feat "firewalld_zone" isLinux)
(feat "fuse" isLinux)
(feat "glusterfs" enableGlusterfs)
(feat "host_validate" true)
(feat "libiscsi" enableIscsi)
(feat "libnl" isLinux)
(feat "libpcap" true)
(feat "libssh2" true)
(feat "login_shell" isLinux)
(feat "nss" (isLinux && !stdenv.hostPlatform.isMusl))
(feat "numactl" isLinux)
(feat "numad" isLinux)
(feat "pciaccess" isLinux)
(feat "polkit" isLinux)
(feat "readline" true)
(feat "secdriver_apparmor" isLinux)
(feat "ssh_proxy" isLinux)
(feat "tests" true)
(feat "udev" isLinux)
(feat "json_c" true)
(driver "ch" (isLinux && (stdenv.hostPlatform.isx86_64 || stdenv.hostPlatform.isAarch64)))
(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)
];
doCheck = true;
postInstall = ''
substituteInPlace $out/bin/virt-xml-validate \
--replace xmllint ${libxml2}/bin/xmllint
# Enable to set some options from the corresponding NixOS module (or other
# places) via environment variables.
substituteInPlace $out/libexec/libvirt-guests.sh \
--replace 'ON_BOOT="start"' 'ON_BOOT=''${ON_BOOT:-start}' \
--replace 'ON_SHUTDOWN="suspend"' 'ON_SHUTDOWN=''${ON_SHUTDOWN:-suspend}' \
--replace 'PARALLEL_SHUTDOWN=0' 'PARALLEL_SHUTDOWN=''${PARALLEL_SHUTDOWN:-0}' \
--replace 'SHUTDOWN_TIMEOUT=300' 'SHUTDOWN_TIMEOUT=''${SHUTDOWN_TIMEOUT:-300}' \
--replace 'START_DELAY=0' 'START_DELAY=''${START_DELAY:-0}' \
--replace "$out/bin" '${gettext}/bin' \
--replace 'lock/subsys' 'lock' \
--replace 'gettext.sh' 'gettext.sh
# Added in nixpkgs:
gettext() { "${gettext}/bin/gettext" "$@"; }
'
''
+ lib.optionalString isLinux ''
for f in $out/lib/systemd/system/*.service ; do
substituteInPlace $f --replace /bin/kill ${coreutils}/bin/kill
done
rm $out/lib/systemd/system/{virtlockd,virtlogd}.*
wrapProgram $out/sbin/libvirtd \
--prefix PATH : /run/libvirt/nix-emulators:${binPath}
'';
passthru.updateScript = writeScript "update-libvirt" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq common-updater-scripts
set -eu -o pipefail
libvirtVersion=$(curl https://gitlab.com/api/v4/projects/192693/repository/tags | jq -r '.[].name|select(. | contains("rc") | not)' | head -n1 | sed "s/v//g")
sysvirtVersion=$(curl https://gitlab.com/api/v4/projects/192677/repository/tags | jq -r '.[].name|select(. | contains("rc") | not)' | head -n1 | sed "s/v//g")
update-source-version ${pname} "$libvirtVersion"
update-source-version python3Packages.${pname} "$libvirtVersion"
update-source-version perlPackages.SysVirt "$sysvirtVersion" --file="pkgs/top-level/perl-packages.nix"
'';
passthru.tests.libvirtd = nixosTests.libvirtd;
meta = {
description = "Toolkit to interact with the virtualization capabilities of recent versions of Linux and other OSes";
homepage = "https://libvirt.org/";
changelog = "https://gitlab.com/libvirt/libvirt/-/raw/v${version}/NEWS.rst";
license = lib.licenses.lgpl2Plus;
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [
fpletz
globin
lovesegfault
];
};
}