xen: rewrite build expression to be more modular, support upstream qemu and seabios

Also:

* provides a bunch of build options
* documents build options config in longDescription
* provides a bunch of predefined packages and documents them some more
* sources' hashes stay the same

+513 -284
+16
pkgs/applications/virtualization/xen/0000-fix-install-python.patch
··· 1 + tools/python/install-wrap script brakes shebangs patching, disable 2 + 3 + diff --git a/tools/Rules.mk b/tools/Rules.mk 4 + index 87a56dc..a7da869 100644 5 + --- a/tools/Rules.mk 6 + +++ b/tools/Rules.mk 7 + @@ -90,8 +90,7 @@ CFLAGS += $(CFLAGS-y) 8 + 9 + CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS) 10 + 11 + -INSTALL_PYTHON_PROG = \ 12 + - $(XEN_ROOT)/tools/python/install-wrap "$(PYTHON_PATH)" $(INSTALL_PROG) 13 + +INSTALL_PYTHON_PROG = $(INSTALL_PROG) 14 + 15 + %.opic: %.c 16 + $(CC) $(CPPFLAGS) -DPIC $(CFLAGS) $(CFLAGS_$*.opic) -fPIC -c -o $@ $< $(APPEND_CFLAGS)
+27
pkgs/applications/virtualization/xen/0000-fix-ipxe-src.patch
··· 1 + hack to make etherboot use prefetched ipxe 2 + 3 + diff --git a/tools/firmware/etherboot/Makefile b/tools/firmware/etherboot/Makefile 4 + index a0578d2..64428a0 100644 5 + --- a/tools/firmware/etherboot/Makefile 6 + +++ b/tools/firmware/etherboot/Makefile 7 + @@ -16,6 +16,7 @@ IPXE_TARBALL_URL ?= $(XEN_EXTFILES_URL)/ipxe-git-$(IPXE_GIT_TAG).tar.gz 8 + 9 + D=ipxe 10 + T=ipxe.tar.gz 11 + +G=ipxe.git 12 + 13 + ROMS = $(addprefix $D/src/bin/, $(addsuffix .rom, $(ETHERBOOT_NICS))) 14 + 15 + @@ -36,9 +37,9 @@ $T: 16 + fi 17 + mv _$T $T 18 + 19 + -$D/src/arch/i386/Makefile: $T Config 20 + - rm -rf $D 21 + - gzip -dc $T | tar xf - 22 + +$D/src/arch/i386/Makefile: $G Config 23 + + mkdir $D 24 + + cp -a $G/* $D 25 + for i in $$(cat patches/series) ; do \ 26 + patch -d $D -p1 --quiet <patches/$$i || exit 1 ; \ 27 + done
+227 -142
pkgs/applications/virtualization/xen/4.5.nix
··· 1 - { callPackage, fetchurl, fetchpatch, fetchgit, ... } @ args: 1 + { stdenv, callPackage, fetchurl, fetchpatch, fetchgit 2 + , withInternalQemu ? true 3 + , withInternalTraditionalQemu ? true 4 + , withInternalSeabios ? true 5 + , withSeabios ? !withInternalSeabios, seabios ? null 6 + , withInternalOVMF ? false # FIXME: tricky to build 7 + , withOVMF ? false, OVMF 8 + , withLibHVM ? true 9 + 10 + # qemu 11 + , udev, pciutils, xorg, SDL, pixman, acl, glusterfs, spice_protocol, usbredir 12 + , alsaLib 13 + , ... } @ args: 14 + 15 + assert withInternalSeabios -> !withSeabios; 16 + assert withInternalOVMF -> !withOVMF; 17 + 18 + with stdenv.lib; 19 + 20 + # Patching XEN? Check the XSAs at 21 + # https://xenbits.xen.org/xsa/ 22 + # and try applying all the ones we don't have yet. 2 23 3 24 let 4 - # Xen 4.5.5 5 - # 6 - # Patching XEN? Check the XSAs and try applying all the ones we 7 - # don't have yet. 8 - # 9 - # XSAs at: https://xenbits.xen.org/xsa/ 10 - xenConfig = rec { 11 - version = "4.5.5"; 25 + xsaPatch = { name , sha256 }: (fetchpatch { 26 + url = "https://xenbits.xen.org/xsa/xsa${name}.patch"; 27 + inherit sha256; 28 + }); 29 + 30 + qemuDeps = [ 31 + udev pciutils xorg.libX11 SDL pixman acl glusterfs spice_protocol usbredir 32 + alsaLib 33 + ]; 34 + in 12 35 13 - xsaPatch = { name , sha256 }: (fetchpatch { 14 - url = "https://xenbits.xen.org/xsa/xsa${name}.patch"; 15 - inherit sha256; 16 - }); 36 + callPackage (import ./generic.nix (rec { 37 + version = "4.5.5"; 17 38 18 - name = "xen-${version}"; 39 + src = fetchurl { 40 + url = "http://bits.xensource.com/oss-xen/release/${version}/xen-${version}.tar.gz"; 41 + sha256 = "1y74ms4yc3znf8jc3fgyq94va2y0pf7jh8m9pfqnpgklywqnw8g2"; 42 + }; 19 43 20 - src = fetchurl { 21 - url = "http://bits.xensource.com/oss-xen/release/${version}/${name}.tar.gz"; 22 - sha256 = "1y74ms4yc3znf8jc3fgyq94va2y0pf7jh8m9pfqnpgklywqnw8g2"; 44 + # Sources needed to build tools and firmwares. 45 + xenfiles = optionalAttrs withInternalQemu { 46 + "qemu-xen" = { 47 + src = fetchgit { 48 + url = https://xenbits.xen.org/git-http/qemu-xen.git; 49 + rev = "refs/tags/qemu-xen-${version}"; 50 + sha256 = "014s755slmsc7xzy7qhk9i3kbjr2grxb5yznjp71dl6xxfvnday2"; 51 + }; 52 + buildInputs = qemuDeps; 53 + patches = [ 54 + (xsaPatch { 55 + name = "197-4.5-qemuu"; 56 + sha256 = "09gp980qdlfpfmxy0nk7ncyaa024jnrpzx9gpq2kah21xygy5myx"; 57 + }) 58 + (xsaPatch { 59 + name = "208-qemuu-4.7"; 60 + sha256 = "0z9b1whr8rp2riwq7wndzcnd7vw1ckwx0vbk098k2pcflrzppgrb"; 61 + }) 62 + (xsaPatch { 63 + name = "209-qemuu/0001-display-cirrus-ignore-source-pitch-value-as-needed-i"; 64 + sha256 = "1xvxzsrsq05fj6szjlpbgg4ia3cw54dn5g7xzq1n1dymbhv606m0"; 65 + }) 66 + (xsaPatch { 67 + name = "209-qemuu/0002-cirrus-add-blit_is_unsafe-call-to-cirrus_bitblt_cput"; 68 + sha256 = "0avxqs9922qjfsxxlk7bh10432a526j2yyykhags8dk1bzxkpxwv"; 69 + }) 70 + ]; 71 + meta.description = "Xen's fork of upstream Qemu"; 72 + }; 73 + } // optionalAttrs withInternalTraditionalQemu { 74 + "qemu-xen-traditional" = { 75 + src = fetchgit { 76 + url = https://xenbits.xen.org/git-http/qemu-xen-traditional.git; 77 + rev = "refs/tags/xen-${version}"; 78 + sha256 = "0n0ycxlf1wgdjkdl8l2w1i0zzssk55dfv67x8i6b2ima01r0k93r"; 79 + }; 80 + buildInputs = qemuDeps; 81 + patches = [ 82 + (xsaPatch { 83 + name = "197-4.5-qemut"; 84 + sha256 = "17l7npw00gyhqzzaqamwm9cawfvzm90zh6jjyy95dmqbh7smvy79"; 85 + }) 86 + (xsaPatch { 87 + name = "199-trad"; 88 + sha256 = "0dfw6ciycw9a9s97sbnilnzhipnzmdm9f7xcfngdjfic8cqdcv42"; 89 + }) 90 + (xsaPatch { 91 + name = "208-qemut"; 92 + sha256 = "0960vhchixp60j9h2lawgbgzf6mpcdk440kblk25a37bd6172l54"; 93 + }) 94 + (xsaPatch { 95 + name = "209-qemut"; 96 + sha256 = "1hq8ghfzw6c47pb5vf9ngxwgs8slhbbw6cq7gk0nam44rwvz743r"; 97 + }) 98 + ]; 99 + postPatch = '' 100 + substituteInPlace xen-hooks.mak \ 101 + --replace /usr/include/pci ${pciutils}/include/pci 102 + ''; 103 + meta.description = "Xen's fork of upstream Qemu that uses old device model"; 23 104 }; 105 + } // optionalAttrs withInternalSeabios { 106 + "firmware/seabios-dir-remote" = { 107 + src = fetchgit { 108 + url = https://xenbits.xen.org/git-http/seabios.git; 109 + rev = "e51488c5f8800a52ac5c8da7a31b85cca5cc95d2"; 110 + #rev = "rel-1.7.5"; 111 + sha256 = "0jk54ybhmw97pzyhpm6jr2x99f702kbn0ipxv5qxcbynflgdazyb"; 112 + }; 113 + patches = [ ./0000-qemu-seabios-enable-ATA_DMA.patch ]; 114 + meta.description = "Xen's fork of Seabios"; 115 + }; 116 + } // optionalAttrs withInternalOVMF { 117 + "firmware/ovmf-dir-remote" = { 118 + src = fetchgit { 119 + url = https://xenbits.xen.org/git-http/ovmf.git; 120 + rev = "cb9a7ebabcd6b8a49dc0854b2f9592d732b5afbd"; 121 + sha256 = "07zmdj90zjrzip74fvd4ss8n8njk6cim85s58mc6snxmqqv7gmcq"; 122 + }; 123 + meta.description = "Xen's fork of OVMF"; 124 + }; 125 + } // { 126 + # TODO: patch Xen to make this optional? 127 + "firmware/etherboot/ipxe.git" = { 128 + src = fetchgit { 129 + url = https://git.ipxe.org/ipxe.git; 130 + rev = "9a93db3f0947484e30e753bbd61a10b17336e20e"; 131 + sha256 = "1ga3h1b34q0cl9azj7j9nswn7mfcs3cgfjdihrm5zkp2xw2hpvr6"; 132 + }; 133 + meta.description = "Xen's fork of iPXE"; 134 + }; 135 + } // optionalAttrs withLibHVM { 136 + "xen-libhvm-dir-remote" = { 137 + src = fetchgit { 138 + name = "xen-libhvm"; 139 + url = https://github.com/ts468/xen-libhvm; 140 + rev = "442dcc4f6f4e374a51e4613532468bd6b48bdf63"; 141 + sha256 = "9ba97c39a00a54c154785716aa06691d312c99be498ebbc00dc3769968178ba8"; 142 + }; 143 + buildPhase = '' 144 + make 145 + cd biospt 146 + cc -Wall -g -D_LINUX -Wstrict-prototypes biospt.c -o biospt -I../libhvm -L../libhvm -lxenhvm 147 + ''; 148 + installPhase = '' 149 + make install 150 + cp biospt/biospt $out/bin/ 151 + ''; 152 + meta = { 153 + description = '' 154 + Helper library for reading ACPI and SMBIOS firmware values 155 + from the host system for use with the HVM guest firmware 156 + pass-through feature in Xen''; 157 + license = licenses.bsd2; 158 + }; 159 + }; 160 + }; 24 161 25 - # Sources needed to build the xen tools and tools/firmware. 26 - firmwareGits = 27 - [ 28 - { git = { name = "seabios"; 29 - url = https://xenbits.xen.org/git-http/seabios.git; 30 - rev = "rel-1.7.5"; 31 - sha256 = "0jk54ybhmw97pzyhpm6jr2x99f702kbn0ipxv5qxcbynflgdazyb"; 32 - }; 33 - patches = [ ./0000-qemu-seabios-enable-ATA_DMA.patch ]; 34 - } 35 - ]; 162 + configureFlags = [] 163 + ++ optional (!withInternalQemu) "--with-system-qemu" # use qemu from PATH 164 + ++ optional (withInternalTraditionalQemu) "--enable-qemu-traditional" 165 + ++ optional (!withInternalTraditionalQemu) "--disable-qemu-traditional" 166 + 167 + ++ optional (withSeabios) "--with-system-seabios=${seabios}" 168 + ++ optional (!withInternalSeabios && !withSeabios) "--disable-seabios" 169 + 170 + ++ optional (withOVMF) "--with-system-ovmf=${OVMF}" 171 + ++ optional (withInternalOVMF) "--enable-ovmf"; 172 + 173 + patches = 174 + [ ./0001-libxl-Spice-image-compression-setting-support-for-up.patch 175 + ./0002-libxl-Spice-streaming-video-setting-support-for-upst.patch 176 + ./0003-Add-qxl-vga-interface-support-for-upstream-qem.patch 177 + (xsaPatch { 178 + name = "190-4.5"; 179 + sha256 = "0f8pw38kkxky89ny3ic5h26v9zsjj9id89lygx896zc3w1klafqm"; 180 + }) 181 + (xsaPatch { 182 + name = "191-4.6"; 183 + sha256 = "1wl1ndli8rflmc44pkp8cw4642gi8z7j7gipac8mmlavmn3wdqhg"; 184 + }) 185 + (xsaPatch { 186 + name = "192-4.5"; 187 + sha256 = "0m8cv0xqvx5pdk7fcmaw2vv43xhl62plyx33xqj48y66x5z9lxpm"; 188 + }) 189 + (xsaPatch { 190 + name = "193-4.5"; 191 + sha256 = "0k9mykhrpm4rbjkhv067f6s05lqmgnldcyb3vi8cl0ndlyh66lvr"; 192 + }) 193 + (xsaPatch { 194 + name = "195"; 195 + sha256 = "0m0g953qnjy2knd9qnkdagpvkkgjbk3ydgajia6kzs499dyqpdl7"; 196 + }) 197 + (xsaPatch { 198 + name = "196-0001-x86-emul-Correct-the-IDT-entry-calculation-in-inject"; 199 + sha256 = "0z53nzrjvc745y26z1qc8jlg3blxp7brawvji1hx3s74n346ssl6"; 200 + }) 201 + (xsaPatch { 202 + name = "196-0002-x86-svm-Fix-injection-of-software-interrupts"; 203 + sha256 = "11cqvr5jn2s92wsshpilx9qnfczrd9hnyb5aim6qwmz3fq3hrrkz"; 204 + }) 205 + (xsaPatch { 206 + name = "198"; 207 + sha256 = "0d1nndn4p520c9xa87ixnyks3mrvzcri7c702d6mm22m8ansx6d9"; 208 + }) 209 + (xsaPatch { 210 + name = "200-4.6"; 211 + sha256 = "0k918ja83470iz5k4vqi15293zjvz2dipdhgc9sy9rrhg4mqncl7"; 212 + }) 213 + (xsaPatch { 214 + name = "202-4.6"; 215 + sha256 = "0nnznkrvfbbc8z64dr9wvbdijd4qbpc0wz2j5vpmx6b32sm7932f"; 216 + }) 217 + (xsaPatch { 218 + name = "204-4.5"; 219 + sha256 = "083z9pbdz3f532fnzg7n2d5wzv6rmqc0f4mvc3mnmkd0rzqw8vcp"; 220 + }) 221 + (xsaPatch { 222 + name = "207"; 223 + sha256 = "0wdlhijmw9mdj6a82pyw1rwwiz605dwzjc392zr3fpb2jklrvibc"; 224 + }) 225 + ]; 36 226 37 - toolsGits = 38 - [ 39 - { git = { name = "qemu-xen"; 40 - url = https://xenbits.xen.org/git-http/qemu-xen.git; 41 - rev = "refs/tags/qemu-xen-${version}"; 42 - sha256 = "014s755slmsc7xzy7qhk9i3kbjr2grxb5yznjp71dl6xxfvnday2"; 43 - }; 44 - patches = [ 45 - (xsaPatch { 46 - name = "197-4.5-qemuu"; 47 - sha256 = "09gp980qdlfpfmxy0nk7ncyaa024jnrpzx9gpq2kah21xygy5myx"; 48 - }) 49 - (xsaPatch { 50 - name = "208-qemuu-4.7"; 51 - sha256 = "0z9b1whr8rp2riwq7wndzcnd7vw1ckwx0vbk098k2pcflrzppgrb"; 52 - }) 53 - (xsaPatch { 54 - name = "209-qemuu"; 55 - sha256 = "05df4165by6pzxrnizkw86n2f77k9i1g4fqqpws81ycb9ng4jzin"; 56 - }) 57 - ]; 58 - } 59 - { git = { name = "qemu-xen-traditional"; 60 - url = https://xenbits.xen.org/git-http/qemu-xen-traditional.git; 61 - # rev = "28c21388c2a32259cff37fc578684f994dca8c9f"; 62 - rev = "refs/tags/xen-${version}"; 63 - sha256 = "0n0ycxlf1wgdjkdl8l2w1i0zzssk55dfv67x8i6b2ima01r0k93r"; 64 - }; 65 - patches = [ 66 - (xsaPatch { 67 - name = "197-4.5-qemut"; 68 - sha256 = "17l7npw00gyhqzzaqamwm9cawfvzm90zh6jjyy95dmqbh7smvy79"; 69 - }) 70 - (xsaPatch { 71 - name = "199-trad"; 72 - sha256 = "0dfw6ciycw9a9s97sbnilnzhipnzmdm9f7xcfngdjfic8cqdcv42"; 73 - }) 74 - (xsaPatch { 75 - name = "208-qemut"; 76 - sha256 = "0960vhchixp60j9h2lawgbgzf6mpcdk440kblk25a37bd6172l54"; 77 - }) 78 - (xsaPatch { 79 - name = "209-qemut"; 80 - sha256 = "1hq8ghfzw6c47pb5vf9ngxwgs8slhbbw6cq7gk0nam44rwvz743r"; 81 - }) 82 - ]; 83 - } 84 - { git = { name = "xen-libhvm"; 85 - url = https://github.com/ts468/xen-libhvm; 86 - rev = "442dcc4f6f4e374a51e4613532468bd6b48bdf63"; 87 - sha256 = "9ba97c39a00a54c154785716aa06691d312c99be498ebbc00dc3769968178ba8"; 88 - }; 89 - description = '' 90 - Helper library for reading ACPI and SMBIOS firmware values 91 - from the host system for use with the HVM guest firmware 92 - pass-through feature in Xen. 93 - ''; 94 - #license = licenses.bsd2; 95 - } 96 - ]; 227 + # Fix build on Glibc 2.24. 228 + NIX_CFLAGS_COMPILE = "-Wno-error=deprecated-declarations"; 97 229 98 - xenPatches = [ ./0001-libxl-Spice-image-compression-setting-support-for-up.patch 99 - ./0002-libxl-Spice-streaming-video-setting-support-for-upst.patch 100 - ./0003-Add-qxl-vga-interface-support-for-upstream-qem.patch 101 - (xsaPatch { 102 - name = "190-4.5"; 103 - sha256 = "0f8pw38kkxky89ny3ic5h26v9zsjj9id89lygx896zc3w1klafqm"; 104 - }) 105 - (xsaPatch { 106 - name = "191-4.6"; 107 - sha256 = "1wl1ndli8rflmc44pkp8cw4642gi8z7j7gipac8mmlavmn3wdqhg"; 108 - }) 109 - (xsaPatch { 110 - name = "192-4.5"; 111 - sha256 = "0m8cv0xqvx5pdk7fcmaw2vv43xhl62plyx33xqj48y66x5z9lxpm"; 112 - }) 113 - (xsaPatch { 114 - name = "193-4.5"; 115 - sha256 = "0k9mykhrpm4rbjkhv067f6s05lqmgnldcyb3vi8cl0ndlyh66lvr"; 116 - }) 117 - (xsaPatch { 118 - name = "195"; 119 - sha256 = "0m0g953qnjy2knd9qnkdagpvkkgjbk3ydgajia6kzs499dyqpdl7"; 120 - }) 121 - (xsaPatch { 122 - name = "196-0001-x86-emul-Correct-the-IDT-entry-calculation-in-inject"; 123 - sha256 = "0z53nzrjvc745y26z1qc8jlg3blxp7brawvji1hx3s74n346ssl6"; 124 - }) 125 - (xsaPatch { 126 - name = "196-0002-x86-svm-Fix-injection-of-software-interrupts"; 127 - sha256 = "11cqvr5jn2s92wsshpilx9qnfczrd9hnyb5aim6qwmz3fq3hrrkz"; 128 - }) 129 - (xsaPatch { 130 - name = "198"; 131 - sha256 = "0d1nndn4p520c9xa87ixnyks3mrvzcri7c702d6mm22m8ansx6d9"; 132 - }) 133 - (xsaPatch { 134 - name = "200-4.6"; 135 - sha256 = "0k918ja83470iz5k4vqi15293zjvz2dipdhgc9sy9rrhg4mqncl7"; 136 - }) 137 - (xsaPatch { 138 - name = "202-4.6"; 139 - sha256 = "0nnznkrvfbbc8z64dr9wvbdijd4qbpc0wz2j5vpmx6b32sm7932f"; 140 - }) 141 - (xsaPatch { 142 - name = "204-4.5"; 143 - sha256 = "083z9pbdz3f532fnzg7n2d5wzv6rmqc0f4mvc3mnmkd0rzqw8vcp"; 144 - }) 145 - (xsaPatch { 146 - name = "207"; 147 - sha256 = "0wdlhijmw9mdj6a82pyw1rwwiz605dwzjc392zr3fpb2jklrvibc"; 148 - }) 149 - ]; 150 - }; 230 + postPatch = '' 231 + # Avoid a glibc >= 2.25 deprecation warnings that get fatal via -Werror. 232 + sed 1i'#include <sys/sysmacros.h>' \ 233 + -i tools/blktap2/control/tap-ctl-allocate.c \ 234 + -i tools/libxl/libxl_device.c 235 + ''; 151 236 152 - in callPackage ./generic.nix (args // { xenConfig=xenConfig; }) 237 + })) args
+169 -138
pkgs/applications/virtualization/xen/generic.nix
··· 1 - { stdenv, fetchurl, which, zlib, pkgconfig, SDL, openssl 2 - , libuuid, gettext, ncurses, dev86, iasl, pciutils, bzip2 3 - , lvm2, utillinux, procps, texinfo, perl, python2Packages 4 - , glib, bridge-utils, xorg, pixman, iproute, udev, bison 5 - , flex, cmake, ocamlPackages, figlet, libaio, yajl 6 - , checkpolicy, transfig, glusterfs, acl, fetchgit, xz, spice 7 - , spice_protocol, usbredir, alsaLib, quilt 1 + config: 2 + { stdenv, cmake, pkgconfig, which 3 + 4 + # Xen 5 + , bison, bzip2, checkpolicy, dev86, figlet, flex, gettext, glib 6 + , iasl, libaio, libiconv, libuuid, ncurses, openssl, perl 7 + , python2Packages 8 + # python2Packages.python 9 + , xz, yajl, zlib 10 + 11 + # Xen Optional 12 + , ocamlPackages 13 + 14 + # Scripts 8 15 , coreutils, gawk, gnused, gnugrep, diffutils, multipath-tools 9 - , inetutils, iptables, openvswitch, nbd, drbd, xenConfig 10 - , xenserverPatched ? false, ... }: 16 + , iproute, inetutils, iptables, bridge-utils, openvswitch, nbd, drbd 17 + , lvm2, utillinux, procps 18 + 19 + # Documentation 20 + # python2Packages.markdown 21 + , transfig, ghostscript, texinfo, pandoc 22 + 23 + , ...} @ args: 11 24 12 25 with stdenv.lib; 13 26 14 27 let 28 + #TODO: fix paths instead 29 + scriptEnvPath = concatMapStringsSep ":" (x: "${x}/bin") [ 30 + which perl 31 + coreutils gawk gnused gnugrep diffutils utillinux multipath-tools 32 + iproute inetutils iptables bridge-utils openvswitch nbd drbd 33 + ]; 15 34 16 - libDir = if stdenv.is64bit then "lib64" else "lib"; 35 + withXenfiles = f: concatStringsSep "\n" (mapAttrsToList f config.xenfiles); 17 36 18 - # Sources needed to build the tools 19 - # These sources are already rather old and probably do not change frequently 20 - xenExtfiles = [ 21 - { url = http://xenbits.xensource.com/xen-extfiles/ipxe-git-9a93db3f0947484e30e753bbd61a10b17336e20e.tar.gz; 22 - sha256 = "0p206zaxlhda60ci33h9gipi5gm46fvvsm6k5c0w7b6cjg0yhb33"; 23 - } 24 - ]; 25 - 26 - scriptEnvPath = stdenv.lib.concatStrings (stdenv.lib.intersperse ":" (map (x: "${x}/bin") 27 - [ coreutils gawk gnused gnugrep which perl diffutils utillinux multipath-tools 28 - iproute inetutils iptables bridge-utils openvswitch nbd drbd ])); 37 + withTools = a: f: withXenfiles (name: x: optionalString (hasAttr a x) '' 38 + echo "processing ${name}" 39 + __do() { 40 + cd "tools/${name}" 41 + ${f name x} 42 + } 43 + ( __do ) 44 + ''); 29 45 in 30 46 31 - 47 + stdenv.mkDerivation (rec { 48 + inherit (config) version; 32 49 33 - stdenv.mkDerivation { 34 - inherit (xenConfig) name version src; 50 + name = "xen-${version}"; 35 51 36 52 dontUseCmakeConfigure = true; 37 53 38 - buildInputs = 39 - [ which zlib pkgconfig SDL openssl libuuid gettext ncurses 40 - dev86 iasl pciutils bzip2 xz texinfo perl yajl 41 - python2Packages.python python2Packages.wrapPython 42 - glib bridge-utils pixman iproute udev bison xorg.libX11 43 - flex ocamlPackages.ocaml ocamlPackages.findlib figlet libaio 44 - checkpolicy python2Packages.markdown transfig 45 - glusterfs acl cmake spice spice_protocol usbredir 46 - alsaLib quilt 47 - ]; 48 - 49 54 hardeningDisable = [ "stackprotector" "fortify" "pic" ]; 50 55 51 - patches = stdenv.lib.optionals ((xenserverPatched == false) && (builtins.hasAttr "xenPatches" xenConfig)) xenConfig.xenPatches; 56 + buildInputs = [ 57 + cmake pkgconfig which 52 58 53 - postPatch = '' 54 - ${stdenv.lib.optionalString ((xenserverPatched == true) && (builtins.hasAttr "xenserverPatches" xenConfig)) xenConfig.xenserverPatches} 59 + # Xen 60 + bison bzip2 checkpolicy dev86 figlet flex gettext glib iasl libaio 61 + libiconv libuuid ncurses openssl perl python2Packages.python xz yajl zlib 62 + 63 + # oxenstored 64 + ocamlPackages.findlib ocamlPackages.ocaml 65 + 66 + # Python fixes 67 + python2Packages.wrapPython 68 + 69 + # Documentation 70 + python2Packages.markdown transfig ghostscript texinfo pandoc 71 + 72 + # Others 73 + ] ++ (concatMap (x: x.buildInputs or []) (attrValues config.xenfiles)) 74 + ++ (config.buildInputs or []); 75 + 76 + prePatch = '' 77 + ### Generic fixes 78 + 79 + # Xen's stubdoms, tools and firmwares need various sources that 80 + # are usually fetched at build time using wget and git. We can't 81 + # have that, so we prefetch them in nix-expression and setup 82 + # fake wget and git for debugging purposes. 83 + 84 + mkdir fake-bin 85 + 86 + # Fake git: just print what it wants and die 87 + cat > fake-bin/wget << EOF 88 + #!/bin/sh -e 89 + echo ===== FAKE WGET: Not fetching \$* 90 + [ -e \$3 ] 91 + EOF 92 + 93 + # Fake git: just print what it wants and die 94 + cat > fake-bin/git << EOF 95 + #!/bin/sh 96 + echo ===== FAKE GIT: Not cloning \$* 97 + [ -e \$3 ] 98 + EOF 55 99 56 - # Xen's tools and firmares need various git repositories that it 57 - # usually checks out at time using git. We can't have that. 58 - ${flip concatMapStrings xenConfig.toolsGits (x: let src = fetchgit x.git; in '' 59 - cp -r ${src} tools/${src.name}-dir-remote 60 - chmod -R +w tools/${src.name}-dir-remote 61 - '' + stdenv.lib.optionalString (builtins.hasAttr "patches" x) '' 62 - ( cd tools/${src.name}-dir-remote; ${concatStringsSep "; " (map (p: "patch -p1 < ${p}") x.patches)} ) 63 - '')} 64 - ${flip concatMapStrings xenConfig.firmwareGits (x: let src = fetchgit x.git; in '' 65 - cp -r ${src} tools/firmware/${src.name}-dir-remote 66 - chmod -R +w tools/firmware/${src.name}-dir-remote 67 - '' + stdenv.lib.optionalString (builtins.hasAttr "patches" x) '' 68 - ( cd tools/firmware/${src.name}-dir-remote; ${concatStringsSep "; " (map (p: "patch -p1 < ${p}") x.patches)} ) 69 - '')} 100 + chmod +x fake-bin/* 101 + export PATH=$PATH:$PWD/fake-bin 70 102 71 - # Xen's stubdoms and firmwares need various sources that are usually fetched 72 - # at build time using wget. We can't have that, so we prefetch Xen's ext_files. 73 - mkdir xen_ext_files 74 - ${flip concatMapStrings xenExtfiles (x: let src = fetchurl x; in '' 75 - cp ${src} xen_ext_files/${src.name} 76 - '')} 103 + # Remove in-tree qemu stuff in case we build from a tar-ball 104 + rm -rf tools/qemu-xen tools/qemu-xen-traditional 105 + 106 + # Fix shebangs, mainly for build-scipts 107 + # We want to do this before getting prefetched stuff to speed things up 108 + # (prefetched stuff has lots of files) 109 + find . -type f | xargs sed -i 's@/usr/bin/\(python\|perl\)@/usr/bin/env \1@g' 110 + find . -type f | xargs sed -i 's@/bin/bash@/bin/sh@g' 77 111 78 - # Avoid a glibc >= 2.25 deprecation warnings that get fatal via -Werror. 79 - sed 1i'#include <sys/sysmacros.h>' \ 80 - -i tools/blktap2/control/tap-ctl-allocate.c \ 81 - -i tools/libxl/libxl_device.c 112 + # Get prefetched stuff 113 + ${withXenfiles (name: x: '' 114 + echo "${x.src} -> tools/${name}" 115 + cp -r ${x.src} tools/${name} 116 + chmod -R +w tools/${name} 117 + '')} 82 118 ''; 83 119 84 - preConfigure = '' 85 - # Fake wget: copy prefetched downloads instead 86 - mkdir wget 87 - echo "#!/bin/sh" > wget/wget 88 - echo "echo ===== Not fetching \$*, copy pre-fetched file instead" >> wget/wget 89 - echo "cp \$4 \$3" >> wget/wget 90 - chmod +x wget/wget 91 - export PATH=$PATH:$PWD/wget 92 - export EXTRA_QEMUU_CONFIGURE_ARGS="--enable-spice --enable-usb-redir --enable-linux-aio" 93 - ''; 120 + patches = [ ./0000-fix-ipxe-src.patch 121 + ./0000-fix-install-python.patch ] 122 + ++ (config.patches or []); 94 123 95 - # https://github.com/NixOS/nixpkgs/issues/13590 96 - configureFlags = ["--disable-stubdom"]; 124 + postPatch = '' 125 + ### Hacks 97 126 98 - postConfigure = 99 - '' 100 - substituteInPlace tools/libfsimage/common/fsimage_plugin.c \ 101 - --replace /usr $out 127 + # Work around a bug in our GCC wrapper: `gcc -MF foo -v' doesn't 128 + # print the GCC version number properly. 129 + substituteInPlace xen/Makefile \ 130 + --replace '$(CC) $(CFLAGS) -v' '$(CC) -v' 102 131 103 - substituteInPlace tools/blktap2/lvm/lvm-util.c \ 104 - --replace /usr/sbin/vgs ${lvm2}/sbin/vgs \ 105 - --replace /usr/sbin/lvs ${lvm2}/sbin/lvs 132 + # Hack to get `gcc -m32' to work without having 32-bit Glibc headers. 133 + mkdir -p tools/include/gnu 134 + touch tools/include/gnu/stubs-32.h 106 135 107 - substituteInPlace tools/xenmon/xenmon.py \ 108 - --replace /usr/bin/pkill ${procps}/bin/pkill 136 + ### Fixing everything else 109 137 110 - substituteInPlace tools/xenstat/Makefile \ 111 - --replace /usr/include/curses.h ${ncurses.dev}/include/curses.h 138 + substituteInPlace tools/libfsimage/common/fsimage_plugin.c \ 139 + --replace /usr $out 112 140 113 - substituteInPlace tools/qemu-xen-traditional/xen-hooks.mak \ 114 - --replace /usr/include/pci ${pciutils}/include/pci 141 + substituteInPlace tools/blktap2/lvm/lvm-util.c \ 142 + --replace /usr/sbin/vgs ${lvm2}/bin/vgs \ 143 + --replace /usr/sbin/lvs ${lvm2}/bin/lvs 115 144 116 - substituteInPlace tools/qemu-xen-traditional-dir-remote/xen-hooks.mak \ 117 - --replace /usr/include/pci ${pciutils}/include/pci 145 + substituteInPlace tools/misc/xenpvnetboot \ 146 + --replace /usr/sbin/mount ${utillinux}/bin/mount \ 147 + --replace /usr/sbin/umount ${utillinux}/bin/umount 118 148 119 - substituteInPlace tools/hotplug/Linux/xen-backend.rules \ 120 - --replace /etc/xen/scripts $out/etc/xen/scripts 149 + substituteInPlace tools/xenmon/xenmon.py \ 150 + --replace /usr/bin/pkill ${procps}/bin/pkill 121 151 122 - # blktap is not provided by xen, but by xapi 123 - sed -i '/blktap/d' tools/hotplug/Linux/xen-backend.rules 152 + substituteInPlace tools/xenstat/Makefile \ 153 + --replace /usr/include/curses.h ${ncurses.dev}/include/curses.h 124 154 125 - # Work around a bug in our GCC wrapper: `gcc -MF foo -v' doesn't 126 - # print the GCC version number properly. 127 - substituteInPlace xen/Makefile \ 128 - --replace '$(CC) $(CFLAGS) -v' '$(CC) -v' 155 + # TODO: use this as a template and support our own if-up scripts instead? 156 + substituteInPlace tools/hotplug/Linux/xen-backend.rules.in \ 157 + --replace "@XEN_SCRIPT_DIR@" $out/etc/xen/scripts 129 158 130 - # Allow the location of the xendomains config file to be 131 - # overriden at runtime. 132 - substituteInPlace tools/hotplug/Linux/init.d/xendomains \ 133 - --replace 'XENDOM_CONFIG=/etc/sysconfig/xendomains' "" \ 134 - --replace 'XENDOM_CONFIG=/etc/default/xendomains' "" \ 135 - --replace /etc/xen/scripts/hotplugpath.sh $out/etc/xen/scripts/hotplugpath.sh \ 136 - --replace /bin/ls ls 159 + # blktap is not provided by xen, but by xapi 160 + sed -i '/blktap/d' tools/hotplug/Linux/xen-backend.rules.in 137 161 138 - substituteInPlace tools/hotplug/Linux/xendomains \ 139 - --replace /bin/ls ls 162 + ${withTools "patches" (name: x: '' 163 + ${concatMapStringsSep "\n" (p: '' 164 + echo "# Patching with ${p}" 165 + patch -p1 < ${p} 166 + '') x.patches} 167 + '')} 140 168 141 - # Hack to get `gcc -m32' to work without having 32-bit Glibc headers. 142 - mkdir -p tools/include/gnu 143 - touch tools/include/gnu/stubs-32.h 144 - ''; 169 + ${withTools "postPatch" (name: x: x.postPatch)} 145 170 146 - # Fix build on Glibc 2.24. 147 - NIX_CFLAGS_COMPILE = "-Wno-error=deprecated-declarations"; 171 + ${config.postPatch or ""} 172 + ''; 148 173 149 174 # TODO: Flask needs more testing before enabling it by default. 150 175 #makeFlags = "XSM_ENABLE=y FLASK_ENABLE=y PREFIX=$(out) CONFIG_DIR=/etc XEN_EXTFILES_URL=\\$(XEN_ROOT)/xen_ext_files "; 151 - makeFlags = "PREFIX=$(out) CONFIG_DIR=/etc XEN_EXTFILES_URL=\\$(XEN_ROOT)/xen_ext_files "; 176 + makeFlags = [ "PREFIX=$(out) CONFIG_DIR=/etc" "XEN_SCRIPT_DIR=/etc/xen/scripts" ] 177 + ++ (config.makeFlags or []); 152 178 153 179 buildFlags = "xen tools"; 154 180 155 - postBuild = 156 - '' 157 - make -C docs man-pages 181 + postBuild = '' 182 + make -C docs man-pages 158 183 159 - (cd tools/xen-libhvm-dir-remote; make) 160 - (cd tools/xen-libhvm-dir-remote/biospt; cc -Wall -g -D_LINUX -Wstrict-prototypes biospt.c -o biospt -I../libhvm -L../libhvm -lxenhvm) 161 - ''; 184 + ${withTools "buildPhase" (name: x: x.buildPhase)} 185 + ''; 162 186 163 - installPhase = 164 - '' 165 - mkdir -p $out $out/share 166 - cp -prvd dist/install/nix/store/*/* $out/ 167 - cp -prvd dist/install/boot $out/boot 168 - cp -prvd dist/install/etc $out 169 - cp -dR docs/man1 docs/man5 $out/share/man/ 170 - wrapPythonPrograms 171 - substituteInPlace $out/etc/xen/scripts/hotplugpath.sh --replace SBINDIR=\"$out/sbin\" SBINDIR=\"$out/bin\" 187 + installPhase = '' 188 + mkdir -p $out $out/share 189 + cp -prvd dist/install/nix/store/*/* $out/ 190 + cp -prvd dist/install/boot $out/boot 191 + cp -prvd dist/install/etc $out 192 + cp -dR docs/man1 docs/man5 $out/share/man/ 172 193 173 - shopt -s extglob 174 - for i in $out/etc/xen/scripts/!(*.sh); do 175 - sed -i "2s@^@export PATH=$out/bin:${scriptEnvPath}\n@" $i 176 - done 194 + ${withTools "installPhase" (name: x: x.installPhase)} 177 195 178 - (cd tools/xen-libhvm-dir-remote; make install) 179 - cp tools/xen-libhvm-dir-remote/biospt/biospt $out/bin/. 180 - ''; 196 + # Hack 197 + substituteInPlace $out/etc/xen/scripts/hotplugpath.sh \ 198 + --replace SBINDIR=\"$out/sbin\" SBINDIR=\"$out/bin\" 199 + 200 + wrapPythonPrograms 201 + 202 + shopt -s extglob 203 + for i in $out/etc/xen/scripts/!(*.sh); do 204 + sed -i "2s@^@export PATH=$out/bin:${scriptEnvPath}\n@" $i 205 + done 206 + ''; 181 207 182 208 meta = { 183 209 homepage = http://www.xen.org/; 184 - description = "Xen hypervisor and management tools for Dom0"; 210 + description = "Xen hypervisor and related components" 211 + + optionalString (args ? meta && args.meta ? description) 212 + " (${args.meta.description})"; 213 + longDescription = (args.meta.longDescription or "") 214 + + "\nIncludes:\n" 215 + + withXenfiles (name: x: ''* ${name}: ${x.meta.description or "(No description)"}.''); 185 216 platforms = [ "x86_64-linux" ]; 186 - maintainers = with stdenv.lib.maintainers; [ eelco tstrobel ]; 217 + maintainers = with stdenv.lib.maintainers; [ eelco tstrobel oxij ]; 187 218 }; 188 - } 219 + } // removeAttrs config [ "xenfiles" "buildInputs" "patches" "postPatch" "meta" ])
+64
pkgs/applications/virtualization/xen/packages.nix
··· 1 + { callPackage 2 + , stdenv, overrideCC, gcc49 3 + }: 4 + 5 + # TODO on new Xen version: generalize this to generate [vanilla slim 6 + # light] for each ./<version>.nix. 7 + 8 + rec { 9 + 10 + xen_4_5-vanilla = callPackage ./4.5.nix { 11 + # At the very least included seabios and etherboot need gcc49, 12 + # so we have to build all of it with gcc49. 13 + stdenv = overrideCC stdenv gcc49; 14 + 15 + meta = { 16 + description = "vanilla"; 17 + longDescription = '' 18 + Vanilla version of Xen. Uses forks of Qemu and Seabios bundled 19 + with Xen. This gives vanilla experince, but wastes space and 20 + build time: typical NixOS setup that runs lots of VMs will 21 + build three different versions of Qemu when using this (two 22 + forks and upstream). 23 + ''; 24 + }; 25 + }; 26 + 27 + xen_4_5-slim = xen_4_5-vanilla.override { 28 + withInternalQemu = false; 29 + withInternalTraditionalQemu = true; 30 + withInternalSeabios = false; 31 + withSeabios = true; 32 + 33 + meta = { 34 + description = "slim"; 35 + longDescription = '' 36 + Slimmed-down version of Xen that reuses nixpkgs packages as 37 + much as possible. Different parts may get out of sync, but 38 + this builds faster and uses less space than vanilla. Use with 39 + `qemu_xen` from nixpkgs. 40 + ''; 41 + }; 42 + }; 43 + 44 + xen_4_5-light = xen_4_5-vanilla.override { 45 + withInternalQemu = false; 46 + withInternalTraditionalQemu = false; 47 + withInternalSeabios = false; 48 + withSeabios = true; 49 + 50 + meta = { 51 + description = "light"; 52 + longDescription = '' 53 + Slimmed-down version of Xen without `qemu-traditional` (you 54 + don't need it if you don't know what it is). Use with 55 + `qemu_xen-light` from nixpkgs. 56 + ''; 57 + }; 58 + }; 59 + 60 + xen-vanilla = xen_4_5-vanilla; 61 + xen-slim = xen_4_5-slim; 62 + xen-light = xen_4_5-light; 63 + 64 + }
+10 -4
pkgs/top-level/all-packages.nix
··· 11892 11892 watch = callPackage ../os-specific/linux/procps/watch.nix { }; 11893 11893 11894 11894 qemu_kvm = lowPrio (qemu.override { x86Only = true; }); 11895 - qemu_xen = lowPrio (qemu.override { x86Only = true; xenSupport = true; }); 11895 + 11896 + # See `xenPackages` source for explanations. 11897 + # Building with `xen` instead of `xen-slim` is possible, but makes no sense. 11898 + qemu_xen = lowPrio (qemu.override { x86Only = true; xenSupport = true; xen = xen-slim; }); 11899 + qemu_xen-light = lowPrio (qemu.override { x86Only = true; xenSupport = true; xen = xen-light; }); 11896 11900 11897 11901 qemu_test = lowPrio (qemu.override { x86Only = true; nixosTestRunner = true; }); 11898 11902 ··· 15997 16001 15998 16002 xdotool = callPackage ../tools/X11/xdotool { }; 15999 16003 16000 - xen_4_5 = callPackage ../applications/virtualization/xen/4.5.nix { stdenv = overrideCC stdenv gcc49; }; 16001 - xen_xenServer = callPackage ../applications/virtualization/xen/4.5.nix { xenserverPatched = true; stdenv = overrideCC stdenv gcc49; }; 16002 - xen = xen_4_5; 16004 + xenPackages = recurseIntoAttrs (callPackage ../applications/virtualization/xen/packages.nix {}); 16005 + 16006 + xen = xenPackages.xen_4_5-vanilla; 16007 + xen-slim = xenPackages.xen_4_5-slim; 16008 + xen-light = xenPackages.xen_4_5-light; 16003 16009 16004 16010 win-spice = callPackage ../applications/virtualization/driver/win-spice { }; 16005 16011 win-virtio = callPackage ../applications/virtualization/driver/win-virtio { };