summary refs log tree commit diff
path: root/pkgs/os-specific/linux/qemu-kvm/default.nix
blob: 2f93769d280141981a5cf123f2f7a44f95adc454 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ stdenv, fetchurl, attr, zlib, SDL, alsaLib, pkgconfig, pciutils, libuuid, vde2
, libjpeg, libpng, ncurses, python, glib, libaio, mesa, perl, texinfo
, spice, spice_protocol, spiceSupport ? false }:

assert stdenv.isLinux;

let version = "1.2.0"; in

stdenv.mkDerivation rec {
  name = "qemu-kvm-${version}";

  src = fetchurl {
    url = "mirror://sourceforge/kvm/qemu-kvm/${version}/${name}.tar.gz";
    sha256 = "018vb5nmk2fsm143bs2bl2wirhasd4b10d7jchl32zik4inbk2p9";
  };

  buildInputs =
    [ attr zlib SDL alsaLib pkgconfig pciutils libuuid vde2 libjpeg libpng
      ncurses python glib libaio mesa texinfo perl
    ] ++ stdenv.lib.optionals spiceSupport [ spice_protocol spice ];

  patches = [ ./fix-librt-check.patch ./fix-usb-passthrough.patch ];

  postPatch = ''
      patchShebangs .
      sed '/qtest_add_func.*check_time/d' -i tests/rtc-test.c
    '' # disable tests that meddle with system time, they seem to work bad, maybe due to newer glib
    + stdenv.lib.optionalString spiceSupport ''
       for i in configure spice-qemu-char.c ui/spice-input.c ui/spice-core.c ui/qemu-spice.h; do
         substituteInPlace $i --replace '#include <spice.h>' '#include <spice/spice.h>'
       done
    '';

  configureFlags =
    [ "--audio-drv-list=alsa"
      "--smbd=smbd"                               # use `smbd' from $PATH
      "--enable-docs"
      "--python=${python}/bin/python"
    ] ++ stdenv.lib.optional spiceSupport "--enable-spice";

  postInstall =
    ''
      # Libvirt expects us to be called `qemu-kvm'.  Otherwise it will
      # set the domain type to "qemu" rather than "kvm", which can
      # cause architecture selection to misbehave.
      ln -sv $(cd $out/bin && echo qemu-system-*) $out/bin/qemu-kvm
    '';

  doCheck = true;

  enableParallelBuilding = true;

  meta = {
    homepage = http://www.linux-kvm.org/;
    description = "A full virtualization solution for Linux on x86 hardware containing virtualization extensions";
    platforms = stdenv.lib.platforms.linux;
  };
}