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