2016-09-01 01:51:09 +00:00
|
|
|
config:
|
2021-01-15 05:42:41 +00:00
|
|
|
{ lib, stdenv, cmake, pkg-config, which
|
2016-09-01 01:51:09 +00:00
|
|
|
|
|
|
|
# Xen
|
|
|
|
, bison, bzip2, checkpolicy, dev86, figlet, flex, gettext, glib
|
|
|
|
, iasl, libaio, libiconv, libuuid, ncurses, openssl, perl
|
|
|
|
, python2Packages
|
|
|
|
# python2Packages.python
|
|
|
|
, xz, yajl, zlib
|
|
|
|
|
|
|
|
# Xen Optional
|
|
|
|
, ocamlPackages
|
|
|
|
|
|
|
|
# Scripts
|
2016-01-21 15:07:38 +00:00
|
|
|
, coreutils, gawk, gnused, gnugrep, diffutils, multipath-tools
|
2016-09-01 01:51:09 +00:00
|
|
|
, iproute, inetutils, iptables, bridge-utils, openvswitch, nbd, drbd
|
2020-11-24 15:29:28 +00:00
|
|
|
, lvm2, util-linux, procps, systemd
|
2016-09-01 01:51:09 +00:00
|
|
|
|
|
|
|
# Documentation
|
|
|
|
# python2Packages.markdown
|
|
|
|
, transfig, ghostscript, texinfo, pandoc
|
|
|
|
|
2019-04-30 02:22:53 +00:00
|
|
|
, binutils-unwrapped
|
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
, ...} @ args:
|
2010-10-04 23:25:03 +00:00
|
|
|
|
2021-01-15 05:42:41 +00:00
|
|
|
with lib;
|
2010-10-04 23:25:03 +00:00
|
|
|
|
|
|
|
let
|
2016-09-01 01:51:09 +00:00
|
|
|
#TODO: fix paths instead
|
|
|
|
scriptEnvPath = concatMapStringsSep ":" (x: "${x}/bin") [
|
|
|
|
which perl
|
2020-11-24 15:29:28 +00:00
|
|
|
coreutils gawk gnused gnugrep diffutils util-linux multipath-tools
|
2016-09-01 01:51:09 +00:00
|
|
|
iproute inetutils iptables bridge-utils openvswitch nbd drbd
|
|
|
|
];
|
|
|
|
|
|
|
|
withXenfiles = f: concatStringsSep "\n" (mapAttrsToList f config.xenfiles);
|
|
|
|
|
|
|
|
withTools = a: f: withXenfiles (name: x: optionalString (hasAttr a x) ''
|
|
|
|
echo "processing ${name}"
|
|
|
|
__do() {
|
|
|
|
cd "tools/${name}"
|
|
|
|
${f name x}
|
|
|
|
}
|
|
|
|
( __do )
|
|
|
|
'');
|
2019-04-30 02:22:53 +00:00
|
|
|
|
|
|
|
# We don't want to use the wrapped version, because this version of ld is
|
|
|
|
# only used for linking the Xen EFI binary, and the build process really
|
|
|
|
# needs control over the LDFLAGS used
|
|
|
|
efiBinutils = binutils-unwrapped.overrideAttrs (oldAttrs: {
|
|
|
|
name = "efi-binutils";
|
|
|
|
configureFlags = oldAttrs.configureFlags ++ [
|
|
|
|
"--enable-targets=x86_64-pep"
|
|
|
|
];
|
|
|
|
doInstallCheck = false; # We get a spurious failure otherwise, due to host/target mis-match
|
|
|
|
});
|
2016-09-01 01:51:09 +00:00
|
|
|
in
|
2010-10-04 23:25:03 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
stdenv.mkDerivation (rec {
|
|
|
|
inherit (config) version;
|
2010-10-06 11:04:07 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
name = "xen-${version}";
|
2010-09-09 16:45:18 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
dontUseCmakeConfigure = true;
|
2010-09-09 16:45:18 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
hardeningDisable = [ "stackprotector" "fortify" "pic" ];
|
2010-09-09 16:45:18 +00:00
|
|
|
|
2020-12-31 07:48:55 +00:00
|
|
|
nativeBuildInputs = [ pkg-config ];
|
2016-09-01 01:51:09 +00:00
|
|
|
buildInputs = [
|
2017-09-14 19:24:37 +00:00
|
|
|
cmake which
|
2015-01-29 08:58:28 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
# Xen
|
|
|
|
bison bzip2 checkpolicy dev86 figlet flex gettext glib iasl libaio
|
|
|
|
libiconv libuuid ncurses openssl perl python2Packages.python xz yajl zlib
|
2008-10-04 15:24:08 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
# oxenstored
|
2017-05-11 10:12:47 +00:00
|
|
|
ocamlPackages.findlib ocamlPackages.ocaml systemd
|
2010-09-09 16:45:18 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
# Python fixes
|
|
|
|
python2Packages.wrapPython
|
2010-09-09 16:45:18 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
# Documentation
|
|
|
|
python2Packages.markdown transfig ghostscript texinfo pandoc
|
2015-12-23 01:59:47 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
# Others
|
|
|
|
] ++ (concatMap (x: x.buildInputs or []) (attrValues config.xenfiles))
|
|
|
|
++ (config.buildInputs or []);
|
2015-08-31 10:04:33 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
prePatch = ''
|
|
|
|
### Generic fixes
|
|
|
|
|
|
|
|
# Xen's stubdoms, tools and firmwares need various sources that
|
|
|
|
# are usually fetched at build time using wget and git. We can't
|
|
|
|
# have that, so we prefetch them in nix-expression and setup
|
|
|
|
# fake wget and git for debugging purposes.
|
|
|
|
|
|
|
|
mkdir fake-bin
|
|
|
|
|
|
|
|
# Fake git: just print what it wants and die
|
|
|
|
cat > fake-bin/wget << EOF
|
2019-01-15 22:41:31 +00:00
|
|
|
#!${stdenv.shell} -e
|
2016-09-01 01:51:09 +00:00
|
|
|
echo ===== FAKE WGET: Not fetching \$*
|
|
|
|
[ -e \$3 ]
|
|
|
|
EOF
|
2014-12-21 23:03:08 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
# Fake git: just print what it wants and die
|
|
|
|
cat > fake-bin/git << EOF
|
2019-01-15 22:41:31 +00:00
|
|
|
#!${stdenv.shell}
|
2016-09-01 01:51:09 +00:00
|
|
|
echo ===== FAKE GIT: Not cloning \$*
|
|
|
|
[ -e \$3 ]
|
|
|
|
EOF
|
|
|
|
|
|
|
|
chmod +x fake-bin/*
|
|
|
|
export PATH=$PATH:$PWD/fake-bin
|
|
|
|
|
|
|
|
# Remove in-tree qemu stuff in case we build from a tar-ball
|
|
|
|
rm -rf tools/qemu-xen tools/qemu-xen-traditional
|
|
|
|
|
|
|
|
# Fix shebangs, mainly for build-scipts
|
|
|
|
# We want to do this before getting prefetched stuff to speed things up
|
|
|
|
# (prefetched stuff has lots of files)
|
|
|
|
find . -type f | xargs sed -i 's@/usr/bin/\(python\|perl\)@/usr/bin/env \1@g'
|
2017-04-27 07:55:34 +00:00
|
|
|
find . -type f -not -path "./tools/hotplug/Linux/xendomains.in" \
|
2019-01-15 22:41:31 +00:00
|
|
|
| xargs sed -i 's@/bin/bash@${stdenv.shell}@g'
|
2016-09-01 01:51:09 +00:00
|
|
|
|
|
|
|
# Get prefetched stuff
|
|
|
|
${withXenfiles (name: x: ''
|
|
|
|
echo "${x.src} -> tools/${name}"
|
|
|
|
cp -r ${x.src} tools/${name}
|
|
|
|
chmod -R +w tools/${name}
|
|
|
|
'')}
|
2014-12-21 23:03:08 +00:00
|
|
|
'';
|
|
|
|
|
2019-04-30 02:22:53 +00:00
|
|
|
patches = [
|
|
|
|
./0000-fix-ipxe-src.patch
|
|
|
|
./0000-fix-install-python.patch
|
|
|
|
./0004-makefile-use-efi-ld.patch
|
|
|
|
./0005-makefile-fix-efi-mountdir-use.patch
|
|
|
|
] ++ (config.patches or []);
|
2016-03-09 13:51:19 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
postPatch = ''
|
|
|
|
### Hacks
|
|
|
|
|
|
|
|
# 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-14 13:50:32 +00:00
|
|
|
|
2016-09-01 01:51:09 +00: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 13:50:32 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
### Fixing everything else
|
2010-09-14 13:50:32 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
substituteInPlace tools/libfsimage/common/fsimage_plugin.c \
|
|
|
|
--replace /usr $out
|
2010-09-14 13:50:32 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
substituteInPlace tools/blktap2/lvm/lvm-util.c \
|
|
|
|
--replace /usr/sbin/vgs ${lvm2}/bin/vgs \
|
|
|
|
--replace /usr/sbin/lvs ${lvm2}/bin/lvs
|
2015-08-31 10:04:33 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
substituteInPlace tools/misc/xenpvnetboot \
|
2020-11-24 15:29:28 +00:00
|
|
|
--replace /usr/sbin/mount ${util-linux}/bin/mount \
|
|
|
|
--replace /usr/sbin/umount ${util-linux}/bin/umount
|
2012-08-07 22:33:06 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
substituteInPlace tools/xenmon/xenmon.py \
|
|
|
|
--replace /usr/bin/pkill ${procps}/bin/pkill
|
2015-01-29 08:58:28 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
substituteInPlace tools/xenstat/Makefile \
|
|
|
|
--replace /usr/include/curses.h ${ncurses.dev}/include/curses.h
|
2015-01-29 08:58:28 +00:00
|
|
|
|
2018-03-04 12:35:20 +00:00
|
|
|
${optionalString (builtins.compareVersions config.version "4.8" >= 0) ''
|
2017-05-11 10:12:47 +00:00
|
|
|
substituteInPlace tools/hotplug/Linux/launch-xenstore.in \
|
|
|
|
--replace /bin/mkdir mkdir
|
|
|
|
''}
|
2010-09-16 15:21:28 +00:00
|
|
|
|
2018-03-04 12:35:20 +00:00
|
|
|
${optionalString (builtins.compareVersions config.version "4.6" < 0) ''
|
2017-05-11 10:12:47 +00:00
|
|
|
# TODO: use this as a template and support our own if-up scripts instead?
|
|
|
|
substituteInPlace tools/hotplug/Linux/xen-backend.rules.in \
|
|
|
|
--replace "@XEN_SCRIPT_DIR@" $out/etc/xen/scripts
|
|
|
|
|
|
|
|
# blktap is not provided by xen, but by xapi
|
|
|
|
sed -i '/blktap/d' tools/hotplug/Linux/xen-backend.rules.in
|
|
|
|
''}
|
2010-10-06 16:04:04 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
${withTools "patches" (name: x: ''
|
|
|
|
${concatMapStringsSep "\n" (p: ''
|
|
|
|
echo "# Patching with ${p}"
|
|
|
|
patch -p1 < ${p}
|
|
|
|
'') x.patches}
|
|
|
|
'')}
|
2015-07-15 10:19:38 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
${withTools "postPatch" (name: x: x.postPatch)}
|
2010-09-14 13:50:32 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
${config.postPatch or ""}
|
|
|
|
'';
|
2016-08-23 17:13:30 +00:00
|
|
|
|
2017-04-27 07:55:34 +00:00
|
|
|
postConfigure = ''
|
|
|
|
substituteInPlace tools/hotplug/Linux/xendomains \
|
|
|
|
--replace /bin/ls ls
|
|
|
|
'';
|
|
|
|
|
2019-04-30 02:22:53 +00:00
|
|
|
EFI_LD = "${efiBinutils}/bin/ld";
|
|
|
|
EFI_VENDOR = "nixos";
|
|
|
|
|
2015-08-31 10:04:33 +00:00
|
|
|
# TODO: Flask needs more testing before enabling it by default.
|
2019-10-27 13:03:25 +00:00
|
|
|
#makeFlags = [ "XSM_ENABLE=y" "FLASK_ENABLE=y" "PREFIX=$(out)" "CONFIG_DIR=/etc" "XEN_EXTFILES_URL=\\$(XEN_ROOT)/xen_ext_files" ];
|
2016-09-01 01:51:09 +00:00
|
|
|
makeFlags = [ "PREFIX=$(out) CONFIG_DIR=/etc" "XEN_SCRIPT_DIR=/etc/xen/scripts" ]
|
|
|
|
++ (config.makeFlags or []);
|
2015-08-31 10:04:33 +00:00
|
|
|
|
2019-10-27 13:03:25 +00:00
|
|
|
buildFlags = [ "xen" "tools" ];
|
2015-08-31 10:04:33 +00:00
|
|
|
|
2016-09-01 01:51:09 +00:00
|
|
|
postBuild = ''
|
|
|
|
make -C docs man-pages
|
|
|
|
|
|
|
|
${withTools "buildPhase" (name: x: x.buildPhase)}
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2017-05-11 10:12:47 +00:00
|
|
|
mkdir -p $out $out/share $out/share/man
|
2016-09-01 01:51:09 +00:00
|
|
|
cp -prvd dist/install/nix/store/*/* $out/
|
|
|
|
cp -prvd dist/install/boot $out/boot
|
|
|
|
cp -prvd dist/install/etc $out
|
|
|
|
cp -dR docs/man1 docs/man5 $out/share/man/
|
|
|
|
|
|
|
|
${withTools "installPhase" (name: x: x.installPhase)}
|
|
|
|
|
|
|
|
# Hack
|
|
|
|
substituteInPlace $out/etc/xen/scripts/hotplugpath.sh \
|
|
|
|
--replace SBINDIR=\"$out/sbin\" SBINDIR=\"$out/bin\"
|
|
|
|
|
|
|
|
wrapPythonPrograms
|
2017-06-09 06:17:51 +00:00
|
|
|
# We also need to wrap pygrub, which lies in lib
|
|
|
|
wrapPythonProgramsIn "$out/lib" "$out $pythonPath"
|
2016-09-01 01:51:09 +00:00
|
|
|
|
|
|
|
shopt -s extglob
|
|
|
|
for i in $out/etc/xen/scripts/!(*.sh); do
|
|
|
|
sed -i "2s@^@export PATH=$out/bin:${scriptEnvPath}\n@" $i
|
|
|
|
done
|
|
|
|
'';
|
2010-09-10 10:53:17 +00:00
|
|
|
|
2018-06-09 07:17:14 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2018-03-10 20:16:02 +00:00
|
|
|
# TODO(@oxij): Stop referencing args here
|
2008-10-04 15:24:08 +00:00
|
|
|
meta = {
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "http://www.xen.org/";
|
2016-09-01 01:51:09 +00:00
|
|
|
description = "Xen hypervisor and related components"
|
|
|
|
+ optionalString (args ? meta && args.meta ? description)
|
|
|
|
" (${args.meta.description})";
|
|
|
|
longDescription = (args.meta.longDescription or "")
|
|
|
|
+ "\nIncludes:\n"
|
2021-01-24 09:19:10 +00:00
|
|
|
+ withXenfiles (name: x: "* ${name}: ${x.meta.description or "(No description)"}.");
|
2015-02-27 07:13:05 +00:00
|
|
|
platforms = [ "x86_64-linux" ];
|
2021-01-15 05:42:41 +00:00
|
|
|
maintainers = with lib.maintainers; [ eelco tstrobel oxij ];
|
|
|
|
license = lib.licenses.gpl2;
|
2018-03-10 20:16:02 +00:00
|
|
|
} // (config.meta or {});
|
2016-09-01 01:51:09 +00:00
|
|
|
} // removeAttrs config [ "xenfiles" "buildInputs" "patches" "postPatch" "meta" ])
|