Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 21.11 250 lines 5.9 kB view raw
1{ lib 2, stdenv 3, fetchurl 4, fetchFromGitLab 5, makeWrapper 6, autoreconfHook 7, fetchpatch 8, coreutils 9, libxml2 10, gnutls 11, perl 12, python3 13, attr 14, glib 15, docutils 16, iproute2 17, readline 18, lvm2 19, util-linux 20, systemd 21, libpciaccess 22, gettext 23, libtasn1 24, iptables 25, libgcrypt 26, yajl 27, pmutils 28, libcap_ng 29, libapparmor 30, dnsmasq 31, libnl 32, libpcap 33, libxslt 34, xhtml1 35, numad 36, numactl 37, perlPackages 38, curl 39, libiconv 40, gmp 41, zfs 42, parted 43, bridge-utils 44, dmidecode 45, dbus 46, libtirpc 47, rpcsvc-proto 48, darwin 49, meson 50, ninja 51, audit 52, cmake 53, bash-completion 54, pkg-config 55, enableXen ? false 56, xen ? null 57, enableIscsi ? false 58, openiscsi 59, enableCeph ? false 60, ceph 61, enableGlusterfs ? false 62, glusterfs 63, Carbon 64, AppKit 65}: 66 67with lib; 68 69# if you update, also bump <nixpkgs/pkgs/development/python-modules/libvirt/default.nix> and SysVirt in <nixpkgs/pkgs/top-level/perl-packages.nix> 70let 71 buildFromTarball = stdenv.isDarwin; 72in 73stdenv.mkDerivation rec { 74 pname = "libvirt"; 75 version = "7.9.0"; 76 77 src = 78 if buildFromTarball then 79 fetchurl 80 { 81 url = "https://libvirt.org/sources/${pname}-${version}.tar.xz"; 82 sha256 = "sha256-gpzytfV0J5xA8ERuEWiBXT82uJcQVgJjyiznAlb3Low="; 83 } 84 else 85 fetchFromGitLab 86 { 87 owner = pname; 88 repo = pname; 89 rev = "v${version}"; 90 sha256 = "sha256-Ua6+EKLES3385fqhH2+qwnwE+X/nmWqIBxCXXE3SVhs="; 91 fetchSubmodules = true; 92 }; 93 94 patches = [ 95 ./0001-meson-patch-in-an-install-prefix-for-building-on-nix.patch 96 ./0002-meson-patch-ch-install-prefix.patch 97 ]; 98 99 nativeBuildInputs = [ 100 ninja 101 meson 102 cmake 103 makeWrapper 104 pkg-config 105 docutils 106 ] ++ optional (!stdenv.isDarwin) [ 107 rpcsvc-proto 108 ] ++ optionals stdenv.isDarwin [ 109 darwin.developer_cmds # needed for rpcgen 110 ]; 111 112 buildInputs = [ 113 bash-completion 114 pkg-config 115 libxml2 116 gnutls 117 perl 118 python3 119 readline 120 gettext 121 libtasn1 122 libgcrypt 123 yajl 124 libxslt 125 xhtml1 126 perlPackages.XMLXPath 127 curl 128 libpcap 129 glib 130 dbus 131 ] ++ optionals stdenv.isLinux [ 132 audit 133 libpciaccess 134 lvm2 135 util-linux 136 systemd 137 libnl 138 numad 139 zfs 140 libapparmor 141 libcap_ng 142 numactl 143 attr 144 parted 145 libtirpc 146 ] ++ optionals (enableXen && stdenv.isLinux && stdenv.isx86_64) [ 147 xen 148 ] ++ optionals enableIscsi [ 149 openiscsi 150 ] ++ optionals enableCeph [ 151 ceph 152 ] ++ optionals enableGlusterfs [ 153 glusterfs 154 ] ++ optionals stdenv.isDarwin [ 155 libiconv 156 gmp 157 Carbon 158 AppKit 159 ]; 160 161 preConfigure = 162 let 163 overrides = { 164 QEMU_BRIDGE_HELPER = "/run/wrappers/bin/qemu-bridge-helper"; 165 QEMU_PR_HELPER = "/run/libvirt/nix-helpers/qemu-pr-helper"; 166 }; 167 patchBuilder = var: value: '' 168 sed -i meson.build -e "s|conf.set_quoted('${var}',.*|conf.set_quoted('${var}','${value}')|" 169 ''; 170 in 171 '' 172 PATH=${lib.makeBinPath ([ dnsmasq ] ++ optionals stdenv.isLinux [ iproute2 iptables lvm2 systemd numad ] ++ optionals enableIscsi [ openiscsi ])}:$PATH 173 # the path to qemu-kvm will be stored in VM's .xml and .save files 174 # do not use "''${qemu_kvm}/bin/qemu-kvm" to avoid bound VMs to particular qemu derivations 175 substituteInPlace src/lxc/lxc_conf.c \ 176 --replace 'lxc_path,' '"/run/libvirt/nix-emulators/libvirt_lxc",' 177 substituteInPlace build-aux/meson.build \ 178 --replace "gsed" "sed" \ 179 --replace "gmake" "make" \ 180 --replace "ggrep" "grep" 181 patchShebangs . 182 '' 183 + (lib.concatStringsSep "\n" (lib.mapAttrsToList patchBuilder overrides)); 184 185 mesonAutoFeatures = "auto"; 186 187 mesonFlags = 188 let 189 opt = option: enable: "-D${option}=${if enable then "enabled" else "disabled"}"; 190 in 191 [ 192 "--sysconfdir=/var/lib" 193 "-Dinstall_prefix=${placeholder "out"}" 194 "-Dlocalstatedir=/var" 195 "-Drunstatedir=/run" 196 "-Dlibpcap=enabled" 197 "-Ddriver_qemu=enabled" 198 "-Ddriver_vmware=enabled" 199 "-Ddriver_vbox=enabled" 200 "-Ddriver_test=enabled" 201 "-Ddriver_esx=enabled" 202 "-Ddriver_remote=enabled" 203 "-Dpolkit=enabled" 204 (opt "storage_iscsi" enableIscsi) 205 ] ++ optionals stdenv.isLinux [ 206 (opt "storage_zfs" (zfs != null)) 207 "-Dattr=enabled" 208 "-Dapparmor=enabled" 209 "-Dsecdriver_apparmor=enabled" 210 "-Dnumad=enabled" 211 "-Dstorage_disk=enabled" 212 (opt "glusterfs" enableGlusterfs) 213 (opt "storage_rbd" enableCeph) 214 ] ++ optionals stdenv.isDarwin [ 215 "-Dinit_script=none" 216 ]; 217 218 postInstall = 219 let 220 binPath = [ iptables iproute2 pmutils numad numactl bridge-utils dmidecode dnsmasq ] ++ optionals enableIscsi [ openiscsi ]; 221 in 222 '' 223 substituteInPlace $out/libexec/libvirt-guests.sh \ 224 --replace 'ON_BOOT="start"' 'ON_BOOT=''${ON_BOOT:-start}' \ 225 --replace 'ON_SHUTDOWN="suspend"' 'ON_SHUTDOWN=''${ON_SHUTDOWN:-suspend}' \ 226 --replace "$out/bin" '${gettext}/bin' \ 227 --replace 'lock/subsys' 'lock' \ 228 --replace 'gettext.sh' 'gettext.sh 229 # Added in nixpkgs: 230 gettext() { "${gettext}/bin/gettext" "$@"; } 231 ' 232 '' + optionalString stdenv.isLinux '' 233 substituteInPlace $out/lib/systemd/system/libvirtd.service --replace /bin/kill ${coreutils}/bin/kill 234 rm $out/lib/systemd/system/{virtlockd,virtlogd}.* 235 wrapProgram $out/sbin/libvirtd \ 236 --prefix PATH : /run/libvirt/nix-emulators:${makeBinPath binPath} 237 ''; 238 239 meta = { 240 homepage = "https://libvirt.org/"; 241 repositories.git = "git://libvirt.org/libvirt.git"; 242 description = '' 243 A toolkit to interact with the virtualization capabilities of recent 244 versions of Linux (and other OSes) 245 ''; 246 license = licenses.lgpl2Plus; 247 platforms = platforms.unix; 248 maintainers = with maintainers; [ fpletz globin ]; 249 }; 250}