2011-03-29 17:19:59 +02:00
|
|
|
{ stdenv, fetchurl, which, zlib, pkgconfig, SDL, openssl
|
2014-12-22 00:03:08 +01:00
|
|
|
, libuuid, gettext, ncurses, dev86, iasl, pciutils, bzip2
|
|
|
|
, lvm2, utillinux, procps, texinfo, perl, pythonPackages
|
2015-09-15 11:26:18 +02:00
|
|
|
, glib, bridge-utils, xorg, pixman, iproute, udev, bison
|
2014-12-22 00:03:08 +01:00
|
|
|
, flex, cmake, ocaml, ocamlPackages, figlet, libaio, yajl
|
2015-07-02 16:33:01 +02:00
|
|
|
, checkpolicy, transfig, glusterfs, acl, fetchgit, xz, spice
|
2015-01-29 09:58:28 +01:00
|
|
|
, spice_protocol, usbredir, alsaLib, quilt
|
2016-01-21 16:07:38 +01:00
|
|
|
, coreutils, gawk, gnused, gnugrep, diffutils, multipath-tools
|
2015-01-29 09:58:28 +01:00
|
|
|
, inetutils, iptables, openvswitch, nbd, drbd, xenConfig
|
|
|
|
, xenserverPatched ? false, ... }:
|
2010-10-05 01:25:03 +02:00
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2010-10-06 13:04:07 +02:00
|
|
|
libDir = if stdenv.is64bit then "lib64" else "lib";
|
|
|
|
|
2016-03-09 19:56:14 +01:00
|
|
|
# Sources needed to build the tools
|
2015-01-29 09:58:28 +01:00
|
|
|
# These sources are already rather old and probably do not change frequently
|
2014-12-22 00:03:08 +01:00
|
|
|
xenExtfiles = [
|
|
|
|
{ url = http://xenbits.xensource.com/xen-extfiles/ipxe-git-9a93db3f0947484e30e753bbd61a10b17336e20e.tar.gz;
|
|
|
|
sha256 = "0p206zaxlhda60ci33h9gipi5gm46fvvsm6k5c0w7b6cjg0yhb33";
|
|
|
|
}
|
2010-10-05 01:25:03 +02:00
|
|
|
];
|
2010-09-09 18:45:18 +02:00
|
|
|
|
2015-01-29 09:58:28 +01:00
|
|
|
scriptEnvPath = stdenv.lib.concatStrings (stdenv.lib.intersperse ":" (map (x: "${x}/bin")
|
2016-01-21 16:07:38 +01:00
|
|
|
[ coreutils gawk gnused gnugrep which perl diffutils utillinux multipath-tools
|
2015-02-26 20:49:33 +01:00
|
|
|
iproute inetutils iptables bridge-utils openvswitch nbd drbd ]));
|
2014-08-08 17:58:34 +02:00
|
|
|
in
|
2010-09-09 18:45:18 +02:00
|
|
|
|
|
|
|
|
2015-01-29 09:58:28 +01:00
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
inherit (xenConfig) name version src;
|
2008-10-04 17:24:08 +02:00
|
|
|
|
2014-12-22 00:03:08 +01:00
|
|
|
dontUseCmakeConfigure = true;
|
2010-09-09 18:45:18 +02:00
|
|
|
|
|
|
|
buildInputs =
|
2011-03-29 17:19:59 +02:00
|
|
|
[ which zlib pkgconfig SDL openssl libuuid gettext ncurses
|
2014-12-22 00:03:08 +01:00
|
|
|
dev86 iasl pciutils bzip2 xz texinfo perl yajl
|
2011-03-29 17:19:59 +02:00
|
|
|
pythonPackages.python pythonPackages.wrapPython
|
2015-09-15 11:26:18 +02:00
|
|
|
glib bridge-utils pixman iproute udev bison xorg.libX11
|
2014-12-22 00:03:08 +01:00
|
|
|
flex ocaml ocamlPackages.findlib figlet libaio
|
|
|
|
checkpolicy pythonPackages.markdown transfig
|
2015-07-02 16:33:01 +02:00
|
|
|
glusterfs acl cmake spice spice_protocol usbredir
|
2015-01-29 09:58:28 +01:00
|
|
|
alsaLib quilt
|
2010-09-09 18:45:18 +02:00
|
|
|
];
|
|
|
|
|
2011-03-28 20:12:32 +02:00
|
|
|
pythonPath = [ pythonPackages.curses ];
|
|
|
|
|
2015-07-02 16:33:01 +02:00
|
|
|
patches = stdenv.lib.optionals ((xenserverPatched == false) && (builtins.hasAttr "xenPatches" xenConfig)) xenConfig.xenPatches;
|
2015-08-31 12:04:33 +02:00
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
${stdenv.lib.optionalString ((xenserverPatched == true) && (builtins.hasAttr "xenserverPatches" xenConfig)) xenConfig.xenserverPatches}
|
|
|
|
|
|
|
|
# Xen's tools and firmares need various git repositories that it
|
|
|
|
# usually checks out at time using git. We can't have that.
|
|
|
|
${flip concatMapStrings xenConfig.toolsGits (x: let src = fetchgit x.git; in ''
|
|
|
|
cp -r ${src} tools/${src.name}-dir-remote
|
|
|
|
chmod -R +w tools/${src.name}-dir-remote
|
|
|
|
'' + stdenv.lib.optionalString (builtins.hasAttr "patches" x) ''
|
|
|
|
( cd tools/${src.name}-dir-remote; ${concatStringsSep "; " (map (p: "patch -p1 < ${p}") x.patches)} )
|
|
|
|
'')}
|
|
|
|
${flip concatMapStrings xenConfig.firmwareGits (x: let src = fetchgit x.git; in ''
|
|
|
|
cp -r ${src} tools/firmware/${src.name}-dir-remote
|
|
|
|
chmod -R +w tools/firmware/${src.name}-dir-remote
|
|
|
|
'' + stdenv.lib.optionalString (builtins.hasAttr "patches" x) ''
|
|
|
|
( cd tools/firmware/${src.name}-dir-remote; ${concatStringsSep "; " (map (p: "patch -p1 < ${p}") x.patches)} )
|
|
|
|
'')}
|
|
|
|
|
|
|
|
# Xen's stubdoms and firmwares need various sources that are usually fetched
|
|
|
|
# at build time using wget. We can't have that, so we prefetch Xen's ext_files.
|
|
|
|
mkdir xen_ext_files
|
|
|
|
${flip concatMapStrings xenExtfiles (x: let src = fetchurl x; in ''
|
|
|
|
cp ${src} xen_ext_files/${src.name}
|
|
|
|
'')}
|
|
|
|
'';
|
2014-12-22 00:03:08 +01:00
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
# Fake wget: copy prefetched downloads instead
|
|
|
|
mkdir wget
|
|
|
|
echo "#!/bin/sh" > wget/wget
|
|
|
|
echo "echo ===== Not fetching \$*, copy pre-fetched file instead" >> wget/wget
|
|
|
|
echo "cp \$4 \$3" >> wget/wget
|
|
|
|
chmod +x wget/wget
|
|
|
|
export PATH=$PATH:$PWD/wget
|
2015-07-02 16:33:01 +02:00
|
|
|
export EXTRA_QEMUU_CONFIGURE_ARGS="--enable-spice --enable-usb-redir --enable-linux-aio"
|
2014-12-22 00:03:08 +01:00
|
|
|
'';
|
|
|
|
|
2016-03-09 14:51:19 +01:00
|
|
|
# https://github.com/NixOS/nixpkgs/issues/13590
|
|
|
|
configureFlags = ["--disable-stubdom"];
|
|
|
|
|
2015-08-31 12:04:33 +02:00
|
|
|
postConfigure =
|
2010-09-14 15:50:32 +02:00
|
|
|
''
|
|
|
|
substituteInPlace tools/libfsimage/common/fsimage_plugin.c \
|
|
|
|
--replace /usr $out
|
|
|
|
|
|
|
|
substituteInPlace tools/blktap2/lvm/lvm-util.c \
|
|
|
|
--replace /usr/sbin/vgs ${lvm2}/sbin/vgs \
|
|
|
|
--replace /usr/sbin/lvs ${lvm2}/sbin/lvs
|
|
|
|
|
|
|
|
substituteInPlace tools/hotplug/Linux/network-bridge \
|
|
|
|
--replace /usr/bin/logger ${utillinux}/bin/logger
|
|
|
|
|
|
|
|
substituteInPlace tools/xenmon/xenmon.py \
|
|
|
|
--replace /usr/bin/pkill ${procps}/bin/pkill
|
|
|
|
|
|
|
|
substituteInPlace tools/xenstat/Makefile \
|
2015-10-05 20:32:54 +02:00
|
|
|
--replace /usr/include/curses.h ${ncurses.dev}/include/curses.h
|
2010-09-14 15:50:32 +02:00
|
|
|
|
2015-08-31 12:04:33 +02:00
|
|
|
substituteInPlace tools/qemu-xen-traditional/xen-hooks.mak \
|
|
|
|
--replace /usr/include/pci ${pciutils}/include/pci
|
|
|
|
|
|
|
|
substituteInPlace tools/qemu-xen-traditional-dir-remote/xen-hooks.mak \
|
2012-08-08 00:33:06 +02:00
|
|
|
--replace /usr/include/pci ${pciutils}/include/pci
|
|
|
|
|
2015-01-29 09:58:28 +01:00
|
|
|
substituteInPlace tools/hotplug/Linux/xen-backend.rules \
|
|
|
|
--replace /etc/xen/scripts $out/etc/xen/scripts
|
|
|
|
|
|
|
|
# blktap is not provided by xen, but by xapi
|
|
|
|
sed -i '/blktap/d' tools/hotplug/Linux/xen-backend.rules
|
|
|
|
|
2010-09-14 15:50:32 +02:00
|
|
|
# Work around a bug in our GCC wrapper: `gcc -MF foo -v' doesn't
|
|
|
|
# print the GCC version number properly.
|
|
|
|
substituteInPlace xen/Makefile \
|
|
|
|
--replace '$(CC) $(CFLAGS) -v' '$(CC) -v'
|
2010-09-16 17:21:28 +02:00
|
|
|
|
2010-10-06 18:04:04 +02:00
|
|
|
# Allow the location of the xendomains config file to be
|
|
|
|
# overriden at runtime.
|
|
|
|
substituteInPlace tools/hotplug/Linux/init.d/xendomains \
|
|
|
|
--replace 'XENDOM_CONFIG=/etc/sysconfig/xendomains' "" \
|
2015-01-29 09:58:28 +01:00
|
|
|
--replace 'XENDOM_CONFIG=/etc/default/xendomains' "" \
|
|
|
|
--replace /etc/xen/scripts/hotplugpath.sh $out/etc/xen/scripts/hotplugpath.sh \
|
2010-10-06 18:04:04 +02:00
|
|
|
--replace /bin/ls ls
|
|
|
|
|
2015-07-15 12:19:38 +02:00
|
|
|
substituteInPlace tools/hotplug/Linux/xendomains \
|
|
|
|
--replace /bin/ls ls
|
|
|
|
|
2010-12-22 20:38:26 +01:00
|
|
|
# Hack to get `gcc -m32' to work without having 32-bit Glibc headers.
|
|
|
|
mkdir -p tools/include/gnu
|
|
|
|
touch tools/include/gnu/stubs-32.h
|
2010-09-14 15:50:32 +02:00
|
|
|
'';
|
|
|
|
|
2015-08-31 12:04:33 +02:00
|
|
|
# TODO: Flask needs more testing before enabling it by default.
|
|
|
|
#makeFlags = "XSM_ENABLE=y FLASK_ENABLE=y PREFIX=$(out) CONFIG_DIR=/etc XEN_EXTFILES_URL=\\$(XEN_ROOT)/xen_ext_files ";
|
|
|
|
makeFlags = "PREFIX=$(out) CONFIG_DIR=/etc XEN_EXTFILES_URL=\\$(XEN_ROOT)/xen_ext_files ";
|
|
|
|
|
2016-03-09 14:51:19 +01:00
|
|
|
buildFlags = "xen tools";
|
2015-08-31 12:04:33 +02:00
|
|
|
|
2010-10-06 13:04:07 +02:00
|
|
|
postBuild =
|
|
|
|
''
|
|
|
|
make -C docs man-pages
|
2015-07-02 16:33:01 +02:00
|
|
|
|
|
|
|
(cd tools/xen-libhvm-dir-remote; make)
|
|
|
|
(cd tools/xen-libhvm-dir-remote/biospt; cc -Wall -g -D_LINUX -Wstrict-prototypes biospt.c -o biospt -I../libhvm -L../libhvm -lxenhvm)
|
2010-10-06 13:04:07 +02:00
|
|
|
'';
|
|
|
|
|
2010-09-09 18:45:18 +02:00
|
|
|
installPhase =
|
|
|
|
''
|
2015-01-29 09:58:28 +01:00
|
|
|
mkdir -p $out $out/share
|
2011-07-02 21:21:28 +02:00
|
|
|
cp -prvd dist/install/nix/store/*/* $out/
|
2010-09-09 18:45:18 +02:00
|
|
|
cp -prvd dist/install/boot $out/boot
|
2015-01-29 09:58:28 +01:00
|
|
|
cp -prvd dist/install/etc $out
|
2010-10-06 13:04:07 +02:00
|
|
|
cp -dR docs/man1 docs/man5 $out/share/man/
|
2011-03-28 20:12:32 +02:00
|
|
|
wrapPythonPrograms
|
2015-01-29 09:58:28 +01:00
|
|
|
substituteInPlace $out/etc/xen/scripts/hotplugpath.sh --replace SBINDIR=\"$out/sbin\" SBINDIR=\"$out/bin\"
|
|
|
|
|
|
|
|
shopt -s extglob
|
|
|
|
for i in $out/etc/xen/scripts/!(*.sh); do
|
2015-07-02 16:33:01 +02:00
|
|
|
sed -i "2s@^@export PATH=$out/bin:${scriptEnvPath}\n@" $i
|
2015-01-29 09:58:28 +01:00
|
|
|
done
|
2015-07-02 16:33:01 +02:00
|
|
|
|
|
|
|
(cd tools/xen-libhvm-dir-remote; make install)
|
|
|
|
cp tools/xen-libhvm-dir-remote/biospt/biospt $out/bin/.
|
2015-01-29 09:58:28 +01:00
|
|
|
'';
|
2010-09-10 12:53:17 +02:00
|
|
|
|
2008-10-04 17:24:08 +02:00
|
|
|
meta = {
|
2010-09-09 18:45:18 +02:00
|
|
|
homepage = http://www.xen.org/;
|
|
|
|
description = "Xen hypervisor and management tools for Dom0";
|
2015-02-27 08:13:05 +01:00
|
|
|
platforms = [ "x86_64-linux" ];
|
2014-12-22 00:03:08 +01:00
|
|
|
maintainers = with stdenv.lib.maintainers; [ eelco tstrobel ];
|
2008-10-04 17:24:08 +02:00
|
|
|
};
|
|
|
|
}
|