nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 20.09 140 lines 4.9 kB view raw
1{ stdenv, fetchurl, fetchgit 2, pkgconfig, makeWrapper, autoreconfHook, fetchpatch 3, coreutils, libxml2, gnutls, perl, python2, attr, glib, docutils 4, iproute, iptables, readline, lvm2, utillinux, systemd, libpciaccess, gettext 5, libtasn1, ebtables, libgcrypt, yajl, pmutils, libcap_ng, libapparmor 6, dnsmasq, libnl, libpcap, libxslt, xhtml1, numad, numactl, perlPackages 7, curl, libiconv, gmp, zfs, parted, bridge-utils, dmidecode, dbus 8, enableXen ? false, xen ? null 9, enableIscsi ? false, openiscsi 10, enableCeph ? false, ceph 11}: 12 13with stdenv.lib; 14 15# if you update, also bump <nixpkgs/pkgs/development/python-modules/libvirt/default.nix> and SysVirt in <nixpkgs/pkgs/top-level/perl-packages.nix> 16let 17 buildFromTarball = stdenv.isDarwin; 18in stdenv.mkDerivation rec { 19 pname = "libvirt"; 20 version = "6.3.0"; 21 22 src = 23 if buildFromTarball then 24 fetchurl { 25 url = "http://libvirt.org/sources/${pname}-${version}.tar.xz"; 26 sha256 = "1xcng497hs1gary3pz3fp590a4r1kqs4d0d8k5p370j0scw981kl"; 27 } 28 else 29 fetchgit { 30 url = "git://libvirt.org/libvirt.git"; 31 rev = "v${version}"; 32 sha256 = "129b3p72jlb40dsidak3nvpssv75xx2v99y63gzp5k074fp8y8x4"; 33 fetchSubmodules = true; 34 }; 35 36 nativeBuildInputs = [ makeWrapper pkgconfig docutils ] ++ optionals (!buildFromTarball) [ autoreconfHook ]; 37 buildInputs = [ 38 libxml2 gnutls perl python2 readline gettext libtasn1 libgcrypt yajl 39 libxslt xhtml1 perlPackages.XMLXPath curl libpcap glib dbus 40 ] ++ optionals stdenv.isLinux [ 41 libpciaccess lvm2 utillinux systemd libnl numad zfs 42 libapparmor libcap_ng numactl attr parted 43 ] ++ optionals (enableXen && stdenv.isLinux && stdenv.isx86_64) [ 44 xen 45 ] ++ optionals enableIscsi [ 46 openiscsi 47 ] ++ optionals enableCeph [ 48 ceph 49 ] ++ optionals stdenv.isDarwin [ 50 libiconv gmp 51 ]; 52 53 preConfigure = '' 54 PATH=${stdenv.lib.makeBinPath ([ dnsmasq ] ++ optionals stdenv.isLinux [ iproute iptables ebtables lvm2 systemd numad ] ++ optionals enableIscsi [ openiscsi ])}:$PATH 55 # the path to qemu-kvm will be stored in VM's .xml and .save files 56 # do not use "''${qemu_kvm}/bin/qemu-kvm" to avoid bound VMs to particular qemu derivations 57 substituteInPlace src/lxc/lxc_conf.c \ 58 --replace 'lxc_path,' '"/run/libvirt/nix-emulators/libvirt_lxc",' 59 patchShebangs . # fixes /usr/bin/python references 60 mkdir -p build && cd build 61 ''; 62 63 configureScript = "../configure"; 64 65 dontAddDisableDepTrack = true; 66 67 configureFlags = [ 68 "--with-runstatedir=/run" # TODO: remove when autoconf 1.70 is released 69 "--localstatedir=/var" 70 "--sysconfdir=/var/lib" 71 "--with-libpcap" 72 "--with-qemu" 73 "--with-vmware" 74 "--with-vbox" 75 "--with-test" 76 "--with-esx" 77 "--with-remote" 78 "--with-polkit" 79 ] ++ optionals stdenv.isLinux [ 80 "QEMU_BRIDGE_HELPER=/run/wrappers/bin/qemu-bridge-helper" 81 "QEMU_PR_HELPER=/run/libvirt/nix-helpers/qemu-pr-helper" 82 "EBTABLES_PATH=${ebtables}/bin/ebtables-legacy" 83 "--with-attr" 84 "--with-apparmor" 85 "--with-secdriver-apparmor" 86 "--with-numad" 87 "--with-macvtap" 88 "--with-virtualport" 89 "--with-storage-disk" 90 ] ++ optionals (stdenv.isLinux && zfs != null) [ 91 "--with-storage-zfs" 92 ] ++ optionals enableIscsi [ 93 "--with-storage-iscsi" 94 ] ++ optionals enableCeph [ 95 "--with-storage-rbd" 96 ] ++ optionals stdenv.isDarwin [ 97 "--with-init-script=none" 98 ]; 99 100 installFlags = [ 101 "runstatedir=${placeholder "out"}/run" 102 "localstatedir=$(TMPDIR)/var" 103 "sysconfdir=$(out)/var/lib" 104 ]; 105 106 postInstall = let 107 binPath = [ iptables iproute pmutils numad numactl bridge-utils dmidecode dnsmasq ebtables ] ++ optionals enableIscsi [ openiscsi ]; 108 in '' 109 substituteInPlace $out/libexec/libvirt-guests.sh \ 110 --replace 'ON_BOOT=start' 'ON_BOOT=''${ON_BOOT:-start}' \ 111 --replace 'ON_SHUTDOWN=suspend' 'ON_SHUTDOWN=''${ON_SHUTDOWN:-suspend}' \ 112 --replace "$out/bin" '${gettext}/bin' \ 113 --replace 'lock/subsys' 'lock' \ 114 --replace 'gettext.sh' 'gettext.sh 115 # Added in nixpkgs: 116 gettext() { "${gettext}/bin/gettext" "$@"; } 117 ' 118 '' + optionalString stdenv.isLinux '' 119 substituteInPlace $out/lib/systemd/system/libvirtd.service --replace /bin/kill ${coreutils}/bin/kill 120 rm $out/lib/systemd/system/{virtlockd,virtlogd}.* 121 wrapProgram $out/sbin/libvirtd \ 122 --prefix PATH : /run/libvirt/nix-emulators:${makeBinPath binPath} 123 ''; 124 125 enableParallelBuilding = true; 126 127 NIX_CFLAGS_COMPILE = "-fno-stack-protector"; 128 129 meta = { 130 homepage = "http://libvirt.org/"; 131 repositories.git = "git://libvirt.org/libvirt.git"; 132 description = '' 133 A toolkit to interact with the virtualization capabilities of recent 134 versions of Linux (and other OSes) 135 ''; 136 license = licenses.lgpl2Plus; 137 platforms = platforms.unix; 138 maintainers = with maintainers; [ fpletz globin ]; 139 }; 140}