nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 22.05 348 lines 8.3 kB view raw
1{ lib 2, autoreconfHook 3, bash-completion 4, bridge-utils 5, cmake 6, coreutils 7, curl 8, darwin 9, dbus 10, dnsmasq 11, docutils 12, fetchFromGitLab 13, fetchurl 14, gettext 15, glib 16, gnutls 17, iproute2 18, iptables 19, libgcrypt 20, libpcap 21, libtasn1 22, libxml2 23, libxslt 24, makeWrapper 25, meson 26, ninja 27, perl 28, perlPackages 29, polkit 30, pkg-config 31, pmutils 32, python3 33, readline 34, rpcsvc-proto 35, stdenv 36, xhtml1 37, yajl 38 39 # Linux 40, acl ? null 41, attr ? null 42, audit ? null 43, dmidecode ? null 44, fuse ? null 45, kmod ? null 46, libapparmor ? null 47, libcap_ng ? null 48, libnl ? null 49, libpciaccess ? null 50, libtirpc ? null 51, lvm2 ? null 52, numactl ? null 53, numad ? null 54, parted ? null 55, systemd ? null 56, util-linux ? null 57 58 # Darwin 59, gmp ? null 60, libiconv ? null 61, Carbon ? null 62, AppKit ? null 63 64 # Options 65, enableCeph ? false 66, ceph ? null 67, enableGlusterfs ? false 68, glusterfs ? null 69, enableIscsi ? false 70, openiscsi ? null 71, libiscsi ? null 72, enableXen ? false 73, xen ? null 74, enableZfs ? stdenv.isLinux 75, zfs ? null 76}: 77 78with lib; 79 80let 81 inherit (stdenv) isDarwin isLinux isx86_64; 82 binPath = makeBinPath ([ 83 dnsmasq 84 ] ++ optionals isLinux [ 85 bridge-utils 86 dmidecode 87 dnsmasq 88 iproute2 89 iptables 90 kmod 91 lvm2 92 numactl 93 numad 94 pmutils 95 systemd 96 ] ++ optionals enableIscsi [ 97 libiscsi 98 openiscsi 99 ]); 100in 101 102assert enableXen -> isLinux && isx86_64; 103assert enableCeph -> isLinux; 104assert enableGlusterfs -> isLinux; 105assert enableZfs -> isLinux; 106 107# if you update, also bump <nixpkgs/pkgs/development/python-modules/libvirt/default.nix> and SysVirt in <nixpkgs/pkgs/top-level/perl-packages.nix> 108stdenv.mkDerivation rec { 109 pname = "libvirt"; 110 # NOTE: You must also bump: 111 # <nixpkgs/pkgs/development/python-modules/libvirt/default.nix> 112 # SysVirt in <nixpkgs/pkgs/top-level/perl-packages.nix> 113 version = "8.1.0"; 114 115 src = 116 if isDarwin then 117 fetchurl 118 { 119 url = "https://libvirt.org/sources/${pname}-${version}.tar.xz"; 120 sha256 = "sha256-PGxDvs/+s0o/OXxhYgaqaaiT/4v16CCDk8hOjnU1KTQ="; 121 } 122 else 123 fetchFromGitLab 124 { 125 owner = pname; 126 repo = pname; 127 rev = "v${version}"; 128 sha256 = "sha256-nk8pBlss+g4EMy+RnAOyz6YlGGvlBvl5aBpcytsK1wY="; 129 fetchSubmodules = true; 130 }; 131 132 patches = [ 133 ./0001-meson-patch-in-an-install-prefix-for-building-on-nix.patch 134 ./0001-qemu-segmentation-fault-in-virtqemud-executing-qemuD.patch 135 ]; 136 137 # remove some broken tests 138 postPatch = '' 139 sed -i '/commandtest/d' tests/meson.build 140 sed -i '/virnetsockettest/d' tests/meson.build 141 # delete only the first occurrence of this 142 sed -i '0,/qemuxml2argvtest/{/qemuxml2argvtest/d;}' tests/meson.build 143 '' + optionalString isDarwin '' 144 sed -i '/qemucapabilitiestest/d' tests/meson.build 145 ''; 146 147 148 nativeBuildInputs = [ 149 meson 150 151 cmake 152 docutils 153 makeWrapper 154 ninja 155 pkg-config 156 ] 157 ++ optional (!isDarwin) rpcsvc-proto 158 # NOTE: needed for rpcgen 159 ++ optional isDarwin darwin.developer_cmds; 160 161 buildInputs = [ 162 bash-completion 163 curl 164 dbus 165 gettext 166 glib 167 gnutls 168 libgcrypt 169 libpcap 170 libtasn1 171 libxml2 172 libxslt 173 perl 174 perlPackages.XMLXPath 175 pkg-config 176 python3 177 readline 178 xhtml1 179 yajl 180 ] ++ optionals isLinux [ 181 acl 182 attr 183 audit 184 fuse 185 libapparmor 186 libcap_ng 187 libnl 188 libpciaccess 189 libtirpc 190 lvm2 191 numactl 192 numad 193 parted 194 systemd 195 util-linux 196 ] ++ optionals isDarwin [ 197 AppKit 198 Carbon 199 gmp 200 libiconv 201 ] 202 ++ optionals enableCeph [ ceph ] 203 ++ optionals enableGlusterfs [ glusterfs ] 204 ++ optionals enableIscsi [ libiscsi openiscsi ] 205 ++ optionals enableXen [ xen ] 206 ++ optionals enableZfs [ zfs ]; 207 208 preConfigure = 209 let 210 overrides = { 211 QEMU_BRIDGE_HELPER = "/run/wrappers/bin/qemu-bridge-helper"; 212 QEMU_PR_HELPER = "/run/libvirt/nix-helpers/qemu-pr-helper"; 213 }; 214 215 patchBuilder = var: value: '' 216 sed -i meson.build -e "s|conf.set_quoted('${var}',.*|conf.set_quoted('${var}','${value}')|" 217 ''; 218 in 219 '' 220 PATH="${binPath}:$PATH" 221 # the path to qemu-kvm will be stored in VM's .xml and .save files 222 # do not use "''${qemu_kvm}/bin/qemu-kvm" to avoid bound VMs to particular qemu derivations 223 substituteInPlace src/lxc/lxc_conf.c \ 224 --replace 'lxc_path,' '"/run/libvirt/nix-emulators/libvirt_lxc",' 225 226 substituteInPlace build-aux/meson.build \ 227 --replace "gsed" "sed" \ 228 --replace "gmake" "make" \ 229 --replace "ggrep" "grep" 230 231 substituteInPlace src/util/virpolkit.h \ 232 --replace '"/usr/bin/pkttyagent"' '"${polkit.bin}/bin/pkttyagent"' 233 234 patchShebangs . 235 '' 236 + (lib.concatStringsSep "\n" (lib.mapAttrsToList patchBuilder overrides)); 237 238 mesonAutoFeatures = "disabled"; 239 240 mesonFlags = 241 let 242 cfg = option: val: "-D${option}=${val}"; 243 feat = option: enable: cfg option (if enable then "enabled" else "disabled"); 244 driver = name: feat "driver_${name}"; 245 storage = name: feat "storage_${name}"; 246 in 247 [ 248 "--sysconfdir=/var/lib" 249 (cfg "install_prefix" (placeholder "out")) 250 (cfg "localstatedir" "/var") 251 (cfg "runstatedir" "/run") 252 253 (cfg "init_script" (if isDarwin then "none" else "systemd")) 254 255 (feat "apparmor" isLinux) 256 (feat "attr" isLinux) 257 (feat "audit" isLinux) 258 (feat "bash_completion" true) 259 (feat "blkid" isLinux) 260 (feat "capng" isLinux) 261 (feat "curl" true) 262 (feat "docs" true) 263 (feat "expensive_tests" true) 264 (feat "firewalld" isLinux) 265 (feat "firewalld_zone" isLinux) 266 (feat "fuse" isLinux) 267 (feat "glusterfs" enableGlusterfs) 268 (feat "host_validate" true) 269 (feat "libiscsi" enableIscsi) 270 (feat "libnl" isLinux) 271 (feat "libpcap" true) 272 (feat "libssh2" true) 273 (feat "login_shell" isLinux) 274 (feat "nss" isLinux) 275 (feat "numactl" isLinux) 276 (feat "numad" isLinux) 277 (feat "pciaccess" isLinux) 278 (feat "polkit" true) 279 (feat "readline" true) 280 (feat "secdriver_apparmor" isLinux) 281 (feat "tests" true) 282 (feat "udev" isLinux) 283 (feat "yajl" true) 284 285 (driver "ch" isLinux) 286 (driver "esx" true) 287 (driver "interface" isLinux) 288 (driver "libvirtd" true) 289 (driver "libxl" enableXen) 290 (driver "lxc" isLinux) 291 (driver "network" true) 292 (driver "openvz" isLinux) 293 (driver "qemu" true) 294 (driver "remote" true) 295 (driver "secrets" true) 296 (driver "test" true) 297 (driver "vbox" true) 298 (driver "vmware" true) 299 300 (storage "dir" true) 301 (storage "disk" isLinux) 302 (storage "fs" isLinux) 303 (storage "gluster" enableGlusterfs) 304 (storage "iscsi" enableIscsi) 305 (storage "iscsi_direct" enableIscsi) 306 (storage "lvm" isLinux) 307 (storage "mpath" isLinux) 308 (storage "rbd" enableCeph) 309 (storage "scsi" true) 310 (storage "vstorage" isLinux) 311 (storage "zfs" enableZfs) 312 ]; 313 314 doCheck = true; 315 316 postInstall = '' 317 substituteInPlace $out/bin/virt-xml-validate \ 318 --replace xmllint ${libxml2}/bin/xmllint 319 320 substituteInPlace $out/libexec/libvirt-guests.sh \ 321 --replace 'ON_BOOT="start"' 'ON_BOOT=''${ON_BOOT:-start}' \ 322 --replace 'ON_SHUTDOWN="suspend"' 'ON_SHUTDOWN=''${ON_SHUTDOWN:-suspend}' \ 323 --replace "$out/bin" '${gettext}/bin' \ 324 --replace 'lock/subsys' 'lock' \ 325 --replace 'gettext.sh' 'gettext.sh 326 # Added in nixpkgs: 327 gettext() { "${gettext}/bin/gettext" "$@"; } 328 ' 329 '' + optionalString isLinux '' 330 for f in $out/lib/systemd/system/*.service ; do 331 substituteInPlace $f --replace /bin/kill ${coreutils}/bin/kill 332 done 333 rm $out/lib/systemd/system/{virtlockd,virtlogd}.* 334 wrapProgram $out/sbin/libvirtd \ 335 --prefix PATH : /run/libvirt/nix-emulators:${binPath} 336 ''; 337 338 meta = { 339 homepage = "https://libvirt.org/"; 340 description = '' 341 A toolkit to interact with the virtualization capabilities of recent 342 versions of Linux (and other OSes) 343 ''; 344 license = licenses.lgpl2Plus; 345 platforms = platforms.unix; 346 maintainers = with maintainers; [ fpletz globin lovesegfault ]; 347 }; 348}