gnu: nnn: Don't use NAME in source URI.
[jackhill/guix/guix.git] / gnu / packages / virtualization.scm
CommitLineData
b15fcf9e 1;;; GNU Guix --- Functional package management for GNU
589e3f4e 2;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
ecfe88b7 3;;; Copyright © 2015, 2016, 2017, 2018 Mark H Weaver <mhw@netris.org>
49fe965d 4;;; Copyright © 2016, 2017, 2018. 2019 Efraim Flashner <efraim@flashner.co.il>
fe420383 5;;; Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
f152208b 6;;; Copyright © 2017 Alex Vong <alexvong1995@gmail.com>
b376ec57 7;;; Copyright © 2017 Andy Patterson <ajpatter@uwaterloo.ca>
27b52c1f 8;;; Copyright © 2017, 2018 Rutger Helling <rhelling@mykolab.com>
969bbf8b 9;;; Copyright © 2017, 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
0def9120 10;;; Copyright © 2018 Danny Milosavljevic <dannym@scratchpost.org>
de7f03ce 11;;; Copyright © 2018 Sou Bunnbu <iyzsong@member.fsf.org>
f6e55da0 12;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
17043677 13;;; Copyright © 2019 Guy Fleury Iteriteka <hoonandon@gmail.com>
b15fcf9e
LC
14;;;
15;;; This file is part of GNU Guix.
16;;;
17;;; GNU Guix is free software; you can redistribute it and/or modify it
18;;; under the terms of the GNU General Public License as published by
19;;; the Free Software Foundation; either version 3 of the License, or (at
20;;; your option) any later version.
21;;;
22;;; GNU Guix is distributed in the hope that it will be useful, but
23;;; WITHOUT ANY WARRANTY; without even the implied warranty of
24;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25;;; GNU General Public License for more details.
26;;;
27;;; You should have received a copy of the GNU General Public License
28;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
29
59132b80 30(define-module (gnu packages virtualization)
161ed547 31 #:use-module (gnu packages)
309693e0 32 #:use-module (gnu packages admin)
35e8900d 33 #:use-module (gnu packages assembly)
efcada41 34 #:use-module (gnu packages attr)
309693e0 35 #:use-module (gnu packages autotools)
ecfe88b7 36 #:use-module (gnu packages bison)
a0f6c3b3 37 #:use-module (gnu packages check)
35e8900d 38 #:use-module (gnu packages cmake)
b15fcf9e 39 #:use-module (gnu packages compression)
35e8900d 40 #:use-module (gnu packages cross-base)
309693e0
RW
41 #:use-module (gnu packages curl)
42 #:use-module (gnu packages cyrus-sasl)
43 #:use-module (gnu packages disk)
8fc7bd23 44 #:use-module (gnu packages dns)
fe420383
RW
45 #:use-module (gnu packages docbook)
46 #:use-module (gnu packages documentation)
35e8900d
DM
47 #:use-module (gnu packages figlet)
48 #:use-module (gnu packages firmware)
ecfe88b7 49 #:use-module (gnu packages flex)
fb9472a3 50 #:use-module (gnu packages fontutils)
90a8ef8c 51 #:use-module (gnu packages gettext)
efcada41
DC
52 #:use-module (gnu packages gl)
53 #:use-module (gnu packages glib)
a0f6c3b3 54 #:use-module (gnu packages gnome)
7714a069 55 #:use-module (gnu packages gnupg)
de7f03ce 56 #:use-module (gnu packages golang)
a0f6c3b3 57 #:use-module (gnu packages gtk)
e55354b8 58 #:use-module (gnu packages image)
fb9d7865 59 #:use-module (gnu packages libusb)
efcada41
DC
60 #:use-module (gnu packages linux)
61 #:use-module (gnu packages ncurses)
71d4ba52 62 #:use-module (gnu packages nettle)
fe420383 63 #:use-module (gnu packages networking)
7714a069 64 #:use-module (gnu packages package-management)
06da1a6b 65 #:use-module (gnu packages perl)
efcada41 66 #:use-module (gnu packages pkg-config)
309693e0 67 #:use-module (gnu packages polkit)
fe420383 68 #:use-module (gnu packages protobuf)
efcada41 69 #:use-module (gnu packages python)
589e3f4e 70 #:use-module (gnu packages python-web)
44d10b1f 71 #:use-module (gnu packages python-xyz)
28e3569f 72 #:use-module (gnu packages pulseaudio)
5d4a8f9b 73 #:use-module (gnu packages selinux)
efcada41 74 #:use-module (gnu packages sdl)
38b9ce44 75 #:use-module (gnu packages spice)
efcada41 76 #:use-module (gnu packages texinfo)
71d4ba52 77 #:use-module (gnu packages textutils)
309693e0
RW
78 #:use-module (gnu packages tls)
79 #:use-module (gnu packages web)
35e8900d 80 #:use-module (gnu packages wget)
efcada41 81 #:use-module (gnu packages xdisorg)
309693e0 82 #:use-module (gnu packages xml)
8981465b 83 #:use-module (gnu packages xorg)
6da90719 84 #:use-module (guix build-system cmake)
efcada41 85 #:use-module (guix build-system gnu)
de7f03ce 86 #:use-module (guix build-system go)
7cd2032f 87 #:use-module (guix build-system python)
efcada41 88 #:use-module (guix download)
7714a069 89 #:use-module (guix git-download)
b23b9667 90 #:use-module ((guix licenses) #:prefix license:)
efcada41
DC
91 #:use-module (guix packages)
92 #:use-module (guix utils)
06da1a6b 93 #:use-module (srfi srfi-1))
b15fcf9e 94
e38a71ee
LC
95(define (qemu-patch commit file-name sha256)
96 "Return an origin for COMMIT."
97 (origin
98 (method url-fetch)
99 (uri (string-append
100 "http://git.qemu.org/?p=qemu.git;a=commitdiff_plain;h="
101 commit))
102 (sha256 sha256)
103 (file-name file-name)))
104
06da1a6b 105(define-public qemu
b15fcf9e 106 (package
06da1a6b 107 (name "qemu")
6b34499d 108 (version "3.1.0")
b15fcf9e
LC
109 (source (origin
110 (method url-fetch)
2de7d137 111 (uri (string-append "https://download.qemu.org/qemu-"
fbd6fb1a 112 version ".tar.xz"))
11d19ca2
LF
113 (patches (search-patches "qemu-CVE-2018-16872.patch"
114 "qemu-CVE-2019-6778.patch"))
b15fcf9e
LC
115 (sha256
116 (base32
6b34499d 117 "1z5bd5nfyjvhfi1s95labc82y4hjdjjkdabw931362ls0zghh1ba"))))
b15fcf9e
LC
118 (build-system gnu-build-system)
119 (arguments
219b4556
LC
120 '(;; Running tests in parallel can occasionally lead to failures, like:
121 ;; boot_sector_test: assertion failed (signature == SIGNATURE): (0x00000000 == 0x0000dead)
122 #:parallel-tests? #f
0e5d0f66
RH
123 #:configure-flags (list "--enable-usb-redir" "--enable-opengl"
124 (string-append "--smbd="
125 (assoc-ref %outputs "out")
28e3569f
OP
126 "/libexec/samba-wrapper")
127 "--audio-drv-list=alsa,pa,sdl")
05051e8b
LC
128 #:phases
129 (modify-phases %standard-phases
130 (replace 'configure
131 (lambda* (#:key inputs outputs (configure-flags '())
20c263b0 132 #:allow-other-keys)
05051e8b
LC
133 ;; The `configure' script doesn't understand some of the
134 ;; GNU options. Thus, add a new phase that's compatible.
135 (let ((out (assoc-ref outputs "out")))
136 (setenv "SHELL" (which "bash"))
b15fcf9e 137
05051e8b
LC
138 ;; While we're at it, patch for tests.
139 (substitute* "tests/libqtest.c"
140 (("/bin/sh") (which "sh")))
50731c51 141
05051e8b
LC
142 ;; The binaries need to be linked against -lrt.
143 (setenv "LDFLAGS" "-lrt")
642d2db5
TGR
144 (apply invoke
145 `("./configure"
146 ,(string-append "--cc=" (which "gcc"))
147 ;; Some architectures insist on using HOST_CC
148 ,(string-append "--host-cc=" (which "gcc"))
149 "--disable-debug-info" ; save build space
150 "--enable-virtfs" ; just to be sure
151 ,(string-append "--prefix=" out)
152 ,(string-append "--sysconfdir=/etc")
153 ,@configure-flags)))))
05051e8b
LC
154 (add-after 'install 'install-info
155 (lambda* (#:key inputs outputs #:allow-other-keys)
156 ;; Install the Info manual, unless Texinfo is missing.
642d2db5
TGR
157 (when (assoc-ref inputs "texinfo")
158 (let* ((out (assoc-ref outputs "out"))
159 (dir (string-append out "/share/info")))
160 (invoke "make" "info")
161 (for-each (lambda (info)
162 (install-file info dir))
163 (find-files "." "\\.info"))))
164 #t))
0e5d0f66
RH
165 ;; Create a wrapper for Samba. This allows QEMU to use Samba without
166 ;; pulling it in as an input. Note that you need to explicitly install
167 ;; Samba in your Guix profile for Samba support.
168 (add-after 'install-info 'create-samba-wrapper
169 (lambda* (#:key inputs outputs #:allow-other-keys)
170 (let* ((out (assoc-ref %outputs "out"))
171 (libexec (string-append out "/libexec")))
172 (call-with-output-file "samba-wrapper"
173 (lambda (port)
174 (format port "#!/bin/sh
175exec smbd $@")))
176 (chmod "samba-wrapper" #o755)
177 (install-file "samba-wrapper" libexec))
178 #t))
de3bbf65
LC
179 (add-before 'check 'make-gtester-verbose
180 (lambda _
181 ;; Make GTester verbose to facilitate investigation upon failure.
d229ba95 182 (setenv "V" "1") #t))
05051e8b
LC
183 (add-before 'check 'disable-test-qga
184 (lambda _
43bec6d0 185 (substitute* "tests/Makefile.include"
05051e8b
LC
186 ;; Comment out the test-qga test, which needs /sys and
187 ;; fails within the build environment.
188 (("check-unit-.* tests/test-qga" all)
189 (string-append "# " all)))
190 #t)))))
b15fcf9e 191 (inputs ; TODO: Add optional inputs.
2f042822
DC
192 `(("alsa-lib" ,alsa-lib)
193 ("attr" ,attr)
b15fcf9e 194 ("glib" ,glib)
90a8ef8c 195 ("gtk+" ,gtk+)
fa65e84a 196 ("libaio" ,libaio)
2f042822
DC
197 ("libattr" ,attr)
198 ("libcap" ,libcap) ; virtfs support requires libcap & libattr
9a187b39
AP
199 ("libdrm" ,libdrm)
200 ("libepoxy" ,libepoxy)
513885b5 201 ("libjpeg" ,libjpeg-turbo)
2f042822 202 ("libpng" ,libpng)
34a28c13 203 ("libseccomp" ,libseccomp)
2f042822
DC
204 ("libusb" ,libusb) ;USB pass-through support
205 ("mesa" ,mesa)
206 ("ncurses" ,ncurses)
207 ;; ("pciutils" ,pciutils)
2b2fdd45 208 ("pixman" ,pixman)
28e3569f 209 ("pulseaudio" ,pulseaudio)
27b52c1f 210 ("sdl2" ,sdl2)
38b9ce44 211 ("spice" ,spice)
b376ec57 212 ("usbredir" ,usbredir)
b15fcf9e 213 ("util-linux" ,util-linux)
2f042822 214 ;; ("vde2" ,vde2)
38b9ce44 215 ("virglrenderer" ,virglrenderer)
2f042822 216 ("zlib" ,zlib)))
90a8ef8c
RH
217 (native-inputs `(("gettext" ,gettext-minimal)
218 ("glib:bin" ,glib "bin") ; gtester, etc.
2f042822 219 ("perl" ,perl)
ecfe88b7
MW
220 ("flex" ,flex)
221 ("bison" ,bison)
2f042822 222 ("pkg-config" ,pkg-config)
27b52c1f 223 ("python-wrapper" ,python-wrapper)
2f042822 224 ("texinfo" ,texinfo)))
ce9fbae1 225 (home-page "https://www.qemu.org")
06da1a6b 226 (synopsis "Machine emulator and virtualizer")
72b9eebf 227 (description
50731c51 228 "QEMU is a generic machine emulator and virtualizer.
72b9eebf
LC
229
230When used as a machine emulator, QEMU can run OSes and programs made for one
50731c51
LC
231machine (e.g. an ARM board) on a different machine---e.g., your own PC. By
232using dynamic translation, it achieves very good performance.
72b9eebf
LC
233
234When used as a virtualizer, QEMU achieves near native performances by
235executing the guest code directly on the host CPU. QEMU supports
236virtualization when executing under the Xen hypervisor or using
237the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86,
50731c51
LC
238server and embedded PowerPC, and S390 guests.")
239
240 ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
b23b9667 241 (license license:gpl2)
f47638a3
LC
242
243 ;; Several tests fail on MIPS; see <http://hydra.gnu.org/build/117914>.
244 (supported-systems (delete "mips64el-linux" %supported-systems))))
50731c51 245
06da1a6b
LC
246(define-public qemu-minimal
247 ;; QEMU without GUI support.
248 (package (inherit qemu)
249 (name "qemu-minimal")
250 (synopsis "Machine emulator and virtualizer (without GUI)")
251 (arguments
b376ec57
AP
252 (substitute-keyword-arguments (package-arguments qemu)
253 ((#:configure-flags _ '(list))
254 ;; Restrict to the targets supported by Guix.
255 ''("--target-list=i386-softmmu,x86_64-softmmu,mips64el-softmmu,arm-softmmu,aarch64-softmmu"))))
06da1a6b
LC
256
257 ;; Remove dependencies on optional libraries, notably GUI libraries.
90a8ef8c
RH
258 (native-inputs (fold alist-delete (package-native-inputs qemu)
259 '("gettext")))
06da1a6b 260 (inputs (fold alist-delete (package-inputs qemu)
90a8ef8c 261 '("libusb" "mesa" "sdl2" "spice" "virglrenderer" "gtk+"
28e3569f 262 "usbredir" "libdrm" "libepoxy" "pulseaudio")))))
309693e0 263
27b52c1f
RH
264;; The GRUB test suite fails with later versions of Qemu, so we
265;; keep it at 2.10 for now. See
266;; <https://lists.gnu.org/archive/html/bug-grub/2018-02/msg00004.html>.
267;; This package is hidden since we do not backport updates to it.
268(define-public qemu-minimal-2.10
269 (hidden-package
270 (package
271 (inherit qemu-minimal)
272 (version "2.10.2")
273 (source (origin
274 (method url-fetch)
275 (uri (string-append "https://download.qemu.org/qemu-"
276 version ".tar.xz"))
277 (sha256
278 (base32
3d5ad159
MW
279 "17w21spvaxaidi2am5lpsln8yjpyp2zi3s3gc6nsxj5arlgamzgw"))
280 (patches
281 (search-patches "qemu-glibc-2.27.patch"))))
27b52c1f
RH
282 ;; qemu-minimal-2.10 needs Python 2. Remove below once no longer necessary.
283 (native-inputs `(("python-2" ,python-2)
284 ,@(fold alist-delete (package-native-inputs qemu)
285 '("python-wrapper")))))))
286
a0f6c3b3
RW
287(define-public libosinfo
288 (package
289 (name "libosinfo")
d701f8bd 290 (version "1.0.0")
a0f6c3b3
RW
291 (source
292 (origin
293 (method url-fetch)
d701f8bd 294 (uri (string-append "https://releases.pagure.org/libosinfo/libosinfo-"
a0f6c3b3
RW
295 version ".tar.gz"))
296 (sha256
297 (base32
d701f8bd 298 "0srrs2m6irqd4f867g8ls6jp2dq3ql0l9d0fh80d55sivvn2bd7p"))))
a0f6c3b3
RW
299 (build-system gnu-build-system)
300 (arguments
d701f8bd
RW
301 `(#:configure-flags
302 (list (string-append "--with-usb-ids-path="
303 (assoc-ref %build-inputs "usb.ids"))
304 (string-append "--with-pci-ids-path="
305 (assoc-ref %build-inputs "pci.ids")))
306 #:phases
a0f6c3b3 307 (modify-phases %standard-phases
d701f8bd
RW
308 ;; This odd test fails for unknown reasons.
309 (add-after 'unpack 'disable-broken-test
310 (lambda _
311 (substitute* "test/Makefile.in"
312 (("test-isodetect\\$\\(EXEEXT\\)") ""))
a0f6c3b3
RW
313 #t)))))
314 (inputs
315 `(("libsoup" ,libsoup)
316 ("libxml2" ,libxml2)
317 ("libxslt" ,libxslt)
318 ("gobject-introspection" ,gobject-introspection)))
319 (native-inputs
320 `(("check" ,check)
321 ("glib" ,glib "bin") ; glib-mkenums, etc.
322 ("gtk-doc" ,gtk-doc)
323 ("vala" ,vala)
324 ("intltool" ,intltool)
325 ("pkg-config" ,pkg-config)
326 ("pci.ids"
327 ,(origin
328 (method url-fetch)
d701f8bd 329 (uri "https://github.com/pciutils/pciids/raw/ad02084f0bc143e3c15e31a6152a3dfb1d7a3156/pci.ids")
a0f6c3b3
RW
330 (sha256
331 (base32
d701f8bd 332 "0kfhpj5rnh24hz2714qhfmxk281vwc2w50sm73ggw5d15af7zfsw"))))
a0f6c3b3
RW
333 ("usb.ids"
334 ,(origin
335 (method url-fetch)
0d73f148 336 (uri "https://svn.code.sf.net/p/linux-usb/repo/trunk/htdocs/usb.ids?r=2681")
b02733d4 337 (file-name "usb.ids")
a0f6c3b3
RW
338 (sha256
339 (base32
0d73f148 340 "1m6yhvz5k8aqzxgk7xj3jkk8frl1hbv0h3vgj4wbnvnx79qnvz3r"))))))
a0f6c3b3
RW
341 (home-page "https://libosinfo.org/")
342 (synopsis "Operating system information database")
343 (description "libosinfo is a GObject based library API for managing
344information about operating systems, hypervisors and the (virtual) hardware
345devices they can support. It includes a database containing device metadata
346and provides APIs to match/identify optimal devices for deploying an operating
347system on a hypervisor. Via GObject Introspection, the API is available in
348all common programming languages. Vala bindings are also provided.")
349 ;; The library files are released under LGPLv2.1 or later; the source
350 ;; files in the "tools" directory are released under GPLv2+.
b23b9667 351 (license (list license:lgpl2.1+ license:gpl2+))))
a0f6c3b3 352
5d4a8f9b
SB
353(define-public lxc
354 (package
355 (name "lxc")
c4f8953a 356 (version "3.0.2")
5d4a8f9b
SB
357 (source (origin
358 (method url-fetch)
359 (uri (string-append
360 "https://linuxcontainers.org/downloads/lxc/lxc-"
361 version ".tar.gz"))
362 (sha256
363 (base32
c4f8953a 364 "0p1gy553cm4mhwxi85fl6qiwz61rjmvysm8c8pd20qh62xxi3dva"))))
5d4a8f9b
SB
365 (build-system gnu-build-system)
366 (native-inputs
367 `(("pkg-config" ,pkg-config)))
368 (inputs
369 `(("gnutls" ,gnutls)
370 ("libcap" ,libcap)
371 ("libseccomp" ,libseccomp)
372 ("libselinux" ,libselinux)))
373 (arguments
374 '(#:configure-flags
375 '("--sysconfdir=/etc"
376 "--localstatedir=/var")
377 #:phases
378 (modify-phases %standard-phases
379 (replace 'install
380 (lambda* (#:key outputs #:allow-other-keys)
381 (let* ((out (assoc-ref outputs "out"))
382 (bashcompdir (string-append out "/etc/bash_completion.d")))
d6870d10 383 (invoke "make" "install"
5d4a8f9b
SB
384 (string-append "bashcompdir=" bashcompdir)
385 ;; Don't install files into /var and /etc.
386 "LXCPATH=/tmp/var/lib/lxc"
387 "localstatedir=/tmp/var"
388 "sysconfdir=/tmp/etc"
d6870d10 389 "sysconfigdir=/tmp/etc/default")))))))
5d4a8f9b
SB
390 (synopsis "Linux container tools")
391 (home-page "https://linuxcontainers.org/")
392 (description
393 "LXC is a userspace interface for the Linux kernel containment features.
394Through a powerful API and simple tools, it lets Linux users easily create and
395manage system or application containers.")
b23b9667 396 (license license:lgpl2.1+)))
5d4a8f9b 397
309693e0
RW
398(define-public libvirt
399 (package
400 (name "libvirt")
8981465b 401 (version "4.10.0")
309693e0
RW
402 (source (origin
403 (method url-fetch)
2e508b6d 404 (uri (string-append "https://libvirt.org/sources/libvirt-"
309693e0
RW
405 version ".tar.xz"))
406 (sha256
407 (base32
8981465b 408 "0v17zzyyb25nn9l18v5244myg7590dp6ppwgi8xysipifc0q77bz"))))
309693e0
RW
409 (build-system gnu-build-system)
410 (arguments
411 `(;; FAIL: virshtest
412 ;; FAIL: virfirewalltest
413 ;; FAIL: virkmodtest
414 ;; FAIL: virnetsockettest
415 ;; FAIL: networkxml2firewalltest
416 ;; FAIL: nwfilterebiptablestest
417 ;; FAIL: nwfilterxml2firewalltest
07378e31 418 ;; Time-out while running commandtest.
309693e0
RW
419 #:tests? #f
420 #:configure-flags
421 (list "--with-polkit"
a4b93921 422 "--sysconfdir=/etc"
309693e0
RW
423 "--localstatedir=/var")
424 #:phases
425 (modify-phases %standard-phases
426 (add-after 'unpack 'fix-tests
427 (lambda _
428 (substitute* '("tests/commandtest.c"
429 "gnulib/tests/test-posix_spawn1.c"
430 "gnulib/tests/test-posix_spawn2.c")
431 (("/bin/sh") (which "sh")))
432 #t))
a4b93921
SB
433 (replace 'install
434 ;; Since the sysconfdir and localstatedir should be /etc and /var
435 ;; at runtime, we must prevent writing to them at installation
436 ;; time.
437 (lambda _
07378e31
TGR
438 (invoke "make" "install"
439 "sysconfdir=/tmp/etc"
440 "localstatedir=/tmp/var")))
903e051a
CB
441 (add-after 'install 'wrap-libvirtd
442 (lambda* (#:key inputs outputs #:allow-other-keys)
443 (let ((out (assoc-ref outputs "out")))
444 (wrap-program (string-append out "/sbin/libvirtd")
445 `("PATH" = (,(string-append (assoc-ref inputs "iproute")
446 "/sbin")
447 ,(string-append (assoc-ref inputs "qemu")
448 "/bin"))))
449 #t))))))
309693e0
RW
450 (inputs
451 `(("libxml2" ,libxml2)
8981465b
RH
452 ("eudev" ,eudev)
453 ("libpciaccess" ,libpciaccess)
309693e0
RW
454 ("gnutls" ,gnutls)
455 ("dbus" ,dbus)
456 ("qemu" ,qemu)
309693e0
RW
457 ("libpcap" ,libpcap)
458 ("libnl" ,libnl)
459 ("libuuid" ,util-linux)
460 ("lvm2" ,lvm2) ; for libdevmapper
461 ("curl" ,curl)
462 ("openssl" ,openssl)
463 ("cyrus-sasl" ,cyrus-sasl)
309693e0 464 ("libyajl" ,libyajl)
8fc7bd23
SB
465 ("audit" ,audit)
466 ("dmidecode" ,dmidecode)
467 ("dnsmasq" ,dnsmasq)
468 ("ebtables" ,ebtables)
469 ("iproute" ,iproute)
470 ("iptables" ,iptables)))
309693e0 471 (native-inputs
2f110b32 472 `(("xsltproc" ,libxslt)
b8fb94d5
TGR
473 ("perl" ,perl)
474 ("pkg-config" ,pkg-config)
475 ("polkit" ,polkit)
35d56c1c 476 ("python" ,python)))
2e508b6d 477 (home-page "https://libvirt.org")
309693e0
RW
478 (synopsis "Simple API for virtualization")
479 (description "Libvirt is a C toolkit to interact with the virtualization
480capabilities of recent versions of Linux. The library aims at providing long
481term stable C API initially for the Xen paravirtualization but should be able
482to integrate other virtualization mechanisms if needed.")
b23b9667 483 (license license:lgpl2.1+)))
597ea122
RW
484
485(define-public libvirt-glib
486 (package
487 (name "libvirt-glib")
c3c03162 488 (version "1.0.0")
597ea122
RW
489 (source (origin
490 (method url-fetch)
491 (uri (string-append "ftp://libvirt.org/libvirt/glib/"
492 "libvirt-glib-" version ".tar.gz"))
493 (sha256
494 (base32
c3c03162 495 "0iwa5sdbii52pjpdm5j37f67sdmf0kpcky4liwhy1nf43k85i4fa"))))
597ea122
RW
496 (build-system gnu-build-system)
497 (arguments
498 `(#:phases
499 (modify-phases %standard-phases
500 (add-after 'unpack 'fix-tests
501 (lambda _
502 (substitute* "tests/test-events.c"
503 (("/bin/true") (which "true")))
504 #t)))))
505 (inputs
506 `(("libxml2" ,libxml2)
507 ("libvirt" ,libvirt)
508 ("gobject-introspection" ,gobject-introspection)
509 ("glib" ,glib)
510 ("openssl" ,openssl)
511 ("cyrus-sasl" ,cyrus-sasl)
512 ("lvm2" ,lvm2) ; for libdevmapper
513 ("libyajl" ,libyajl)))
514 (native-inputs
515 `(("pkg-config" ,pkg-config)
516 ("intltool" ,intltool)
517 ("glib" ,glib "bin")
518 ("vala" ,vala)))
b3fee5c1 519 (home-page "https://libvirt.org")
597ea122
RW
520 (synopsis "GLib wrapper around libvirt")
521 (description "libvirt-glib wraps the libvirt library to provide a
522high-level object-oriented API better suited for glib-based applications, via
523three libraries:
524
525@enumerate
526@item libvirt-glib - GLib main loop integration & misc helper APIs
527@item libvirt-gconfig - GObjects for manipulating libvirt XML documents
528@item libvirt-gobject - GObjects for managing libvirt objects
529@end enumerate
530")
b23b9667 531 (license license:lgpl2.1+)))
7cd2032f
RW
532
533(define-public python-libvirt
534 (package
535 (name "python-libvirt")
d15211c9 536 (version "4.10.0")
7cd2032f
RW
537 (source (origin
538 (method url-fetch)
539 (uri (pypi-uri "libvirt-python" version))
540 (sha256
541 (base32
d15211c9 542 "11fipj9naihgc9afc8bz5hi05xa1shp4qcy170sa18p3sl4zljb9"))))
7cd2032f
RW
543 (build-system python-build-system)
544 (arguments
545 `(#:phases
546 (modify-phases %standard-phases
547 (add-after 'unpack 'patch-nosetests-path
548 (lambda* (#:key inputs #:allow-other-keys)
549 (substitute* "setup.py"
9271dfdd
SB
550 (("\"/usr/bin/nosetests\"")
551 (string-append "\"" (which "nosetests") "\""))
552 (("self\\.spawn\\(\\[sys\\.executable, nose\\]\\)")
553 (format #f "self.spawn([\"~a\", nose])" (which "bash"))))
7cd2032f
RW
554 #t)))))
555 (inputs
482d9591
HG
556 `(("libvirt" ,libvirt)))
557 (propagated-inputs
558 `(("python-lxml" ,python-lxml)))
7cd2032f
RW
559 (native-inputs
560 `(("pkg-config" ,pkg-config)
561 ("python-nose" ,python-nose)))
b3fee5c1 562 (home-page "https://libvirt.org")
7cd2032f
RW
563 (synopsis "Python bindings to libvirt")
564 (description "This package provides Python bindings to the libvirt
565virtualization library.")
b23b9667 566 (license license:lgpl2.1+)))
7cd2032f
RW
567
568(define-public python2-libvirt
569 (package-with-python2 python-libvirt))
2f82b53b
RW
570
571(define-public virt-manager
572 (package
573 (name "virt-manager")
f8be7664 574 (version "2.0.0")
2f82b53b
RW
575 (source (origin
576 (method url-fetch)
577 (uri (string-append "https://virt-manager.org/download/sources"
578 "/virt-manager/virt-manager-"
579 version ".tar.gz"))
580 (sha256
581 (base32
f8be7664 582 "1b48xbrx99mfiv80c60k3ydzkpcpbq57c8h8dl0gnffmnzbs8vzb"))))
2f82b53b
RW
583 (build-system python-build-system)
584 (arguments
f8be7664 585 `(#:use-setuptools? #f ; Uses custom distutils 'install' command.
2f82b53b
RW
586 ;; Some of the tests seem to require network access to install virtual
587 ;; machines.
588 #:tests? #f
f023685d
AP
589 #:imported-modules ((guix build glib-or-gtk-build-system)
590 ,@%python-build-system-modules)
2f82b53b
RW
591 #:modules ((ice-9 match)
592 (srfi srfi-26)
593 (guix build python-build-system)
f023685d 594 ((guix build glib-or-gtk-build-system) #:prefix glib-or-gtk:)
2f82b53b
RW
595 (guix build utils))
596 #:phases
597 (modify-phases %standard-phases
598 (add-after 'unpack 'fix-setup
599 (lambda* (#:key outputs #:allow-other-keys)
600 (substitute* "virtcli/cliconfig.py"
601 (("/usr") (assoc-ref outputs "out")))
602 #t))
4ad8fbd1
AP
603 (add-after 'unpack 'fix-default-uri
604 (lambda* (#:key inputs #:allow-other-keys)
605 ;; xen is not available for now - so only patch qemu
606 (substitute* "virtManager/connect.py"
607 (("/usr(/bin/qemu-system)" _ suffix)
608 (string-append (assoc-ref inputs "qemu") suffix)))
609 #t))
2f82b53b
RW
610 (add-before 'wrap 'wrap-with-GI_TYPELIB_PATH
611 (lambda* (#:key inputs outputs #:allow-other-keys)
612 (let* ((bin (string-append (assoc-ref outputs "out") "/bin"))
613 (bin-files (find-files bin ".*"))
614 (paths (map (match-lambda
615 ((output . directory)
616 (let* ((girepodir (string-append
617 directory
618 "/lib/girepository-1.0")))
619 (if (file-exists? girepodir)
620 girepodir #f))))
621 inputs)))
622 (for-each (lambda (file)
623 (format #t "wrapping ~a\n" file)
624 (wrap-program file
625 `("GI_TYPELIB_PATH" ":" prefix
626 ,(filter identity paths))))
627 bin-files))
f023685d
AP
628 #t))
629 (add-after 'install 'glib-or-gtk-compile-schemas
630 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
631 (add-after 'install 'glib-or-gtk-wrap
632 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap)))))
2f82b53b 633 (inputs
b1e9837a
AP
634 `(("dconf" ,dconf)
635 ("gtk+" ,gtk+)
45214efe 636 ("gtk-vnc" ,gtk-vnc)
2f82b53b
RW
637 ("libvirt" ,libvirt)
638 ("libvirt-glib" ,libvirt-glib)
639 ("libosinfo" ,libosinfo)
45214efe 640 ("vte" ,vte)
2f82b53b 641 ("gobject-introspection" ,gobject-introspection)
f8be7664
RH
642 ("python-libvirt" ,python-libvirt)
643 ("python-requests" ,python-requests)
644 ("python-ipaddress" ,python-ipaddress)
645 ("python-pycairo" ,python-pycairo)
646 ("python-pygobject" ,python-pygobject)
647 ("python-libxml2" ,python-libxml2)
8da7f792 648 ("spice-gtk" ,spice-gtk)))
2f82b53b
RW
649 ;; virt-manager searches for qemu-img or kvm-img in the PATH.
650 (propagated-inputs
651 `(("qemu" ,qemu)))
652 (native-inputs
653 `(("glib" ,glib "bin") ; glib-compile-schemas.
e6efcd58 654 ("gtk+" ,gtk+ "bin") ; gtk-update-icon-cache
2f82b53b
RW
655 ("perl" ,perl) ; pod2man
656 ("intltool" ,intltool)))
657 (home-page "https://virt-manager.org/")
658 (synopsis "Manage virtual machines")
659 (description
660 "The virt-manager application is a desktop user interface for managing
661virtual machines through libvirt. It primarily targets KVM VMs, but also
662manages Xen and LXC (Linux containers). It presents a summary view of running
663domains, their live performance and resource utilization statistics.")
b23b9667 664 (license license:gpl2+)))
fe420383
RW
665
666(define-public criu
667 (package
668 (name "criu")
580f33e1 669 (version "3.11")
fe420383
RW
670 (source (origin
671 (method url-fetch)
672 (uri (string-append "http://download.openvz.org/criu/criu-"
673 version ".tar.bz2"))
674 (sha256
675 (base32
580f33e1 676 "03nimyn3wy5mlw30gq7bvlzvvprqjv8f25240yj5arzlld8mhsw8"))))
fe420383
RW
677 (build-system gnu-build-system)
678 (arguments
679 `(#:test-target "test"
680 #:tests? #f ; tests require mounting as root
681 #:make-flags
682 (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
683 (string-append "LIBDIR=" (assoc-ref %outputs "out")
684 "/lib"))
685 #:phases
686 (modify-phases %standard-phases
687 (replace 'configure
688 (lambda* (#:key inputs #:allow-other-keys)
689 ;; The includes for libnl are located in a sub-directory.
690 (setenv "C_INCLUDE_PATH"
691 (string-append (assoc-ref inputs "libnl")
692 "/include/libnl3:"
693 (getenv "C_INCLUDE_PATH")))
694 ;; Prevent xmlto from failing the install phase.
695 (substitute* "Documentation/Makefile"
696 (("XMLTO.*:=.*")
697 (string-append "XMLTO:="
698 (assoc-ref inputs "xmlto")
699 "/bin/xmlto"
700 " --skip-validation "
701 " -x "
702 (assoc-ref inputs "docbook-xsl")
703 "/xml/xsl/docbook-xsl-"
704 ,(package-version docbook-xsl)
580f33e1
EF
705 "/manpages/docbook.xsl"))
706 (("\\$\\(XMLTO\\);")
707 (string-append (assoc-ref inputs "xmlto")
708 "/bin/xmlto;")))
709 #t))
710 (add-after 'unpack 'hardcode-variables
711 (lambda* (#:key inputs #:allow-other-keys)
712 ;; Hardcode arm version detection
713 (substitute* "Makefile"
714 (("ARMV.*:=.*") "ARMV := 7\n"))
715 ;; We are currently using python-2
716 (substitute* "crit/Makefile"
717 (("\\$\\(PYTHON\\)") "python2"))
718 (substitute* "lib/Makefile"
719 (("\\$\\(PYTHON\\)")
720 (string-append (assoc-ref inputs "python")
721 "/bin/python")))
fe420383
RW
722 #t))
723 (add-before 'build 'fix-symlink
724 (lambda* (#:key inputs #:allow-other-keys)
725 ;; The file 'images/google/protobuf/descriptor.proto' points to
726 ;; /usr/include/..., which obviously does not exist.
727 (let* ((file "google/protobuf/descriptor.proto")
728 (target (string-append "images/" file))
729 (source (string-append (assoc-ref inputs "protobuf")
730 "/include/" file)))
731 (delete-file target)
732 (symlink source target)
733 #t)))
734 (add-after 'install 'wrap
735 (lambda* (#:key inputs outputs #:allow-other-keys)
736 ;; Make sure 'crit' runs with the correct PYTHONPATH.
737 (let* ((out (assoc-ref outputs "out"))
738 (path (string-append out
739 "/lib/python"
740 (string-take (string-take-right
741 (assoc-ref inputs "python") 5) 3)
742 "/site-packages:"
743 (getenv "PYTHONPATH"))))
744 (wrap-program (string-append out "/bin/crit")
745 `("PYTHONPATH" ":" prefix (,path))))
746 #t)))))
747 (inputs
748 `(("protobuf" ,protobuf)
749 ("python" ,python-2)
750 ("python2-protobuf" ,python2-protobuf)
751 ("python2-ipaddr" ,python2-ipaddr)
752 ("iproute" ,iproute)
753 ("libaio" ,libaio)
754 ("libcap" ,libcap)
755 ("libnet" ,libnet)
756 ("libnl" ,libnl)))
757 (native-inputs
758 `(("pkg-config" ,pkg-config)
3bf94bc8 759 ("perl" ,perl)
fe420383
RW
760 ("protobuf-c" ,protobuf-c)
761 ("asciidoc" ,asciidoc)
762 ("xmlto" ,xmlto)
763 ("docbook-xml" ,docbook-xml)
764 ("docbook-xsl" ,docbook-xsl)))
765 (home-page "https://criu.org")
766 (synopsis "Checkpoint and restore in user space")
767 (description "Using this tool, you can freeze a running application (or
768part of it) and checkpoint it to a hard drive as a collection of files. You
769can then use the files to restore and run the application from the point it
770was frozen at. The distinctive feature of the CRIU project is that it is
771mainly implemented in user space.")
772 ;; The project is licensed under GPLv2; files in the lib/ directory are
773 ;; LGPLv2.1.
b23b9667 774 (license (list license:gpl2 license:lgpl2.1))))
f46a3523
RH
775
776(define-public qmpbackup
777 (package
778 (name "qmpbackup")
779 (version "0.2")
780 (source (origin
781 (method url-fetch)
782 (uri (string-append "https://github.com/abbbi/qmpbackup/archive/"
783 version ".tar.gz"))
784 (sha256
785 (base32
786 "10k9mnb1yrg4gw1rvz4kw4dxc4aajl8gnjrpm3axqkg63qmxj3qn"))
787 (file-name (string-append name "-" version ".tar.gz"))))
788 (build-system python-build-system)
789 (arguments
790 `(#:python ,python-2))
791 (home-page "https://github.com/abbbi/qmpbackup")
792 (synopsis "Backup and restore QEMU machines")
793 (description "qmpbackup is designed to create and restore full and
794incremental backups of running QEMU virtual machines via QMP, the QEMU
795Machine Protocol.")
b23b9667 796 (license license:gpl3+)))
fb9472a3
RH
797
798(define-public lookingglass
799 (package
800 (name "lookingglass")
6da90719 801 (version "a12")
fb9472a3
RH
802 (source
803 (origin
84243592
MB
804 (method git-fetch)
805 (uri (git-reference (url "https://github.com/gnif/LookingGlass")
806 (commit version)))
807 (file-name (git-file-name name version))
fb9472a3
RH
808 (sha256
809 (base32
84243592 810 "0r6bvl9q94039r6ff4f2bg8si95axx9w8bf1h1qr5730d2kv5yxq"))))
6da90719 811 (build-system cmake-build-system)
fb9472a3
RH
812 (inputs `(("fontconfig" ,fontconfig)
813 ("glu" ,glu)
814 ("mesa" ,mesa)
815 ("openssl" ,openssl)
816 ("sdl2" ,sdl2)
817 ("sdl2-ttf" ,sdl2-ttf)
818 ("spice-protocol" ,spice-protocol)))
71d4ba52
RH
819 (native-inputs `(("libconfig" ,libconfig)
820 ("nettle" ,nettle)
821 ("pkg-config" ,pkg-config)))
fb9472a3
RH
822 (arguments
823 `(#:tests? #f ;; No tests are available.
71d4ba52 824 #:make-flags '("CC=gcc")
fb9472a3 825 #:phases (modify-phases %standard-phases
6da90719 826 (add-before 'configure 'chdir-to-client
fb9472a3
RH
827 (lambda* (#:key outputs #:allow-other-keys)
828 (chdir "client")
829 #t))
830 (replace 'install
831 (lambda* (#:key outputs #:allow-other-keys)
6da90719 832 (install-file "looking-glass-client"
fb9472a3
RH
833 (string-append (assoc-ref outputs "out")
834 "/bin"))
6da90719
RH
835 #t))
836 )))
fb9472a3
RH
837 (home-page "https://looking-glass.hostfission.com")
838 (synopsis "KVM Frame Relay (KVMFR) implementation")
839 (description "Looking Glass allows the use of a KVM (Kernel-based Virtual
840Machine) configured for VGA PCI Pass-through without an attached physical
841monitor, keyboard or mouse. It displays the VM's rendered contents on your main
842monitor/GPU.")
25504aaf
EF
843 ;; This package requires SSE instructions.
844 (supported-systems '("i686-linux" "x86_64-linux"))
b23b9667 845 (license license:gpl2+)))
de7f03ce
SB
846
847(define-public runc
848 (package
849 (name "runc")
850 (version "1.0.0-rc5")
851 (source (origin
852 (method url-fetch)
853 (uri (string-append
854 "https://github.com/opencontainers/runc/releases/"
855 "download/v" version "/runc.tar.xz"))
856 (sha256
857 (base32
858 "081avdzwnqpk368wbaihlzsypaxpj42d7699h7jgp0fks14x4103"))))
859 (build-system go-build-system)
860 (arguments
861 '(#:import-path "github.com/opencontainers/runc"
862 #:install-source? #f
03e45891
SB
863 ;; XXX: 20/139 tests fail due to missing /var, cgroups and apparmor in
864 ;; the build environment.
865 #:tests? #f
de7f03ce
SB
866 #:phases
867 (modify-phases %standard-phases
868 (replace 'unpack
869 (lambda* (#:key source import-path #:allow-other-keys)
870 ;; Unpack the tarball into 'runc' instead of 'runc-1.0.0-rc5'.
871 (let ((dest (string-append "src/" import-path)))
872 (mkdir-p dest)
873 (invoke "tar" "-C" (string-append "src/" import-path)
874 "--strip-components=1"
875 "-xvf" source))))
876 (replace 'build
877 (lambda* (#:key import-path #:allow-other-keys)
878 (chdir (string-append "src/" import-path))
879 ;; XXX: requires 'go-md2man'.
880 ;; (invoke "make" "man")
881 (invoke "make")))
882 ;; (replace 'check
883 ;; (lambda _
884 ;; (invoke "make" "localunittest")))
885 (replace 'install
886 (lambda* (#:key outputs #:allow-other-keys)
887 (let ((out (assoc-ref outputs "out")))
888 (invoke "make" "install" "install-bash"
889 (string-append "PREFIX=" out))))))))
890 (native-inputs
891 `(("pkg-config" ,pkg-config)))
892 (inputs
893 `(("libseccomp" ,libseccomp)))
894 (synopsis "Open container initiative runtime")
895 (home-page "https://www.opencontainers.org/")
896 (description
897 "@command{runc} is a command line client for running applications
898packaged according to the
899@uref{https://github.com/opencontainers/runtime-spec/blob/master/spec.md, Open
900Container Initiative (OCI) format} and is a compliant implementation of the
901Open Container Initiative specification.")
b23b9667 902 (license license:asl2.0)))
efdaf8de
SB
903
904(define-public umoci
905 (package
906 (name "umoci")
9d58e881 907 (version "0.4.4")
efdaf8de
SB
908 (source (origin
909 (method url-fetch)
910 (uri (string-append
911 "https://github.com/openSUSE/umoci/releases/download/v"
912 version "/umoci.tar.xz"))
913 (file-name (string-append "umoci-" version ".tar.xz"))
914 (sha256
915 (base32
9d58e881 916 "1wchmha5k2f370jfijmx9fqp0cp99zfa9ajmfbq3j24qc8p5k8lk"))))
efdaf8de
SB
917 (build-system go-build-system)
918 (arguments
919 '(#:import-path "github.com/openSUSE/umoci"
920 #:install-source? #f
921 #:phases
922 (modify-phases %standard-phases
923 (replace 'unpack
924 (lambda* (#:key source import-path #:allow-other-keys)
925 ;; Unpack the tarball into 'umoci' instead of "runc-${version}".
926 (let ((dest (string-append "src/" import-path)))
927 (mkdir-p dest)
928 (invoke "tar" "-C" (string-append "src/" import-path)
929 "--strip-components=1"
930 "-xvf" source))))
931 (replace 'build
932 (lambda* (#:key import-path #:allow-other-keys)
933 (chdir (string-append "src/" import-path))
934 ;; TODO: build manpages with 'go-md2man'.
935 (invoke "make" "SHELL=bash")))
936 (replace 'install
937 (lambda* (#:key outputs #:allow-other-keys)
938 (let* ((out (assoc-ref outputs "out"))
939 (bindir (string-append out "/bin")))
940 (install-file "umoci" bindir)
941 #t))))))
942 (home-page "https://umo.ci/")
943 (synopsis "Tool for modifying Open Container images")
944 (description
945 "@command{umoci} is a tool that allows for high-level modification of an
946Open Container Initiative (OCI) image layout and its tagged images.")
b23b9667 947 (license license:asl2.0)))
7714a069
SB
948
949(define-public skopeo
950 (package
951 (name "skopeo")
952 (version "0.1.28")
953 (source (origin
954 (method git-fetch)
955 (uri (git-reference
956 (url "https://github.com/projectatomic/skopeo")
957 (commit (string-append "v" version))))
958 (file-name (git-file-name name version))
959 (sha256
960 (base32
961 "068nwrr3nr27alravcq1sxyhdd5jjr24213vdgn1dqva3885gbi0"))))
962 (build-system go-build-system)
963 (native-inputs
964 `(("pkg-config" ,pkg-config)))
965 (inputs
966 `(("btrfs-progs" ,btrfs-progs)
967 ("eudev" ,eudev)
968 ("libassuan" ,libassuan)
969 ("libselinux" ,libselinux)
970 ("libostree" ,libostree)
971 ("lvm2" ,lvm2)
972 ("glib" ,glib)
973 ("gpgme" ,gpgme)))
974 (arguments
975 '(#:import-path "github.com/projectatomic/skopeo"
976 #:install-source? #f
977 #:phases
978 (modify-phases %standard-phases
979 (replace 'build
980 (lambda* (#:key import-path #:allow-other-keys)
981 (chdir (string-append "src/" import-path))
982 ;; TODO: build manpages with 'go-md2man'.
983 (invoke "make" "binary-local")))
984 (replace 'install
985 (lambda* (#:key outputs #:allow-other-keys)
986 (let ((out (assoc-ref outputs "out")))
987 (invoke "make" "install-binary" "install-completions"
988 (string-append "PREFIX=" out))))))))
989 (home-page "https://github.com/projectatomic/skopeo")
990 (synopsis "Interact with container images and container image registries")
991 (description
992 "@command{skopeo} is a command line utility providing various operations
993with container images and container image registries. It can:
994@enumerate
995
996@item Copy container images between various containers image stores,
997converting them as necessary.
998
999@item Convert a Docker schema 2 or schema 1 container image to an OCI image.
1000
1001@item Inspect a repository on a container registry without needlessly pulling
1002the image.
1003
1004@item Sign and verify container images.
1005
1006@item Delete container images from a remote container registry.
1007
1008@end enumerate")
b23b9667 1009 (license license:asl2.0)))
5e95181b
EF
1010
1011(define-public python-vagrant
1012 (package
1013 (name "python-vagrant")
1014 (version "0.5.15")
1015 (source
1016 (origin
1017 (method url-fetch)
1018 (uri (pypi-uri "python-vagrant" version))
1019 (sha256
1020 (base32
1021 "1ikrh6canhcxg5y7pzmkcnnydikppv7s6sm9prfx90nk0ac8m6mg"))))
1022 (build-system python-build-system)
1023 (arguments
1024 '(#:tests? #f)) ; tests involve running vagrant.
1025 (home-page "https://github.com/todddeluca/python-vagrant")
1026 (synopsis "Python bindings for Vagrant")
1027 (description
1028 "Python-vagrant is a Python module that provides a thin wrapper around the
1029@code{vagrant} command line executable, allowing programmatic control of Vagrant
1030virtual machines.")
1031 (license license:expat)))
f6e55da0
JL
1032
1033(define-public bubblewrap
1034 (package
1035 (name "bubblewrap")
1036 (version "0.3.1")
1037 (source (origin
1038 (method url-fetch)
1039 (uri (string-append "https://github.com/projectatomic/bubblewrap/"
1040 "releases/download/v" version "/bubblewrap-"
1041 version ".tar.xz"))
1042 (sha256
1043 (base32
1044 "1y2bdlxnlr84xcbf31lzirc292c5ak9bd2wvcvh4ppsliih6pjny"))))
1045 (build-system gnu-build-system)
1046 (arguments
1047 `(#:phases
1048 (modify-phases %standard-phases
1049 (add-after 'unpack 'fix-test
1050 (lambda* (#:key outputs #:allow-other-keys)
1051 ;; Tests try to access /var/tmp, which is not possible in our build
1052 ;; environment. Let's give them another directory.
1053 ;; /tmp gets overriden in some tests, so we need another directory.
1054 ;; the only possibility is the output directory.
1055 (let ((tmp-dir (string-append (assoc-ref outputs "out") "/tmp")))
1056 (mkdir-p tmp-dir)
1057 (substitute* "tests/test-run.sh"
1058 (("/var/tmp") tmp-dir)
1059 ;; Tests create a temporary python script, so fix its shebang.
1060 (("/usr/bin/env python") (which "python"))
1061 ;; Some tests try to access /usr, but that doesn't exist.
1062 ;; Give them /gnu instead.
1063 (("/usr") "/gnu")
1064 ((" */bin/bash") (which "bash"))
1065 (("/bin/sh") (which "sh"))
1066 (("findmnt") (which "findmnt"))))
1067 #t))
1068 ;; Remove the directory we gave to tests to have a clean package.
1069 (add-after 'check 'remove-tmp-dir
1070 (lambda* (#:key outputs #:allow-other-keys)
1071 (delete-file-recursively (string-append (assoc-ref outputs "out") "/tmp"))
1072 #t)))))
1073 (inputs
1074 `(("libcap" ,libcap)))
1075 (native-inputs
1076 `(("python-2" ,python-2)
1077 ("util-linux" ,util-linux)))
1078 (home-page "https://github.com/projectatomic/bubblewrap")
1079 (synopsis "Unprivileged sandboxing tool")
1080 (description "Bubblewrap is aimed at running applications in a sandbox,
1081where it has restricted access to parts of the operating system or user data
1082such as the home directory. Bubblewrap always creates a new mount namespace,
1083and the user can specify exactly what parts of the filesystem should be visible
1084in the sandbox. Any such directories specified is mounted nodev by default,
1085and can be made readonly.")
1086 (license license:lgpl2.0+)))
17043677 1087
1088(define-public bochs
1089 (package
1090 (name "bochs")
1091 (version "2.6.9")
1092 (source
1093 (origin
1094 (method url-fetch)
1095 (uri (string-append "https://sourceforge.net/projects/bochs/files/bochs/"
1096 version "/bochs-" version ".tar.gz"))
1097 (sha256
1098 (base32
1099 "1379cq4cnfprhw8mgh60i0q9j8fz8d7n3d5fnn2g9fdiv5znfnzf"))))
1100 (build-system gnu-build-system)
1101 (arguments
1102 `(#:tests? #f)) ; No tests exist
1103 (inputs
1104 `(("libxrandr" ,libxrandr)))
1105 (home-page "http://bochs.sourceforge.net/")
1106 (synopsis "Emulator for x86 PC")
1107 (description
1108 "Bochs is an emulator which can emulate Intel x86 CPU, common I/O
1109devices, and a custom BIOS. It can also be compiled to emulate many different
1110x86 CPUs, from early 386 to the most recent x86-64 Intel and AMD processors.
1111Bochs can run most Operating Systems inside the emulation including Linux,
1112DOS or Microsoft Windows.")
1113 (license license:lgpl2.0+)))
35e8900d 1114
35e8900d
DM
1115(define-public xen
1116 (package
1117 (name "xen")
1118 (version "4.11.1")
1119 (source (origin
1120 (method git-fetch)
1121 (uri (git-reference
1122 (url "git://xenbits.xenproject.org/xen.git")
1123 (commit (string-append "RELEASE-" version))))
1124 (file-name (git-file-name name version))
1125 (sha256
1126 (base32
1127 "1wv1hyfii14vi9lfjmnv07h2gpm3b7kvh2p55f4yy2b40simksgk"))))
1128 (build-system gnu-build-system)
1129 (arguments
1130 `(#:configure-flags
1131 (list "--enable-rpath"
1132 "--disable-qemu-traditional" ; It tries to do "git clone"
1133 "--disable-rombios" ; would try to "git clone" via etherboot.
35e8900d
DM
1134 ;; TODO: Re-enable stubdom (it's "more secure" to use it).
1135 "--disable-stubdom" ; tries to "git clone" old patched newlib.
1136 (string-append "--with-initddir="
1137 (assoc-ref %outputs "out")
1138 "/etc/init.d")
1139 (string-append "--with-system-qemu="
1140 (assoc-ref %build-inputs "qemu")
1141 "/bin/qemu-system-i386")
1142 (string-append "--with-system-seabios="
1143 (assoc-ref %build-inputs "seabios")
1144 "/share/firmware/bios.bin")
1145 (string-append "--with-system-ovmf="
1146 (assoc-ref %build-inputs "ovmf")
1147 "/share/firmware/ovmf_ia32.bin"))
1148 #:make-flags (list "-j" "1"
1149 "XEN_BUILD_DATE=Thu Jan 1 01:00:01 CET 1970"
1150 "XEN_BUILD_TIME=01:00:01"
1151 "XEN_BUILD_HOST="
1152 "ETHERBOOT_NICS="
1153 "SMBIOS_REL_DATE=01/01/1970"
1154 "VGABIOS_REL_DATE=01 Jan 1970"
1155 ; QEMU_TRADITIONAL_LOC
1156 ; QEMU_UPSTREAM_LOC
1157 "SYSCONFIG_DIR=/tmp/etc/default"
1158 (string-append "BASH_COMPLETION_DIR="
1159 (assoc-ref %outputs "out")
1160 "/etc/bash_completion.d")
1161 (string-append "BOOT_DIR="
1162 (assoc-ref %outputs "out")
1163 "/boot")
1164 (string-append "DEBUG_DIR="
1165 (assoc-ref %outputs "out")
1166 "/lib/debug")
1167 (string-append "EFI_DIR="
1168 (assoc-ref %outputs "out")
1169 "/lib/efi") ; TODO lib64 ?
1170 "MINIOS_UPSTREAM_URL="
1171 ;(string-append "DISTDIR="
1172 ; (assoc-ref %outputs "out"))
1173)
1174 #:test-target "test"
1175 #:phases
1176 (modify-phases %standard-phases
1177 (add-after 'unpack 'unpack-mini-os
1178 (lambda* (#:key inputs #:allow-other-keys)
1179 (copy-recursively (assoc-ref inputs "mini-os") "extras/mini-os")
1180 #t))
1181 (add-after 'unpack-mini-os 'patch
1182 (lambda* (#:key inputs outputs #:allow-other-keys)
1183 (substitute* "tools/firmware/Rules.mk"
1184 (("override XEN_TARGET_ARCH = x86_32")
1185 (string-append "override XEN_TARGET_ARCH = x86_32
1186override CC = " (assoc-ref inputs "cross-gcc") "/bin/i686-linux-gnu-gcc"))
1187 (("^CFLAGS =$")
1188 (string-append "CFLAGS=-I" (assoc-ref inputs "cross-libc")
1189 "/include\n")))
1190 (substitute* "config/x86_32.mk"
1191 (("CFLAGS += -m32 -march=i686")
1192 (string-append "CFLAGS += -march=i686 -I"
1193 (assoc-ref inputs "cross-libc")
1194 "/include")))
35e8900d
DM
1195 ;; /var is not in /gnu/store , so don't try to create it.
1196 (substitute* '("tools/Makefile"
1197 "tools/xenstore/Makefile"
1198 "tools/xenpaging/Makefile")
1199 (("\\$\\(INSTALL_DIR\\) .*XEN_(DUMP|LOG|RUN|LIB|PAGING)_DIR.*")
1200 "\n")
1201 (("\\$\\(INSTALL_DIR\\) .*XEN_(RUN|LIB)_STORED.*")
1202 "\n"))
1203 ;; Prevent xen from creating /etc .
1204 (substitute* "tools/examples/Makefile"
1205 ((" install-readmes") "")
1206 ((" install-configs") ""))
1207 ;; Set rpath.
1208 (substitute* "tools/pygrub/setup.py"
1209 (("library_dirs =")
1210 ; TODO: extra_link_args = ['-Wl,-rpath=/opt/foo'],
1211 (string-append "runtime_library_dirs = ['"
1212 (assoc-ref outputs "out")
1213 "/lib'],\nlibrary_dirs =")))
1214 #t))
1215 (add-before 'configure 'patch-xen-script-directory
1216 (lambda* (#:key outputs #:allow-other-keys)
1217 (substitute* '("configure"
1218 "tools/configure"
1219 "docs/configure")
1220 (("XEN_SCRIPT_DIR=.*")
1221 (string-append "XEN_SCRIPT_DIR="
1222 (assoc-ref outputs "out")
1223 "/etc/xen/scripts")))
1224 #t))
1225 (add-before 'configure 'set-environment-up
1226 (lambda* (#:key make-flags #:allow-other-keys)
1227 (define (cross? x)
1228 (string-contains x "cross-i686-linux"))
1229 (define (filter-environment! filter-predicate
1230 environment-variable-names)
1231 (for-each
1232 (lambda (env-name)
1233 (let* ((env-value (getenv env-name))
1234 (search-path (search-path-as-string->list env-value))
1235 (new-search-path (filter filter-predicate
1236 search-path))
1237 (new-env-value (list->search-path-as-string
1238 new-search-path ":")))
1239 (setenv env-name new-env-value)))
1240 environment-variable-names))
1241 (setenv "CROSS_C_INCLUDE_PATH" (getenv "C_INCLUDE_PATH"))
1242 (setenv "CROSS_CPLUS_INCLUDE_PATH" (getenv "CPLUS_INCLUDE_PATH"))
1243 (setenv "CROSS_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
1244 (filter-environment! cross?
1245 '("CROSS_C_INCLUDE_PATH" "CROSS_CPLUS_INCLUDE_PATH"
1246 "CROSS_LIBRARY_PATH"))
1247 (filter-environment! (lambda (e) (not (cross? e)))
1248 '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"
1249 "LIBRARY_PATH"))
1250 ;; Guix tries to be helpful and automatically adds
1251 ;; mini-os-git-checkout/include to the include path,
1252 ;; but actually we don't want it to be there (yet).
1253 (filter-environment! (lambda (e)
1254 (not
1255 (string-contains e
1256 "mini-os-git-checkout")))
1257 '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"
1258 "LIBRARY_PATH"))
1259 (setenv "EFI_VENDOR" "guix")
1260 #t))
1261 (replace 'build
1262 (lambda* (#:key make-flags #:allow-other-keys)
1263 (apply invoke "make" "world" make-flags))))))
1264 (inputs
1265 `(("acpica" ,acpica) ; TODO: patch iasl invocation.
1266 ("bridge-utils" ,bridge-utils) ; TODO: patch invocations.
1267 ("glib" ,glib)
1268 ("iproute" ,iproute) ; TODO: patch invocations.
1269 ("libaio" ,libaio)
1270 ("libx11" ,libx11)
1271 ("libyajl" ,libyajl)
1272 ("ncurses" ,ncurses)
1273 ("openssl" ,openssl)
1274 ("ovmf" ,ovmf)
1275 ("pixman" ,pixman)
1276 ("qemu" ,qemu-minimal)
1277 ("seabios" ,seabios)
1278 ("util-linux" ,util-linux) ; uuid
1279 ; TODO: ocaml-findlib, ocaml-nox.
1280 ("xz" ,xz) ; for liblzma
1281 ("zlib" ,zlib)))
1282 (native-inputs
1283 `(("dev86" ,dev86)
1284 ("bison" ,bison)
1285 ("cmake" ,cmake)
1286 ("figlet" ,figlet)
1287 ("flex" ,flex)
1288 ("gettext" ,gettext-minimal)
1289 ("libnl" ,libnl)
1290 ("mini-os"
1291 ,(origin
1292 (method git-fetch)
1293 (uri (git-reference
1294 (url "http://xenbits.xen.org/git-http/mini-os.git")
1295 (commit (string-append "xen-RELEASE-" version))))
1296 (sha256
1297 (base32
1298 "1i8pcl19n60i2m9vlg79q3nknpj209c9ic5x10wxaicx45kc107f"))
1299 (file-name "mini-os-git-checkout")))
1300 ("perl" ,perl)
1301 ; TODO: markdown
1302 ("pkg-config" ,pkg-config)
1303 ("python" ,python-2)
1304 ("wget" ,wget)
1305 ("cross-gcc" ,(cross-gcc "i686-linux-gnu"
1306 #:xbinutils (cross-binutils "i686-linux-gnu")
1307 #:libc (cross-libc "i686-linux-gnu")))
1308 ("cross-libc" ,(cross-libc "i686-linux-gnu")) ; header files
1309 ("cross-libc-static" ,(cross-libc "i686-linux-gnu") "static")))
1310 (home-page "https://xenproject.org/")
1311 (synopsis "Xen Virtual Machine Monitor")
1312 (description "This package provides the Xen Virtual Machine Monitor
1313which is a hypervisor.")
1314 ;; TODO: Some files are licensed differently. List those.
1315 (license license:gpl2)
1316 (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux"))))