summary refs log tree commit diff
path: root/pkgs/development/libraries/libvirt/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/libraries/libvirt/default.nix')
-rw-r--r--pkgs/development/libraries/libvirt/default.nix372
1 files changed, 151 insertions, 221 deletions
diff --git a/pkgs/development/libraries/libvirt/default.nix b/pkgs/development/libraries/libvirt/default.nix
index 7d2bc995da6a6..03d0e17cb4c3e 100644
--- a/pkgs/development/libraries/libvirt/default.nix
+++ b/pkgs/development/libraries/libvirt/default.nix
@@ -1,119 +1,85 @@
 { lib
+, stdenv
+, fetchurl
+, fetchFromGitLab
+, makeWrapper
 , autoreconfHook
-, bash-completion
-, bridge-utils
-, cmake
+, fetchpatch
 , coreutils
-, curl
-, darwin
-, dbus
-, dnsmasq
-, docutils
-, fetchFromGitLab
-, fetchurl
-, gettext
-, glib
+, libxml2
 , gnutls
+, perl
+, python3
+, attr
+, glib
+, docutils
 , iproute2
+, readline
+, lvm2
+, util-linux
+, systemd
+, libpciaccess
+, gettext
+, libtasn1
 , iptables
 , libgcrypt
+, yajl
+, pmutils
+, libcap_ng
+, libapparmor
+, dnsmasq
+, libnl
 , libpcap
-, libtasn1
-, libxml2
 , libxslt
-, makeWrapper
+, xhtml1
+, numad
+, numactl
+, perlPackages
+, curl
+, libiconv
+, gmp
+, zfs
+, parted
+, bridge-utils
+, dmidecode
+, dbus
+, libtirpc
+, rpcsvc-proto
+, darwin
 , meson
 , ninja
-, perl
-, perlPackages
+, audit
+, cmake
+, bash-completion
 , pkg-config
-, pmutils
-, python3
-, readline
-, rpcsvc-proto
-, stdenv
-, xhtml1
-, yajl
-
-  # Linux
-, acl ? null
-, attr ? null
-, audit ? null
-, dmidecode ? null
-, fuse ? 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 ? null
-, libiconv ? null
-, Carbon ? null
-, AppKit ? null
-
-  # Options
-, enableCeph ? false
-, ceph ? null
-, enableGlusterfs ? false
-, glusterfs ? null
-, enableIscsi ? false
-, openiscsi ? null
-, libiscsi ? null
 , enableXen ? false
 , xen ? null
-, enableZfs ? stdenv.isLinux
-, zfs ? null
+, enableIscsi ? false
+, openiscsi
+, enableCeph ? false
+, ceph
+, enableGlusterfs ? false
+, glusterfs
+, Carbon
+, AppKit
 }:
 
 with lib;
 
+# if you update, also bump <nixpkgs/pkgs/development/python-modules/libvirt/default.nix> and SysVirt in <nixpkgs/pkgs/top-level/perl-packages.nix>
 let
-  inherit (stdenv) isDarwin isLinux isx86_64;
-  binPath = makeBinPath ([
-    dnsmasq
-  ] ++ optionals isLinux [
-    bridge-utils
-    dmidecode
-    dnsmasq
-    iproute2
-    iptables
-    kmod
-    lvm2
-    numactl
-    numad
-    pmutils
-    systemd
-  ] ++ optionals enableIscsi [
-    libiscsi
-    openiscsi
-  ]);
+  buildFromTarball = stdenv.isDarwin;
 in
-
-assert enableXen -> isLinux && isx86_64;
-assert enableCeph -> isLinux;
-assert enableGlusterfs -> isLinux;
-assert enableZfs -> isLinux;
-
-# if you update, also bump <nixpkgs/pkgs/development/python-modules/libvirt/default.nix> and SysVirt in <nixpkgs/pkgs/top-level/perl-packages.nix>
 stdenv.mkDerivation rec {
   pname = "libvirt";
-  version = "8.1.0";
+  version = "7.10.0";
 
   src =
-    if isDarwin then
+    if buildFromTarball then
       fetchurl
         {
           url = "https://libvirt.org/sources/${pname}-${version}.tar.xz";
-          sha256 = "sha256-PGxDvs/+s0o/OXxhYgaqaaiT/4v16CCDk8hOjnU1KTQ=";
+          sha256 = "sha256-yzGAFK8JcyeSjG49cpIuO+AqPmQBJHsqpS2auOC0gPk=";
         }
     else
       fetchFromGitLab
@@ -121,74 +87,76 @@ stdenv.mkDerivation rec {
           owner = pname;
           repo = pname;
           rev = "v${version}";
-          sha256 = "sha256-nk8pBlss+g4EMy+RnAOyz6YlGGvlBvl5aBpcytsK1wY=";
+          sha256 = "sha256-bB8LsjZFeJbMmmC0YRPyMag2MBhwagUFC7aB1KhZEkA=";
           fetchSubmodules = true;
         };
 
   patches = [
-    ./do-not-use-sysconfig.patch
-    ./qemu-segmentation-fault-in-virtqemud-executing-qemuD.patch
+    ./0001-meson-patch-in-an-install-prefix-for-building-on-nix.patch
+    ./0002-meson-patch-ch-install-prefix.patch
   ];
 
   nativeBuildInputs = [
+    ninja
     meson
-
     cmake
-    docutils
     makeWrapper
-    ninja
     pkg-config
-  ]
-  ++ optional (!isDarwin) rpcsvc-proto
-  # NOTE: needed for rpcgen
-  ++ optional isDarwin darwin.developer_cmds;
+    docutils
+  ] ++ optional (!stdenv.isDarwin) [
+    rpcsvc-proto
+  ] ++ optionals stdenv.isDarwin [
+    darwin.developer_cmds # needed for rpcgen
+  ];
 
   buildInputs = [
     bash-completion
-    curl
-    dbus
-    gettext
-    glib
-    gnutls
-    libgcrypt
-    libpcap
-    libtasn1
+    pkg-config
     libxml2
-    libxslt
+    gnutls
     perl
-    perlPackages.XMLXPath
-    pkg-config
     python3
     readline
-    xhtml1
+    gettext
+    libtasn1
+    libgcrypt
     yajl
-  ] ++ optionals isLinux [
-    acl
-    attr
+    libxslt
+    xhtml1
+    perlPackages.XMLXPath
+    curl
+    libpcap
+    glib
+    dbus
+  ] ++ optionals stdenv.isLinux [
     audit
-    fuse
-    libapparmor
-    libcap_ng
-    libnl
     libpciaccess
-    libtirpc
     lvm2
-    numactl
+    util-linux
+    systemd
+    libnl
     numad
+    zfs
+    libapparmor
+    libcap_ng
+    numactl
+    attr
     parted
-    systemd
-    util-linux
-  ] ++ optionals isDarwin [
-    AppKit
-    Carbon
-    gmp
+    libtirpc
+  ] ++ optionals (enableXen && stdenv.isLinux && stdenv.isx86_64) [
+    xen
+  ] ++ optionals enableIscsi [
+    openiscsi
+  ] ++ optionals enableCeph [
+    ceph
+  ] ++ optionals enableGlusterfs [
+    glusterfs
+  ] ++ optionals stdenv.isDarwin [
     libiconv
-  ]
-  ++ optionals enableCeph [ ceph ]
-  ++ optionals enableGlusterfs [ glusterfs ]
-  ++ optionals enableIscsi [ libiscsi openiscsi ]
-  ++ optionals enableXen [ xen ]
-  ++ optionals enableZfs [ zfs ];
+    gmp
+    Carbon
+    AppKit
+  ];
 
   preConfigure =
     let
@@ -196,118 +164,80 @@ stdenv.mkDerivation rec {
         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"
+      PATH=${lib.makeBinPath ([ dnsmasq ] ++ optionals stdenv.isLinux [ iproute2 iptables lvm2 systemd numad ] ++ optionals enableIscsi [ openiscsi ])}:$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"
-
       patchShebangs .
     ''
     + (lib.concatStringsSep "\n" (lib.mapAttrsToList patchBuilder overrides));
 
-  mesonAutoFeatures = "disabled";
+  mesonAutoFeatures = "auto";
 
   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}";
+      opt = option: enable: "-D${option}=${if enable then "enabled" else "disabled"}";
     in
     [
-      "--localstatedir=${placeholder "out"}/var/"
-      (cfg "init_script" (if isDarwin then "none" else "systemd"))
-
-      (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)
-      (feat "numactl" isLinux)
-      (feat "numad" isLinux)
-      (feat "pciaccess" isLinux)
-      (feat "polkit" true)
-      (feat "readline" true)
-      (feat "secdriver_apparmor" isLinux)
-      (feat "tests" true)
-      (feat "udev" isLinux)
-      (feat "yajl" true)
-
-      (driver "ch" isLinux)
-      (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)
+      "--sysconfdir=/var/lib"
+      "-Dinstall_prefix=${placeholder "out"}"
+      "-Dlocalstatedir=/var"
+      "-Drunstatedir=/run"
+      "-Dlibpcap=enabled"
+      "-Ddriver_qemu=enabled"
+      "-Ddriver_vmware=enabled"
+      "-Ddriver_vbox=enabled"
+      "-Ddriver_test=enabled"
+      "-Ddriver_esx=enabled"
+      "-Ddriver_remote=enabled"
+      "-Dpolkit=enabled"
+      (opt "storage_iscsi" enableIscsi)
+    ] ++ optionals stdenv.isLinux [
+      (opt "storage_zfs" (zfs != null))
+      "-Dattr=enabled"
+      "-Dapparmor=enabled"
+      "-Dsecdriver_apparmor=enabled"
+      "-Dnumad=enabled"
+      "-Dstorage_disk=enabled"
+      (opt "glusterfs" enableGlusterfs)
+      (opt "storage_rbd" enableCeph)
+    ] ++ optionals stdenv.isDarwin [
+      "-Dinit_script=none"
     ];
 
-  postInstall = ''
-    substituteInPlace $out/bin/virt-xml-validate \
-      --replace xmllint ${libxml2}/bin/xmllint
-
-    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 "$out/bin"              '${gettext}/bin' \
-      --replace 'lock/subsys'           'lock' \
-      --replace 'gettext.sh'            'gettext.sh
-    # Added in nixpkgs:
-    gettext() { "${gettext}/bin/gettext" "$@"; }
-    '
-  '' + optionalString isLinux ''
-    substituteInPlace $out/lib/systemd/system/libvirtd.service --replace /bin/kill ${coreutils}/bin/kill
-    rm $out/lib/systemd/system/{virtlockd,virtlogd}.*
-    wrapProgram $out/sbin/libvirtd \
-      --prefix PATH : /run/libvirt/nix-emulators:${binPath}
-  '';
+  postInstall =
+    let
+      binPath = [ iptables iproute2 pmutils numad numactl bridge-utils dmidecode dnsmasq ] ++ optionals enableIscsi [ openiscsi ];
+    in
+    ''
+      substituteInPlace $out/bin/virt-xml-validate \
+        --replace xmllint ${libxml2}/bin/xmllint
+
+      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 "$out/bin"              '${gettext}/bin' \
+        --replace 'lock/subsys'           'lock' \
+        --replace 'gettext.sh'            'gettext.sh
+      # Added in nixpkgs:
+      gettext() { "${gettext}/bin/gettext" "$@"; }
+      '
+    '' + optionalString stdenv.isLinux ''
+      substituteInPlace $out/lib/systemd/system/libvirtd.service --replace /bin/kill ${coreutils}/bin/kill
+      rm $out/lib/systemd/system/{virtlockd,virtlogd}.*
+      wrapProgram $out/sbin/libvirtd \
+        --prefix PATH : /run/libvirt/nix-emulators:${makeBinPath binPath}
+    '';
 
   meta = {
     homepage = "https://libvirt.org/";
@@ -318,6 +248,6 @@ stdenv.mkDerivation rec {
     '';
     license = licenses.lgpl2Plus;
     platforms = platforms.unix;
-    maintainers = with maintainers; [ fpletz globin lovesegfault ];
+    maintainers = with maintainers; [ fpletz globin ];
   };
 }