Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at release-18.03 110 lines 3.8 kB view raw
1{ stdenv, fetchurl, fetchpatch 2, pkgconfig, makeWrapper 3, coreutils, libxml2, gnutls, devicemapper, perl, python2, attr 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, xen, zfs, parted 8}: 9 10with stdenv.lib; 11 12# if you update, also bump <nixpkgs/pkgs/development/python-modules/libvirt/default.nix> or it will break 13stdenv.mkDerivation rec { 14 name = "libvirt-${version}"; 15 version = "3.10.0"; 16 17 src = fetchurl { 18 url = "http://libvirt.org/sources/${name}.tar.xz"; 19 sha256 = "03kb37iv3dvvdlslznlc0njvjpmq082lczmsslz5p4fcwb50kwfz"; 20 }; 21 22 patches = [ ./build-on-bsd.patch ]; 23 24 nativeBuildInputs = [ makeWrapper pkgconfig ]; 25 buildInputs = [ 26 libxml2 gnutls perl python2 readline gettext libtasn1 libgcrypt yajl 27 libxslt xhtml1 perlPackages.XMLXPath curl libpcap 28 ] ++ optionals stdenv.isLinux [ 29 libpciaccess devicemapper lvm2 utillinux systemd libnl numad zfs 30 libapparmor libcap_ng numactl attr parted 31 ] ++ optionals (stdenv.isLinux && stdenv.isx86_64) [ 32 xen 33 ] ++ optionals stdenv.isDarwin [ 34 libiconv gmp 35 ]; 36 37 preConfigure = optionalString stdenv.isLinux '' 38 PATH=${stdenv.lib.makeBinPath [ iproute iptables ebtables lvm2 systemd ]}:$PATH 39 substituteInPlace configure \ 40 --replace 'as_dummy="/bin:/usr/bin:/usr/sbin"' 'as_dummy="${numad}/bin"' 41 42 # the path to qemu-kvm will be stored in VM's .xml and .save files 43 # do not use "''${qemu_kvm}/bin/qemu-kvm" to avoid bound VMs to particular qemu derivations 44 substituteInPlace src/lxc/lxc_conf.c \ 45 --replace 'lxc_path,' '"/run/libvirt/nix-emulators/libvirt_lxc",' 46 '' + '' 47 PATH=${dnsmasq}/bin:$PATH 48 patchShebangs . # fixes /usr/bin/python references 49 ''; 50 51 configureFlags = [ 52 "--localstatedir=/var" 53 "--sysconfdir=/var/lib" 54 "--with-libpcap" 55 "--with-vmware" 56 "--with-vbox" 57 "--with-test" 58 "--with-esx" 59 "--with-remote" 60 ] ++ optionals stdenv.isLinux [ 61 "--with-attr" 62 "--with-apparmor" 63 "--with-secdriver-apparmor" 64 "--with-numad" 65 "--with-macvtap" 66 "--with-virtualport" 67 "--with-init-script=systemd+redhat" 68 "--with-storage-disk" 69 ] ++ optionals (stdenv.isLinux && zfs != null) [ 70 "--with-storage-zfs" 71 ] ++ optionals stdenv.isDarwin [ 72 "--with-init-script=none" 73 ]; 74 75 installFlags = [ 76 "localstatedir=$(TMPDIR)/var" 77 "sysconfdir=$(out)/var/lib" 78 ]; 79 80 postInstall = '' 81 sed -i 's/ON_SHUTDOWN=suspend/ON_SHUTDOWN=''${ON_SHUTDOWN:-suspend}/' $out/libexec/libvirt-guests.sh 82 substituteInPlace $out/libexec/libvirt-guests.sh \ 83 --replace "$out/bin" "${gettext}/bin" \ 84 --replace "lock/subsys" "lock" 85 sed -e "/gettext\.sh/a \\\n# Added in nixpkgs:\ngettext() { \"${gettext}/bin/gettext\" \"\$@\"; }" \ 86 -i "$out/libexec/libvirt-guests.sh" 87 88 '' + optionalString stdenv.isLinux '' 89 substituteInPlace $out/lib/systemd/system/libvirtd.service --replace /bin/kill ${coreutils}/bin/kill 90 rm $out/lib/systemd/system/{virtlockd,virtlogd}.* 91 wrapProgram $out/sbin/libvirtd \ 92 --prefix PATH : /run/libvirt/nix-emulators:${makeBinPath [ iptables iproute pmutils numad numactl ]} 93 ''; 94 95 enableParallelBuilding = true; 96 97 NIX_CFLAGS_COMPILE = "-fno-stack-protector"; 98 99 meta = { 100 homepage = http://libvirt.org/; 101 repositories.git = git://libvirt.org/libvirt.git; 102 description = '' 103 A toolkit to interact with the virtualization capabilities of recent 104 versions of Linux (and other OSes) 105 ''; 106 license = licenses.lgpl2Plus; 107 platforms = platforms.unix; 108 maintainers = with maintainers; [ fpletz ]; 109 }; 110}