gnu: lxc: Update to 3.0.2.
[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 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 Rutger Helling <rhelling@mykolab.com>
9 ;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
10 ;;; Copyright © 2018 Danny Milosavljevic <dannym@scratchpost.org>
11 ;;; Copyright © 2018 Sou Bunnbu <iyzsong@member.fsf.org>
12 ;;;
13 ;;; This file is part of GNU Guix.
14 ;;;
15 ;;; GNU Guix is free software; you can redistribute it and/or modify it
16 ;;; under the terms of the GNU General Public License as published by
17 ;;; the Free Software Foundation; either version 3 of the License, or (at
18 ;;; your option) any later version.
19 ;;;
20 ;;; GNU Guix is distributed in the hope that it will be useful, but
21 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;;; GNU General Public License for more details.
24 ;;;
25 ;;; You should have received a copy of the GNU General Public License
26 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27
28 (define-module (gnu packages virtualization)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages admin)
31 #:use-module (gnu packages attr)
32 #:use-module (gnu packages autotools)
33 #:use-module (gnu packages bison)
34 #:use-module (gnu packages check)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages curl)
37 #:use-module (gnu packages cyrus-sasl)
38 #:use-module (gnu packages disk)
39 #:use-module (gnu packages dns)
40 #:use-module (gnu packages docbook)
41 #:use-module (gnu packages documentation)
42 #:use-module (gnu packages flex)
43 #:use-module (gnu packages fontutils)
44 #:use-module (gnu packages gettext)
45 #:use-module (gnu packages gl)
46 #:use-module (gnu packages glib)
47 #:use-module (gnu packages gnome)
48 #:use-module (gnu packages gnupg)
49 #:use-module (gnu packages golang)
50 #:use-module (gnu packages gtk)
51 #:use-module (gnu packages image)
52 #:use-module (gnu packages libusb)
53 #:use-module (gnu packages linux)
54 #:use-module (gnu packages ncurses)
55 #:use-module (gnu packages nettle)
56 #:use-module (gnu packages networking)
57 #:use-module (gnu packages package-management)
58 #:use-module (gnu packages perl)
59 #:use-module (gnu packages pkg-config)
60 #:use-module (gnu packages polkit)
61 #:use-module (gnu packages protobuf)
62 #:use-module (gnu packages python)
63 #:use-module (gnu packages python-web)
64 #:use-module (gnu packages pulseaudio)
65 #:use-module (gnu packages selinux)
66 #:use-module (gnu packages sdl)
67 #:use-module (gnu packages spice)
68 #:use-module (gnu packages texinfo)
69 #:use-module (gnu packages textutils)
70 #:use-module (gnu packages tls)
71 #:use-module (gnu packages web)
72 #:use-module (gnu packages xdisorg)
73 #:use-module (gnu packages xml)
74 #:use-module (guix build-system gnu)
75 #:use-module (guix build-system go)
76 #:use-module (guix build-system python)
77 #:use-module (guix download)
78 #:use-module (guix git-download)
79 #:use-module ((guix licenses) #:prefix license:)
80 #:use-module (guix packages)
81 #:use-module (guix utils)
82 #:use-module (srfi srfi-1))
83
84 (define (qemu-patch commit file-name sha256)
85 "Return an origin for COMMIT."
86 (origin
87 (method url-fetch)
88 (uri (string-append
89 "http://git.qemu.org/?p=qemu.git;a=commitdiff_plain;h="
90 commit))
91 (sha256 sha256)
92 (file-name file-name)))
93
94 (define-public qemu
95 (package
96 (name "qemu")
97 (version "3.0.0")
98 (source (origin
99 (method url-fetch)
100 (uri (string-append "https://download.qemu.org/qemu-"
101 version ".tar.xz"))
102 (sha256
103 (base32
104 "04sp3f1gp4bdb913jf7fw761njaqp2l32wgipp1sapmxx17zcyld"))))
105 (build-system gnu-build-system)
106 (arguments
107 '(;; Running tests in parallel can occasionally lead to failures, like:
108 ;; boot_sector_test: assertion failed (signature == SIGNATURE): (0x00000000 == 0x0000dead)
109 #:parallel-tests? #f
110 #:configure-flags (list "--enable-usb-redir" "--enable-opengl"
111 (string-append "--smbd="
112 (assoc-ref %outputs "out")
113 "/libexec/samba-wrapper")
114 "--audio-drv-list=alsa,pa,sdl")
115 #:phases
116 (modify-phases %standard-phases
117 (replace 'configure
118 (lambda* (#:key inputs outputs (configure-flags '())
119 #:allow-other-keys)
120 ;; The `configure' script doesn't understand some of the
121 ;; GNU options. Thus, add a new phase that's compatible.
122 (let ((out (assoc-ref outputs "out")))
123 (setenv "SHELL" (which "bash"))
124
125 ;; While we're at it, patch for tests.
126 (substitute* "tests/libqtest.c"
127 (("/bin/sh") (which "sh")))
128
129 ;; The binaries need to be linked against -lrt.
130 (setenv "LDFLAGS" "-lrt")
131 (apply invoke
132 `("./configure"
133 ,(string-append "--cc=" (which "gcc"))
134 ;; Some architectures insist on using HOST_CC
135 ,(string-append "--host-cc=" (which "gcc"))
136 "--disable-debug-info" ; save build space
137 "--enable-virtfs" ; just to be sure
138 ,(string-append "--prefix=" out)
139 ,(string-append "--sysconfdir=/etc")
140 ,@configure-flags)))))
141 (add-after 'install 'install-info
142 (lambda* (#:key inputs outputs #:allow-other-keys)
143 ;; Install the Info manual, unless Texinfo is missing.
144 (when (assoc-ref inputs "texinfo")
145 (let* ((out (assoc-ref outputs "out"))
146 (dir (string-append out "/share/info")))
147 (invoke "make" "info")
148 (for-each (lambda (info)
149 (install-file info dir))
150 (find-files "." "\\.info"))))
151 #t))
152 ;; Create a wrapper for Samba. This allows QEMU to use Samba without
153 ;; pulling it in as an input. Note that you need to explicitly install
154 ;; Samba in your Guix profile for Samba support.
155 (add-after 'install-info 'create-samba-wrapper
156 (lambda* (#:key inputs outputs #:allow-other-keys)
157 (let* ((out (assoc-ref %outputs "out"))
158 (libexec (string-append out "/libexec")))
159 (call-with-output-file "samba-wrapper"
160 (lambda (port)
161 (format port "#!/bin/sh
162 exec smbd $@")))
163 (chmod "samba-wrapper" #o755)
164 (install-file "samba-wrapper" libexec))
165 #t))
166 (add-before 'check 'make-gtester-verbose
167 (lambda _
168 ;; Make GTester verbose to facilitate investigation upon failure.
169 (setenv "V" "1") #t))
170 (add-before 'check 'disable-test-qga
171 (lambda _
172 (substitute* "tests/Makefile.include"
173 ;; Comment out the test-qga test, which needs /sys and
174 ;; fails within the build environment.
175 (("check-unit-.* tests/test-qga" all)
176 (string-append "# " all)))
177 #t)))))
178 (inputs ; TODO: Add optional inputs.
179 `(("alsa-lib" ,alsa-lib)
180 ("attr" ,attr)
181 ("glib" ,glib)
182 ("gtk+" ,gtk+)
183 ("libaio" ,libaio)
184 ("libattr" ,attr)
185 ("libcap" ,libcap) ; virtfs support requires libcap & libattr
186 ("libdrm" ,libdrm)
187 ("libepoxy" ,libepoxy)
188 ("libjpeg" ,libjpeg-turbo)
189 ("libpng" ,libpng)
190 ("libseccomp" ,libseccomp)
191 ("libusb" ,libusb) ;USB pass-through support
192 ("mesa" ,mesa)
193 ("ncurses" ,ncurses)
194 ;; ("pciutils" ,pciutils)
195 ("pixman" ,pixman)
196 ("pulseaudio" ,pulseaudio)
197 ("sdl2" ,sdl2)
198 ("spice" ,spice)
199 ("usbredir" ,usbredir)
200 ("util-linux" ,util-linux)
201 ;; ("vde2" ,vde2)
202 ("virglrenderer" ,virglrenderer)
203 ("zlib" ,zlib)))
204 (native-inputs `(("gettext" ,gettext-minimal)
205 ("glib:bin" ,glib "bin") ; gtester, etc.
206 ("perl" ,perl)
207 ("flex" ,flex)
208 ("bison" ,bison)
209 ("pkg-config" ,pkg-config)
210 ("python-wrapper" ,python-wrapper)
211 ("texinfo" ,texinfo)))
212 (home-page "https://www.qemu.org")
213 (synopsis "Machine emulator and virtualizer")
214 (description
215 "QEMU is a generic machine emulator and virtualizer.
216
217 When used as a machine emulator, QEMU can run OSes and programs made for one
218 machine (e.g. an ARM board) on a different machine---e.g., your own PC. By
219 using dynamic translation, it achieves very good performance.
220
221 When used as a virtualizer, QEMU achieves near native performances by
222 executing the guest code directly on the host CPU. QEMU supports
223 virtualization when executing under the Xen hypervisor or using
224 the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86,
225 server and embedded PowerPC, and S390 guests.")
226
227 ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
228 (license license:gpl2)
229
230 ;; Several tests fail on MIPS; see <http://hydra.gnu.org/build/117914>.
231 (supported-systems (delete "mips64el-linux" %supported-systems))))
232
233 (define-public qemu-minimal
234 ;; QEMU without GUI support.
235 (package (inherit qemu)
236 (name "qemu-minimal")
237 (synopsis "Machine emulator and virtualizer (without GUI)")
238 (arguments
239 (substitute-keyword-arguments (package-arguments qemu)
240 ((#:configure-flags _ '(list))
241 ;; Restrict to the targets supported by Guix.
242 ''("--target-list=i386-softmmu,x86_64-softmmu,mips64el-softmmu,arm-softmmu,aarch64-softmmu"))))
243
244 ;; Remove dependencies on optional libraries, notably GUI libraries.
245 (native-inputs (fold alist-delete (package-native-inputs qemu)
246 '("gettext")))
247 (inputs (fold alist-delete (package-inputs qemu)
248 '("libusb" "mesa" "sdl2" "spice" "virglrenderer" "gtk+"
249 "usbredir" "libdrm" "libepoxy" "pulseaudio")))))
250
251 ;; The GRUB test suite fails with later versions of Qemu, so we
252 ;; keep it at 2.10 for now. See
253 ;; <https://lists.gnu.org/archive/html/bug-grub/2018-02/msg00004.html>.
254 ;; This package is hidden since we do not backport updates to it.
255 (define-public qemu-minimal-2.10
256 (hidden-package
257 (package
258 (inherit qemu-minimal)
259 (version "2.10.2")
260 (source (origin
261 (method url-fetch)
262 (uri (string-append "https://download.qemu.org/qemu-"
263 version ".tar.xz"))
264 (sha256
265 (base32
266 "17w21spvaxaidi2am5lpsln8yjpyp2zi3s3gc6nsxj5arlgamzgw"))
267 (patches
268 (search-patches "qemu-glibc-2.27.patch"))))
269 ;; qemu-minimal-2.10 needs Python 2. Remove below once no longer necessary.
270 (native-inputs `(("python-2" ,python-2)
271 ,@(fold alist-delete (package-native-inputs qemu)
272 '("python-wrapper")))))))
273
274 (define-public libosinfo
275 (package
276 (name "libosinfo")
277 (version "1.0.0")
278 (source
279 (origin
280 (method url-fetch)
281 (uri (string-append "https://releases.pagure.org/libosinfo/libosinfo-"
282 version ".tar.gz"))
283 (sha256
284 (base32
285 "0srrs2m6irqd4f867g8ls6jp2dq3ql0l9d0fh80d55sivvn2bd7p"))))
286 (build-system gnu-build-system)
287 (arguments
288 `(#:configure-flags
289 (list (string-append "--with-usb-ids-path="
290 (assoc-ref %build-inputs "usb.ids"))
291 (string-append "--with-pci-ids-path="
292 (assoc-ref %build-inputs "pci.ids")))
293 #:phases
294 (modify-phases %standard-phases
295 ;; This odd test fails for unknown reasons.
296 (add-after 'unpack 'disable-broken-test
297 (lambda _
298 (substitute* "test/Makefile.in"
299 (("test-isodetect\\$\\(EXEEXT\\)") ""))
300 #t)))))
301 (inputs
302 `(("libsoup" ,libsoup)
303 ("libxml2" ,libxml2)
304 ("libxslt" ,libxslt)
305 ("gobject-introspection" ,gobject-introspection)))
306 (native-inputs
307 `(("check" ,check)
308 ("glib" ,glib "bin") ; glib-mkenums, etc.
309 ("gtk-doc" ,gtk-doc)
310 ("vala" ,vala)
311 ("intltool" ,intltool)
312 ("pkg-config" ,pkg-config)
313 ("pci.ids"
314 ,(origin
315 (method url-fetch)
316 (uri "https://github.com/pciutils/pciids/raw/ad02084f0bc143e3c15e31a6152a3dfb1d7a3156/pci.ids")
317 (sha256
318 (base32
319 "0kfhpj5rnh24hz2714qhfmxk281vwc2w50sm73ggw5d15af7zfsw"))))
320 ("usb.ids"
321 ,(origin
322 (method url-fetch)
323 (uri "https://svn.code.sf.net/p/linux-usb/repo/trunk/htdocs/usb.ids?r=2681")
324 (file-name "usb.ids")
325 (sha256
326 (base32
327 "1m6yhvz5k8aqzxgk7xj3jkk8frl1hbv0h3vgj4wbnvnx79qnvz3r"))))))
328 (home-page "https://libosinfo.org/")
329 (synopsis "Operating system information database")
330 (description "libosinfo is a GObject based library API for managing
331 information about operating systems, hypervisors and the (virtual) hardware
332 devices they can support. It includes a database containing device metadata
333 and provides APIs to match/identify optimal devices for deploying an operating
334 system on a hypervisor. Via GObject Introspection, the API is available in
335 all common programming languages. Vala bindings are also provided.")
336 ;; The library files are released under LGPLv2.1 or later; the source
337 ;; files in the "tools" directory are released under GPLv2+.
338 (license (list license:lgpl2.1+ license:gpl2+))))
339
340 (define-public lxc
341 (package
342 (name "lxc")
343 (version "3.0.2")
344 (source (origin
345 (method url-fetch)
346 (uri (string-append
347 "https://linuxcontainers.org/downloads/lxc/lxc-"
348 version ".tar.gz"))
349 (sha256
350 (base32
351 "0p1gy553cm4mhwxi85fl6qiwz61rjmvysm8c8pd20qh62xxi3dva"))))
352 (build-system gnu-build-system)
353 (native-inputs
354 `(("pkg-config" ,pkg-config)))
355 (inputs
356 `(("gnutls" ,gnutls)
357 ("libcap" ,libcap)
358 ("libseccomp" ,libseccomp)
359 ("libselinux" ,libselinux)))
360 (arguments
361 '(#:configure-flags
362 '("--sysconfdir=/etc"
363 "--localstatedir=/var")
364 #:phases
365 (modify-phases %standard-phases
366 (replace 'install
367 (lambda* (#:key outputs #:allow-other-keys)
368 (let* ((out (assoc-ref outputs "out"))
369 (bashcompdir (string-append out "/etc/bash_completion.d")))
370 (invoke "make" "install"
371 (string-append "bashcompdir=" bashcompdir)
372 ;; Don't install files into /var and /etc.
373 "LXCPATH=/tmp/var/lib/lxc"
374 "localstatedir=/tmp/var"
375 "sysconfdir=/tmp/etc"
376 "sysconfigdir=/tmp/etc/default")))))))
377 (synopsis "Linux container tools")
378 (home-page "https://linuxcontainers.org/")
379 (description
380 "LXC is a userspace interface for the Linux kernel containment features.
381 Through a powerful API and simple tools, it lets Linux users easily create and
382 manage system or application containers.")
383 (license license:lgpl2.1+)))
384
385 (define-public libvirt
386 (package
387 (name "libvirt")
388 (version "4.3.0")
389 (source (origin
390 (method url-fetch)
391 (uri (string-append "https://libvirt.org/sources/libvirt-"
392 version ".tar.xz"))
393 (sha256
394 (base32
395 "1dy243dqaj174hcka0my7q781wf0dvyi7f9328nwnplqicnf4cd5"))))
396 (build-system gnu-build-system)
397 (arguments
398 `(;; FAIL: virshtest
399 ;; FAIL: virfirewalltest
400 ;; FAIL: virkmodtest
401 ;; FAIL: virnetsockettest
402 ;; FAIL: networkxml2firewalltest
403 ;; FAIL: nwfilterebiptablestest
404 ;; FAIL: nwfilterxml2firewalltest
405 ;; Time-out while running commandtest.
406 #:tests? #f
407 #:configure-flags
408 (list "--with-polkit"
409 "--sysconfdir=/etc"
410 "--localstatedir=/var")
411 #:phases
412 (modify-phases %standard-phases
413 (add-after 'unpack 'fix-tests
414 (lambda _
415 (substitute* '("tests/commandtest.c"
416 "gnulib/tests/test-posix_spawn1.c"
417 "gnulib/tests/test-posix_spawn2.c")
418 (("/bin/sh") (which "sh")))
419 #t))
420 (replace 'install
421 ;; Since the sysconfdir and localstatedir should be /etc and /var
422 ;; at runtime, we must prevent writing to them at installation
423 ;; time.
424 (lambda _
425 (invoke "make" "install"
426 "sysconfdir=/tmp/etc"
427 "localstatedir=/tmp/var")))
428 (add-after 'install 'wrap-libvirtd
429 (lambda* (#:key inputs outputs #:allow-other-keys)
430 (let ((out (assoc-ref outputs "out")))
431 (wrap-program (string-append out "/sbin/libvirtd")
432 `("PATH" = (,(string-append (assoc-ref inputs "iproute")
433 "/sbin")
434 ,(string-append (assoc-ref inputs "qemu")
435 "/bin"))))
436 #t))))))
437 (inputs
438 `(("libxml2" ,libxml2)
439 ("gnutls" ,gnutls)
440 ("dbus" ,dbus)
441 ("qemu" ,qemu)
442 ("libpcap" ,libpcap)
443 ("libnl" ,libnl)
444 ("libuuid" ,util-linux)
445 ("lvm2" ,lvm2) ; for libdevmapper
446 ("curl" ,curl)
447 ("openssl" ,openssl)
448 ("cyrus-sasl" ,cyrus-sasl)
449 ("libyajl" ,libyajl)
450 ("audit" ,audit)
451 ("dmidecode" ,dmidecode)
452 ("dnsmasq" ,dnsmasq)
453 ("ebtables" ,ebtables)
454 ("iproute" ,iproute)
455 ("iptables" ,iptables)))
456 (native-inputs
457 `(("xsltproc" ,libxslt)
458 ("perl" ,perl)
459 ("pkg-config" ,pkg-config)
460 ("polkit" ,polkit)
461 ("python" ,python)))
462 (home-page "https://libvirt.org")
463 (synopsis "Simple API for virtualization")
464 (description "Libvirt is a C toolkit to interact with the virtualization
465 capabilities of recent versions of Linux. The library aims at providing long
466 term stable C API initially for the Xen paravirtualization but should be able
467 to integrate other virtualization mechanisms if needed.")
468 (license license:lgpl2.1+)))
469
470 (define-public libvirt-glib
471 (package
472 (name "libvirt-glib")
473 (version "1.0.0")
474 (source (origin
475 (method url-fetch)
476 (uri (string-append "ftp://libvirt.org/libvirt/glib/"
477 "libvirt-glib-" version ".tar.gz"))
478 (sha256
479 (base32
480 "0iwa5sdbii52pjpdm5j37f67sdmf0kpcky4liwhy1nf43k85i4fa"))))
481 (build-system gnu-build-system)
482 (arguments
483 `(#:phases
484 (modify-phases %standard-phases
485 (add-after 'unpack 'fix-tests
486 (lambda _
487 (substitute* "tests/test-events.c"
488 (("/bin/true") (which "true")))
489 #t)))))
490 (inputs
491 `(("libxml2" ,libxml2)
492 ("libvirt" ,libvirt)
493 ("gobject-introspection" ,gobject-introspection)
494 ("glib" ,glib)
495 ("openssl" ,openssl)
496 ("cyrus-sasl" ,cyrus-sasl)
497 ("lvm2" ,lvm2) ; for libdevmapper
498 ("libyajl" ,libyajl)))
499 (native-inputs
500 `(("pkg-config" ,pkg-config)
501 ("intltool" ,intltool)
502 ("glib" ,glib "bin")
503 ("vala" ,vala)))
504 (home-page "https://libvirt.org")
505 (synopsis "GLib wrapper around libvirt")
506 (description "libvirt-glib wraps the libvirt library to provide a
507 high-level object-oriented API better suited for glib-based applications, via
508 three libraries:
509
510 @enumerate
511 @item libvirt-glib - GLib main loop integration & misc helper APIs
512 @item libvirt-gconfig - GObjects for manipulating libvirt XML documents
513 @item libvirt-gobject - GObjects for managing libvirt objects
514 @end enumerate
515 ")
516 (license license:lgpl2.1+)))
517
518 (define-public python-libvirt
519 (package
520 (name "python-libvirt")
521 (version "4.1.0")
522 (source (origin
523 (method url-fetch)
524 (uri (pypi-uri "libvirt-python" version))
525 (sha256
526 (base32
527 "1ixqhxjkczl8vk9wjx4cknw4374cw5nnsacbd2s755kpd0ys7hny"))))
528 (build-system python-build-system)
529 (arguments
530 `(#:phases
531 (modify-phases %standard-phases
532 (add-after 'unpack 'patch-nosetests-path
533 (lambda* (#:key inputs #:allow-other-keys)
534 (substitute* "setup.py"
535 (("\"/usr/bin/nosetests\"")
536 (string-append "\"" (which "nosetests") "\""))
537 (("self\\.spawn\\(\\[sys\\.executable, nose\\]\\)")
538 (format #f "self.spawn([\"~a\", nose])" (which "bash"))))
539 #t)))))
540 (inputs
541 `(("libvirt" ,libvirt)))
542 (propagated-inputs
543 `(("python-lxml" ,python-lxml)))
544 (native-inputs
545 `(("pkg-config" ,pkg-config)
546 ("python-nose" ,python-nose)))
547 (home-page "https://libvirt.org")
548 (synopsis "Python bindings to libvirt")
549 (description "This package provides Python bindings to the libvirt
550 virtualization library.")
551 (license license:lgpl2.1+)))
552
553 (define-public python2-libvirt
554 (package-with-python2 python-libvirt))
555
556 (define-public virt-manager
557 (package
558 (name "virt-manager")
559 (version "1.5.1")
560 (source (origin
561 (method url-fetch)
562 (uri (string-append "https://virt-manager.org/download/sources"
563 "/virt-manager/virt-manager-"
564 version ".tar.gz"))
565 (sha256
566 (base32
567 "1ardmd4sxdmd57y7qpka44gf09c1yq2g0xs074d3k1h925crv27f"))))
568 (build-system python-build-system)
569 (arguments
570 `(#:python ,python-2
571 #:use-setuptools? #f ; Uses custom distutils 'install' command.
572 ;; Some of the tests seem to require network access to install virtual
573 ;; machines.
574 #:tests? #f
575 #:imported-modules ((guix build glib-or-gtk-build-system)
576 ,@%python-build-system-modules)
577 #:modules ((ice-9 match)
578 (srfi srfi-26)
579 (guix build python-build-system)
580 ((guix build glib-or-gtk-build-system) #:prefix glib-or-gtk:)
581 (guix build utils))
582 #:phases
583 (modify-phases %standard-phases
584 (add-after 'unpack 'fix-setup
585 (lambda* (#:key outputs #:allow-other-keys)
586 (substitute* "virtcli/cliconfig.py"
587 (("/usr") (assoc-ref outputs "out")))
588 #t))
589 (add-after 'unpack 'fix-default-uri
590 (lambda* (#:key inputs #:allow-other-keys)
591 ;; xen is not available for now - so only patch qemu
592 (substitute* "virtManager/connect.py"
593 (("/usr(/bin/qemu-system)" _ suffix)
594 (string-append (assoc-ref inputs "qemu") suffix)))
595 #t))
596 (add-before 'wrap 'wrap-with-GI_TYPELIB_PATH
597 (lambda* (#:key inputs outputs #:allow-other-keys)
598 (let* ((bin (string-append (assoc-ref outputs "out") "/bin"))
599 (bin-files (find-files bin ".*"))
600 (paths (map (match-lambda
601 ((output . directory)
602 (let* ((girepodir (string-append
603 directory
604 "/lib/girepository-1.0")))
605 (if (file-exists? girepodir)
606 girepodir #f))))
607 inputs)))
608 (for-each (lambda (file)
609 (format #t "wrapping ~a\n" file)
610 (wrap-program file
611 `("GI_TYPELIB_PATH" ":" prefix
612 ,(filter identity paths))))
613 bin-files))
614 #t))
615 (add-after 'install 'glib-or-gtk-compile-schemas
616 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
617 (add-after 'install 'glib-or-gtk-wrap
618 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap)))))
619 (inputs
620 `(("dconf" ,dconf)
621 ("gtk+" ,gtk+)
622 ("gtk-vnc" ,gtk-vnc)
623 ("libvirt" ,libvirt)
624 ("libvirt-glib" ,libvirt-glib)
625 ("libosinfo" ,libosinfo)
626 ("vte" ,vte)
627 ("gobject-introspection" ,gobject-introspection)
628 ("python2-libvirt" ,python2-libvirt)
629 ("python2-requests" ,python2-requests)
630 ("python2-ipaddr" ,python2-ipaddr)
631 ("python2-pycairo" ,python2-pycairo)
632 ("python2-pygobject" ,python2-pygobject)
633 ("python2-libxml2" ,python2-libxml2)
634 ("spice-gtk" ,spice-gtk)))
635 ;; virt-manager searches for qemu-img or kvm-img in the PATH.
636 (propagated-inputs
637 `(("qemu" ,qemu)))
638 (native-inputs
639 `(("glib" ,glib "bin") ; glib-compile-schemas.
640 ("gtk+" ,gtk+ "bin") ; gtk-update-icon-cache
641 ("perl" ,perl) ; pod2man
642 ("intltool" ,intltool)))
643 (home-page "https://virt-manager.org/")
644 (synopsis "Manage virtual machines")
645 (description
646 "The virt-manager application is a desktop user interface for managing
647 virtual machines through libvirt. It primarily targets KVM VMs, but also
648 manages Xen and LXC (Linux containers). It presents a summary view of running
649 domains, their live performance and resource utilization statistics.")
650 (license license:gpl2+)))
651
652 (define-public criu
653 (package
654 (name "criu")
655 (version "3.7")
656 (source (origin
657 (method url-fetch)
658 (uri (string-append "http://download.openvz.org/criu/criu-"
659 version ".tar.bz2"))
660 (sha256
661 (base32
662 "0qrpz7pvnks34v7d8lb73flz3mb7qwnib94pdwaxh0mskn8470fq"))))
663 (build-system gnu-build-system)
664 (arguments
665 `(#:test-target "test"
666 #:tests? #f ; tests require mounting as root
667 #:make-flags
668 (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
669 (string-append "LIBDIR=" (assoc-ref %outputs "out")
670 "/lib"))
671 #:phases
672 (modify-phases %standard-phases
673 (replace 'configure
674 (lambda* (#:key inputs #:allow-other-keys)
675 ;; The includes for libnl are located in a sub-directory.
676 (setenv "C_INCLUDE_PATH"
677 (string-append (assoc-ref inputs "libnl")
678 "/include/libnl3:"
679 (getenv "C_INCLUDE_PATH")))
680 ;; Prevent xmlto from failing the install phase.
681 (substitute* "Documentation/Makefile"
682 (("XMLTO.*:=.*")
683 (string-append "XMLTO:="
684 (assoc-ref inputs "xmlto")
685 "/bin/xmlto"
686 " --skip-validation "
687 " -x "
688 (assoc-ref inputs "docbook-xsl")
689 "/xml/xsl/docbook-xsl-"
690 ,(package-version docbook-xsl)
691 "/manpages/docbook.xsl")))
692 #t))
693 (add-before 'build 'fix-symlink
694 (lambda* (#:key inputs #:allow-other-keys)
695 ;; The file 'images/google/protobuf/descriptor.proto' points to
696 ;; /usr/include/..., which obviously does not exist.
697 (let* ((file "google/protobuf/descriptor.proto")
698 (target (string-append "images/" file))
699 (source (string-append (assoc-ref inputs "protobuf")
700 "/include/" file)))
701 (delete-file target)
702 (symlink source target)
703 #t)))
704 (add-after 'install 'wrap
705 (lambda* (#:key inputs outputs #:allow-other-keys)
706 ;; Make sure 'crit' runs with the correct PYTHONPATH.
707 (let* ((out (assoc-ref outputs "out"))
708 (path (string-append out
709 "/lib/python"
710 (string-take (string-take-right
711 (assoc-ref inputs "python") 5) 3)
712 "/site-packages:"
713 (getenv "PYTHONPATH"))))
714 (wrap-program (string-append out "/bin/crit")
715 `("PYTHONPATH" ":" prefix (,path))))
716 #t)))))
717 (inputs
718 `(("protobuf" ,protobuf)
719 ("python" ,python-2)
720 ("python2-protobuf" ,python2-protobuf)
721 ("python2-ipaddr" ,python2-ipaddr)
722 ("iproute" ,iproute)
723 ("libaio" ,libaio)
724 ("libcap" ,libcap)
725 ("libnet" ,libnet)
726 ("libnl" ,libnl)))
727 (native-inputs
728 `(("pkg-config" ,pkg-config)
729 ("perl" ,perl)
730 ("protobuf-c" ,protobuf-c)
731 ("asciidoc" ,asciidoc)
732 ("xmlto" ,xmlto)
733 ("docbook-xml" ,docbook-xml)
734 ("docbook-xsl" ,docbook-xsl)))
735 (home-page "https://criu.org")
736 (synopsis "Checkpoint and restore in user space")
737 (description "Using this tool, you can freeze a running application (or
738 part of it) and checkpoint it to a hard drive as a collection of files. You
739 can then use the files to restore and run the application from the point it
740 was frozen at. The distinctive feature of the CRIU project is that it is
741 mainly implemented in user space.")
742 ;; The project is licensed under GPLv2; files in the lib/ directory are
743 ;; LGPLv2.1.
744 (license (list license:gpl2 license:lgpl2.1))))
745
746 (define-public qmpbackup
747 (package
748 (name "qmpbackup")
749 (version "0.2")
750 (source (origin
751 (method url-fetch)
752 (uri (string-append "https://github.com/abbbi/qmpbackup/archive/"
753 version ".tar.gz"))
754 (sha256
755 (base32
756 "10k9mnb1yrg4gw1rvz4kw4dxc4aajl8gnjrpm3axqkg63qmxj3qn"))
757 (file-name (string-append name "-" version ".tar.gz"))))
758 (build-system python-build-system)
759 (arguments
760 `(#:python ,python-2))
761 (home-page "https://github.com/abbbi/qmpbackup")
762 (synopsis "Backup and restore QEMU machines")
763 (description "qmpbackup is designed to create and restore full and
764 incremental backups of running QEMU virtual machines via QMP, the QEMU
765 Machine Protocol.")
766 (license license:gpl3+)))
767
768 (define-public lookingglass
769 (package
770 (name "lookingglass")
771 (version "a11")
772 (source
773 (origin
774 (method url-fetch)
775 (uri (string-append "https://github.com/gnif/LookingGlass/archive/"
776 version ".tar.gz"))
777 (file-name (string-append name "-" version))
778 (sha256
779 (base32
780 "11qwyp332l66sqksqa0z9439yi4accmbq7wjc6kikc5fimdh9wk5"))))
781 (build-system gnu-build-system)
782 (inputs `(("fontconfig" ,fontconfig)
783 ("glu" ,glu)
784 ("mesa" ,mesa)
785 ("openssl" ,openssl)
786 ("sdl2" ,sdl2)
787 ("sdl2-ttf" ,sdl2-ttf)
788 ("spice-protocol" ,spice-protocol)))
789 (native-inputs `(("libconfig" ,libconfig)
790 ("nettle" ,nettle)
791 ("pkg-config" ,pkg-config)))
792 (arguments
793 `(#:tests? #f ;; No tests are available.
794 #:make-flags '("CC=gcc")
795 #:phases (modify-phases %standard-phases
796 (replace 'configure
797 (lambda* (#:key outputs #:allow-other-keys)
798 (chdir "client")
799 #t))
800 (replace 'install
801 (lambda* (#:key outputs #:allow-other-keys)
802 (install-file "bin/looking-glass-client"
803 (string-append (assoc-ref outputs "out")
804 "/bin"))
805 #t)))))
806 (home-page "https://looking-glass.hostfission.com")
807 (synopsis "KVM Frame Relay (KVMFR) implementation")
808 (description "Looking Glass allows the use of a KVM (Kernel-based Virtual
809 Machine) configured for VGA PCI Pass-through without an attached physical
810 monitor, keyboard or mouse. It displays the VM's rendered contents on your main
811 monitor/GPU.")
812 ;; This package requires SSE instructions.
813 (supported-systems '("i686-linux" "x86_64-linux"))
814 (license license:gpl2+)))
815
816 (define-public runc
817 (package
818 (name "runc")
819 (version "1.0.0-rc5")
820 (source (origin
821 (method url-fetch)
822 (uri (string-append
823 "https://github.com/opencontainers/runc/releases/"
824 "download/v" version "/runc.tar.xz"))
825 (sha256
826 (base32
827 "081avdzwnqpk368wbaihlzsypaxpj42d7699h7jgp0fks14x4103"))))
828 (build-system go-build-system)
829 (arguments
830 '(#:import-path "github.com/opencontainers/runc"
831 #:install-source? #f
832 ;; XXX: 20/139 tests fail due to missing /var, cgroups and apparmor in
833 ;; the build environment.
834 #:tests? #f
835 #:phases
836 (modify-phases %standard-phases
837 (replace 'unpack
838 (lambda* (#:key source import-path #:allow-other-keys)
839 ;; Unpack the tarball into 'runc' instead of 'runc-1.0.0-rc5'.
840 (let ((dest (string-append "src/" import-path)))
841 (mkdir-p dest)
842 (invoke "tar" "-C" (string-append "src/" import-path)
843 "--strip-components=1"
844 "-xvf" source))))
845 (replace 'build
846 (lambda* (#:key import-path #:allow-other-keys)
847 (chdir (string-append "src/" import-path))
848 ;; XXX: requires 'go-md2man'.
849 ;; (invoke "make" "man")
850 (invoke "make")))
851 ;; (replace 'check
852 ;; (lambda _
853 ;; (invoke "make" "localunittest")))
854 (replace 'install
855 (lambda* (#:key outputs #:allow-other-keys)
856 (let ((out (assoc-ref outputs "out")))
857 (invoke "make" "install" "install-bash"
858 (string-append "PREFIX=" out))))))))
859 (native-inputs
860 `(("pkg-config" ,pkg-config)))
861 (inputs
862 `(("libseccomp" ,libseccomp)))
863 (synopsis "Open container initiative runtime")
864 (home-page "https://www.opencontainers.org/")
865 (description
866 "@command{runc} is a command line client for running applications
867 packaged according to the
868 @uref{https://github.com/opencontainers/runtime-spec/blob/master/spec.md, Open
869 Container Initiative (OCI) format} and is a compliant implementation of the
870 Open Container Initiative specification.")
871 (license license:asl2.0)))
872
873 (define-public umoci
874 (package
875 (name "umoci")
876 (version "0.4.0")
877 (source (origin
878 (method url-fetch)
879 (uri (string-append
880 "https://github.com/openSUSE/umoci/releases/download/v"
881 version "/umoci.tar.xz"))
882 (file-name (string-append "umoci-" version ".tar.xz"))
883 (sha256
884 (base32
885 "0hg7hs4dagj2fgymm4b4s68k1v2k2093s3jg0d94j0ixhfmyg9nd"))))
886 (build-system go-build-system)
887 (arguments
888 '(#:import-path "github.com/openSUSE/umoci"
889 #:install-source? #f
890 #:phases
891 (modify-phases %standard-phases
892 (replace 'unpack
893 (lambda* (#:key source import-path #:allow-other-keys)
894 ;; Unpack the tarball into 'umoci' instead of "runc-${version}".
895 (let ((dest (string-append "src/" import-path)))
896 (mkdir-p dest)
897 (invoke "tar" "-C" (string-append "src/" import-path)
898 "--strip-components=1"
899 "-xvf" source))))
900 (replace 'build
901 (lambda* (#:key import-path #:allow-other-keys)
902 (chdir (string-append "src/" import-path))
903 ;; TODO: build manpages with 'go-md2man'.
904 (invoke "make" "SHELL=bash")))
905 (replace 'install
906 (lambda* (#:key outputs #:allow-other-keys)
907 (let* ((out (assoc-ref outputs "out"))
908 (bindir (string-append out "/bin")))
909 (install-file "umoci" bindir)
910 #t))))))
911 (home-page "https://umo.ci/")
912 (synopsis "Tool for modifying Open Container images")
913 (description
914 "@command{umoci} is a tool that allows for high-level modification of an
915 Open Container Initiative (OCI) image layout and its tagged images.")
916 (license license:asl2.0)))
917
918 (define-public skopeo
919 (package
920 (name "skopeo")
921 (version "0.1.28")
922 (source (origin
923 (method git-fetch)
924 (uri (git-reference
925 (url "https://github.com/projectatomic/skopeo")
926 (commit (string-append "v" version))))
927 (file-name (git-file-name name version))
928 (sha256
929 (base32
930 "068nwrr3nr27alravcq1sxyhdd5jjr24213vdgn1dqva3885gbi0"))))
931 (build-system go-build-system)
932 (native-inputs
933 `(("pkg-config" ,pkg-config)))
934 (inputs
935 `(("btrfs-progs" ,btrfs-progs)
936 ("eudev" ,eudev)
937 ("libassuan" ,libassuan)
938 ("libselinux" ,libselinux)
939 ("libostree" ,libostree)
940 ("lvm2" ,lvm2)
941 ("glib" ,glib)
942 ("gpgme" ,gpgme)))
943 (arguments
944 '(#:import-path "github.com/projectatomic/skopeo"
945 #:install-source? #f
946 #:phases
947 (modify-phases %standard-phases
948 (replace 'build
949 (lambda* (#:key import-path #:allow-other-keys)
950 (chdir (string-append "src/" import-path))
951 ;; TODO: build manpages with 'go-md2man'.
952 (invoke "make" "binary-local")))
953 (replace 'install
954 (lambda* (#:key outputs #:allow-other-keys)
955 (let ((out (assoc-ref outputs "out")))
956 (invoke "make" "install-binary" "install-completions"
957 (string-append "PREFIX=" out))))))))
958 (home-page "https://github.com/projectatomic/skopeo")
959 (synopsis "Interact with container images and container image registries")
960 (description
961 "@command{skopeo} is a command line utility providing various operations
962 with container images and container image registries. It can:
963 @enumerate
964
965 @item Copy container images between various containers image stores,
966 converting them as necessary.
967
968 @item Convert a Docker schema 2 or schema 1 container image to an OCI image.
969
970 @item Inspect a repository on a container registry without needlessly pulling
971 the image.
972
973 @item Sign and verify container images.
974
975 @item Delete container images from a remote container registry.
976
977 @end enumerate")
978 (license license:asl2.0)))
979
980 (define-public python-vagrant
981 (package
982 (name "python-vagrant")
983 (version "0.5.15")
984 (source
985 (origin
986 (method url-fetch)
987 (uri (pypi-uri "python-vagrant" version))
988 (sha256
989 (base32
990 "1ikrh6canhcxg5y7pzmkcnnydikppv7s6sm9prfx90nk0ac8m6mg"))))
991 (build-system python-build-system)
992 (arguments
993 '(#:tests? #f)) ; tests involve running vagrant.
994 (home-page "https://github.com/todddeluca/python-vagrant")
995 (synopsis "Python bindings for Vagrant")
996 (description
997 "Python-vagrant is a Python module that provides a thin wrapper around the
998 @code{vagrant} command line executable, allowing programmatic control of Vagrant
999 virtual machines.")
1000 (license license:expat)))