gnu: libdvdcss: Update to 1.4.3.
[jackhill/guix/guix.git] / gnu / packages / virtualization.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2020 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015, 2016, 2017, 2018 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2016, 2017, 2018. 2019, 2020 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–2021 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 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
15 ;;; Copyright © 2020, 2021 Brice Waegeneire <brice@waegenei.re>
16 ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
17 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
18 ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
19 ;;; Copyright © 2020 Brett Gilio <brettg@gnu.org>
20 ;;; Copyright © 2021 Leo Famulari <leo@famulari.name>
21 ;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
22 ;;;
23 ;;; This file is part of GNU Guix.
24 ;;;
25 ;;; GNU Guix is free software; you can redistribute it and/or modify it
26 ;;; under the terms of the GNU General Public License as published by
27 ;;; the Free Software Foundation; either version 3 of the License, or (at
28 ;;; your option) any later version.
29 ;;;
30 ;;; GNU Guix is distributed in the hope that it will be useful, but
31 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
32 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 ;;; GNU General Public License for more details.
34 ;;;
35 ;;; You should have received a copy of the GNU General Public License
36 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
37
38 (define-module (gnu packages virtualization)
39 #:use-module (gnu packages)
40 #:use-module (gnu packages admin)
41 #:use-module (gnu packages assembly)
42 #:use-module (gnu packages attr)
43 #:use-module (gnu packages autotools)
44 #:use-module (gnu packages backup)
45 #:use-module (gnu packages base)
46 #:use-module (gnu packages bash)
47 #:use-module (gnu packages bison)
48 #:use-module (gnu packages build-tools)
49 #:use-module (gnu packages check)
50 #:use-module (gnu packages cmake)
51 #:use-module (gnu packages compression)
52 #:use-module (gnu packages cross-base)
53 #:use-module (gnu packages curl)
54 #:use-module (gnu packages cyrus-sasl)
55 #:use-module (gnu packages debian)
56 #:use-module (gnu packages disk)
57 #:use-module (gnu packages dns)
58 #:use-module (gnu packages docbook)
59 #:use-module (gnu packages documentation)
60 #:use-module (gnu packages figlet)
61 #:use-module (gnu packages firmware)
62 #:use-module (gnu packages flex)
63 #:use-module (gnu packages fontutils)
64 #:use-module (gnu packages freedesktop)
65 #:use-module (gnu packages gettext)
66 #:use-module (gnu packages gl)
67 #:use-module (gnu packages glib)
68 #:use-module (gnu packages gnome)
69 #:use-module (gnu packages gnupg)
70 #:use-module (gnu packages golang)
71 #:use-module (gnu packages graphviz)
72 #:use-module (gnu packages gtk)
73 #:use-module (gnu packages haskell)
74 #:use-module (gnu packages haskell-apps)
75 #:use-module (gnu packages haskell-check)
76 #:use-module (gnu packages haskell-crypto)
77 #:use-module (gnu packages haskell-web)
78 #:use-module (gnu packages haskell-xyz)
79 #:use-module (gnu packages image)
80 #:use-module (gnu packages libbsd)
81 #:use-module (gnu packages libusb)
82 #:use-module (gnu packages linux)
83 #:use-module (gnu packages m4)
84 #:use-module (gnu packages ncurses)
85 #:use-module (gnu packages nettle)
86 #:use-module (gnu packages networking)
87 #:use-module (gnu packages ninja)
88 #:use-module (gnu packages onc-rpc)
89 #:use-module (gnu packages package-management)
90 #:use-module (gnu packages perl)
91 #:use-module (gnu packages pcre)
92 #:use-module (gnu packages pkg-config)
93 #:use-module (gnu packages polkit)
94 #:use-module (gnu packages protobuf)
95 #:use-module (gnu packages python)
96 #:use-module (gnu packages python-build)
97 #:use-module (gnu packages python-check)
98 #:use-module (gnu packages python-crypto)
99 #:use-module (gnu packages python-web)
100 #:use-module (gnu packages python-xyz)
101 #:use-module (gnu packages pulseaudio)
102 #:use-module (gnu packages readline)
103 #:use-module (gnu packages selinux)
104 #:use-module (gnu packages sdl)
105 #:use-module (gnu packages sphinx)
106 #:use-module (gnu packages spice)
107 #:use-module (gnu packages ssh)
108 #:use-module (gnu packages texinfo)
109 #:use-module (gnu packages textutils)
110 #:use-module (gnu packages tls)
111 #:use-module (gnu packages web)
112 #:use-module (gnu packages wget)
113 #:use-module (gnu packages xdisorg)
114 #:use-module (gnu packages xml)
115 #:use-module (gnu packages xorg)
116 #:use-module (guix build-system cmake)
117 #:use-module (guix build-system gnu)
118 #:use-module (guix build-system go)
119 #:use-module (guix build-system meson)
120 #:use-module (guix build-system python)
121 #:use-module (guix build-system trivial)
122 #:use-module (guix download)
123 #:use-module (guix git-download)
124 #:use-module ((guix licenses) #:prefix license:)
125 #:use-module (guix packages)
126 #:use-module (guix utils)
127 #:use-module (srfi srfi-1)
128 #:use-module (srfi srfi-26)
129 #:use-module (ice-9 match))
130
131 (define (qemu-patch commit file-name sha256-bv)
132 "Return an origin for COMMIT."
133 (origin
134 (method url-fetch)
135 (uri (string-append
136 "http://git.qemu.org/?p=qemu.git;a=commitdiff_plain;h="
137 commit))
138 (hash (content-hash sha256-bv sha256))
139 (file-name file-name)))
140
141 (define-public qemu
142 (package
143 (name "qemu")
144 (version "5.2.0")
145 (source
146 (origin
147 (method url-fetch)
148 (uri (string-append "https://download.qemu.org/qemu-"
149 version ".tar.xz"))
150 (sha256
151 (base32
152 "1g0pvx4qbirpcn9mni704y03n3lvkmw2c0rbcwvydyr8ns4xh66b"))
153 (patches (search-patches "qemu-CVE-2021-20203.patch"
154 "qemu-build-info-manual.patch"))
155 (modules '((guix build utils)))
156 (snippet
157 '(begin
158 ;; Fix a bug in the do_ioctl_ifconf() function of qemu to
159 ;; make ioctl(…, SIOCGIFCONF, …) work for emulated 64 bit
160 ;; architectures. The size of struct ifreq is handled
161 ;; incorrectly.
162 ;; https://lists.nongnu.org/archive/html/qemu-devel/2021-01/msg01545.html
163 (substitute* '("linux-user/syscall.c")
164 (("^([[:blank:]]*)const argtype ifreq_arg_type.*$" line indent)
165 (string-append line indent "const argtype ifreq_max_type[] = "
166 "{ MK_STRUCT(STRUCT_ifmap_ifreq) };\n"))
167 (("^([[:blank:]]*)target_ifreq_size[[:blank:]]=.*$" _ indent)
168 (string-append indent "target_ifreq_size = "
169 "thunk_type_size(ifreq_max_type, 0);")))
170 ;; Delete the bundled meson copy.
171 (delete-file-recursively "meson")))))
172 (outputs '("out" "static" "doc")) ;5.3 MiB of HTML docs
173 (build-system gnu-build-system)
174 (arguments
175 ;; FIXME: Disable tests on i686 to work around
176 ;; <https://bugs.gnu.org/40527>.
177 `(#:tests? ,(or (%current-target-system)
178 (not (string=? "i686-linux" (%current-system))))
179 #:configure-flags
180 (let ((gcc (string-append (assoc-ref %build-inputs "gcc") "/bin/gcc"))
181 (out (assoc-ref %outputs "out")))
182 (list (string-append "--cc=" gcc)
183 ;; Some architectures insist on using HOST_CC.
184 (string-append "--host-cc=" gcc)
185 (string-append "--prefix=" out)
186 "--sysconfdir=/etc"
187 (string-append "--smbd=" out "/libexec/samba-wrapper")
188 "--disable-debug-info" ;for space considerations
189 ;; The binaries need to be linked against -lrt.
190 (string-append "--extra-ldflags=-lrt")))
191 ;; Make build and test output verbose to facilitate investigation upon failure.
192 #:make-flags '("V=1")
193 #:modules ((srfi srfi-1)
194 (srfi srfi-26)
195 (ice-9 ftw)
196 (ice-9 match)
197 ,@%gnu-build-system-modules)
198 #:phases
199 (modify-phases %standard-phases
200 (add-after 'set-paths 'hide-glibc
201 (lambda* (#:key inputs #:allow-other-keys)
202 ;; Work around https://issues.guix.info/issue/36882. We need to
203 ;; remove glibc from C_INCLUDE_PATH so that the one hardcoded in GCC,
204 ;; at the bottom of GCC include search-path is used.
205 (let* ((filters '("libc"))
206 (input-directories
207 (filter-map (lambda (input)
208 (match input
209 ((name . dir)
210 (and (not (member name filters))
211 dir))))
212 inputs)))
213 (set-path-environment-variable "C_INCLUDE_PATH"
214 '("include")
215 input-directories))))
216 (add-after 'unpack 'extend-test-time-outs
217 (lambda _
218 ;; These tests can time out on heavily-loaded and/or slow storage.
219 (substitute* (cons* "tests/qemu-iotests/common.qemu"
220 (find-files "tests/qemu-iotests" "^[0-9]+$"))
221 (("QEMU_COMM_TIMEOUT=[0-9]+" match)
222 (string-append match "9")))))
223 (add-after 'unpack 'disable-unusable-tests
224 (lambda _
225 (substitute* "tests/meson.build"
226 ;; Comment out the test-qga test, which needs /sys and
227 ;; fails within the build environment.
228 (("tests.*test-qga.*$" all)
229 (string-append "# " all))
230 ;; Comment out the test-char test, which needs networking and
231 ;; fails within the build environment.
232 (("check-unit-.* tests/test-char" all)
233 (string-append "# " all)))))
234 (add-after 'patch-source-shebangs 'patch-embedded-shebangs
235 (lambda _
236 ;; Ensure the executables created by these source files reference
237 ;; /bin/sh from the store so they work inside the build container.
238 (substitute* '("block/cloop.c" "migration/exec.c"
239 "net/tap.c" "tests/qtest/libqtest.c")
240 (("/bin/sh") (which "sh")))
241 (substitute* "Makefile"
242 (("SHELL = /usr/bin/env bash -o pipefail")
243 "SHELL = bash -o pipefail"))
244 (substitute* "tests/qemu-iotests/check"
245 (("#!/usr/bin/env python3")
246 (string-append "#!" (which "python3"))))))
247 (add-before 'configure 'fix-optionrom-makefile
248 (lambda _
249 ;; Work around the inability of the rules defined in this
250 ;; Makefile to locate the firmware files (e.g.: No rule to make
251 ;; target 'multiboot.bin') by extending the VPATH.
252 (substitute* "pc-bios/optionrom/Makefile"
253 (("^VPATH = \\$\\(SRC_DIR\\)")
254 "VPATH = $(SRC_DIR):$(TOPSRC_DIR)/pc-bios"))))
255 ;; XXX ./configure is being re-run at beginning of build phase...
256 (replace 'configure
257 (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
258 ;; The `configure' script doesn't understand some of the
259 ;; GNU options. Thus, add a new phase that's compatible.
260 (let ((out (assoc-ref outputs "out")))
261 (setenv "SHELL" (which "bash"))
262 ;; Ensure config.status gets the correct shebang off the bat.
263 ;; The build system gets confused if we change it later and
264 ;; attempts to re-run the whole configuration, and fails.
265 (substitute* "configure"
266 (("#!/bin/sh")
267 (string-append "#!" (which "sh"))))
268 (mkdir-p "b/qemu")
269 (chdir "b/qemu")
270 (apply invoke "../../configure" configure-flags))))
271 ;; Configure, build and install QEMU user-emulation static binaries.
272 (add-after 'configure 'configure-user-static
273 (lambda* (#:key inputs outputs #:allow-other-keys)
274 (let* ((gcc (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
275 (static (assoc-ref outputs "static"))
276 ;; This is the common set of configure flags; it is
277 ;; duplicated here to isolate this phase from manipulations
278 ;; to the #:configure-flags build argument, as done in
279 ;; derived packages such as qemu-minimal.
280 (configure-flags (list (string-append "--cc=" gcc)
281 (string-append "--host-cc=" gcc)
282 "--sysconfdir=/etc"
283 "--disable-debug-info")))
284 (mkdir-p "../user-static")
285 (with-directory-excursion "../user-static"
286 (apply invoke "../../configure"
287 "--static"
288 "--disable-docs" ;already built
289 "--disable-system"
290 "--enable-linux-user"
291 (string-append "--prefix=" static)
292 configure-flags)))))
293 (add-after 'build 'build-user-static
294 (lambda args
295 (with-directory-excursion "../user-static"
296 (apply (assoc-ref %standard-phases 'build) args))))
297 (add-after 'install 'install-user-static
298 (lambda* (#:key outputs #:allow-other-keys)
299 (let* ((static (assoc-ref outputs "static"))
300 (bin (string-append static "/bin")))
301 (with-directory-excursion "../user-static"
302 (for-each (cut install-file <> bin)
303 (append-map (cut find-files <> "^qemu-" #:stat stat)
304 (scandir "."
305 (cut string-suffix?
306 "-linux-user" <>))))))))
307 ;; Create a wrapper for Samba. This allows QEMU to use Samba without
308 ;; pulling it in as an input. Note that you need to explicitly install
309 ;; Samba in your Guix profile for Samba support.
310 (add-after 'install 'create-samba-wrapper
311 (lambda* (#:key inputs outputs #:allow-other-keys)
312 (let* ((out (assoc-ref outputs "out"))
313 (libexec (string-append out "/libexec")))
314 (call-with-output-file "samba-wrapper"
315 (lambda (port)
316 (format port "#!/bin/sh
317 exec smbd $@")))
318 (chmod "samba-wrapper" #o755)
319 (install-file "samba-wrapper" libexec))))
320 (add-after 'install 'move-html-doc
321 (lambda* (#:key inputs outputs #:allow-other-keys)
322 (let* ((out (assoc-ref outputs "out"))
323 (doc (assoc-ref outputs "doc"))
324 (qemu-doc (string-append doc "/share/doc/qemu-" ,version)))
325 (mkdir-p qemu-doc)
326 (rename-file (string-append out "/share/doc/qemu")
327 (string-append qemu-doc "/html"))))))))
328 (inputs ; TODO: Add optional inputs.
329 `(("alsa-lib" ,alsa-lib)
330 ("attr" ,attr)
331 ("glib" ,glib)
332 ("gtk+" ,gtk+)
333 ("libaio" ,libaio)
334 ("libattr" ,attr)
335 ("libcacard" ,libcacard) ; smartcard support
336 ("libcap-ng" ,libcap-ng) ; virtfs support requires libcap-ng & libattr
337 ("libdrm" ,libdrm)
338 ("libepoxy" ,libepoxy)
339 ("libjpeg" ,libjpeg-turbo)
340 ("libpng" ,libpng)
341 ("libseccomp" ,libseccomp)
342 ("libusb" ,libusb) ;USB pass-through support
343 ("mesa" ,mesa)
344 ("ncurses" ,ncurses)
345 ;; ("pciutils" ,pciutils)
346 ("pixman" ,pixman)
347 ("pulseaudio" ,pulseaudio)
348 ("sdl2" ,sdl2)
349 ("spice" ,spice)
350 ("usbredir" ,usbredir)
351 ("util-linux" ,util-linux)
352 ("vde2" ,vde2)
353 ("virglrenderer" ,virglrenderer)
354 ("zlib" ,zlib)))
355 (native-inputs `(("gettext" ,gettext-minimal)
356 ("glib:bin" ,glib "bin") ; gtester, etc.
357 ("perl" ,perl)
358 ("flex" ,flex)
359 ("bison" ,bison)
360 ;; Using meson 0.57.1 enables reproducible QEMU builds.
361 ("meson" ,meson-next)
362 ("ninja" ,ninja)
363 ("pkg-config" ,pkg-config)
364 ("python-wrapper" ,python-wrapper)
365 ("python-sphinx" ,python-sphinx)
366 ("texinfo" ,texinfo)
367 ;; The following static libraries are required to build
368 ;; the static output of QEMU.
369 ("glib-static" ,glib-static)
370 ("pcre:static" ,pcre "static")
371 ("zlib:static" ,zlib "static")))
372 (home-page "https://www.qemu.org")
373 (synopsis "Machine emulator and virtualizer")
374 (description
375 "QEMU is a generic machine emulator and virtualizer.
376
377 When used as a machine emulator, QEMU can run OSes and programs made for one
378 machine (e.g. an ARM board) on a different machine---e.g., your own PC. By
379 using dynamic translation, it achieves very good performance.
380
381 When used as a virtualizer, QEMU achieves near native performances by
382 executing the guest code directly on the host CPU. QEMU supports
383 virtualization when executing under the Xen hypervisor or using
384 the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86,
385 server and embedded PowerPC, and S390 guests.")
386
387 ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
388 (license license:gpl2)
389
390 ;; Several tests fail on MIPS; see <http://hydra.gnu.org/build/117914>.
391 (supported-systems (fold delete %supported-systems
392 '("mips64el-linux" "i586-gnu")))))
393
394 (define-public qemu-minimal
395 ;; QEMU without GUI support, only supporting the host's architecture
396 (package
397 (inherit qemu)
398 (name "qemu-minimal")
399 (synopsis
400 "Machine emulator and virtualizer (without GUI) for the host architecture")
401 (arguments
402 (substitute-keyword-arguments (package-arguments qemu)
403 ((#:configure-flags configure-flags '(list))
404 ;; Restrict to the host's architecture.
405 (let* ((system (or (%current-target-system)
406 (%current-system)))
407 (target-list-arg
408 (match system
409 ((? (cut string-prefix? "i686" <>))
410 "--target-list=i386-softmmu")
411 ((? (cut string-prefix? "x86_64" <>))
412 "--target-list=i386-softmmu,x86_64-softmmu")
413 ((? (cut string-prefix? "mips64" <>))
414 (string-append "--target-list=mips-softmmu,mipsel-softmmu,"
415 "mips64-softmmu,mips64el-softmmu"))
416 ((? (cut string-prefix? "mips" <>))
417 "--target-list=mips-softmmu,mipsel-softmmu")
418 ((? (cut string-prefix? "aarch64" <>))
419 "--target-list=arm-softmmu,aarch64-softmmu")
420 ((? (cut string-prefix? "arm" <>))
421 "--target-list=arm-softmmu")
422 ((? (cut string-prefix? "alpha" <>))
423 "--target-list=alpha-softmmu")
424 ((? (cut string-prefix? "powerpc64" <>))
425 "--target-list=ppc-softmmu,ppc64-softmmu")
426 ((? (cut string-prefix? "powerpc" <>))
427 "--target-list=ppc-softmmu")
428 ((? (cut string-prefix? "s390" <>))
429 "--target-list=s390x-softmmu")
430 ((? (cut string-prefix? "riscv" <>))
431 "--target-list=riscv32-softmmu,riscv64-softmmu")
432 (else ; An empty list actually builds all the targets.
433 '()))))
434 `(cons ,target-list-arg ,configure-flags)))))
435
436 ;; Remove dependencies on optional libraries, notably GUI libraries.
437 (native-inputs (fold alist-delete (package-native-inputs qemu)
438 '("gettext")))
439 (inputs (fold alist-delete (package-inputs qemu)
440 '("libusb" "mesa" "sdl2" "spice" "virglrenderer" "gtk+"
441 "usbredir" "libdrm" "libepoxy" "pulseaudio" "vde2"
442 "libcacard")))))
443
444 (define (system->qemu-target system)
445 (cond
446 ((string-prefix? "i686" system)
447 "qemu-system-i386")
448 ((string-prefix? "arm" system)
449 "qemu-system-arm")
450 (else
451 (string-append "qemu-system-" (match (string-split system #\-)
452 ((arch kernel) arch)
453 (_ system))))))
454
455 (define-public ganeti
456 (package
457 (name "ganeti")
458 ;; Note: we use a pre-release for Python 3 compatibility as well as many
459 ;; other fixes.
460 (version "3.0.0beta1-24-g024cc9fa2")
461 (source (origin
462 (method git-fetch)
463 (uri (git-reference
464 (url "https://github.com/ganeti/ganeti")
465 (commit (string-append "v" version))))
466 (sha256
467 (base32 "1ll34qd2mifni3bhg7cnir3xfnkafig8ch33qndqwrsby0y5ssia"))
468 (file-name (git-file-name name version))
469 (patches (search-patches "ganeti-shepherd-support.patch"
470 "ganeti-shepherd-master-failover.patch"
471 "ganeti-deterministic-manual.patch"
472 "ganeti-drbd-compat.patch"
473 "ganeti-os-disk-size.patch"
474 "ganeti-haskell-pythondir.patch"
475 "ganeti-disable-version-symlinks.patch"
476 "ganeti-preserve-PYTHONPATH.patch"))))
477 (build-system gnu-build-system)
478 (arguments
479 `(#:imported-modules (,@%gnu-build-system-modules
480 (guix build haskell-build-system)
481 (guix build python-build-system))
482 #:modules (,@%gnu-build-system-modules
483 ((guix build haskell-build-system) #:prefix haskell:)
484 ((guix build python-build-system) #:select (python-version))
485 (ice-9 rdelim))
486
487 ;; The default test target includes a lot of checks that are only really
488 ;; relevant for developers such as NEWS file checking, line lengths, etc.
489 ;; We are only interested in the "py-tests" and "hs-tests" targets: this
490 ;; is the closest we've got even though it includes a little more.
491 #:test-target "check-TESTS"
492
493 #:configure-flags
494 (list "--localstatedir=/var"
495 "--sharedstatedir=/var"
496 "--sysconfdir=/etc"
497 "--enable-haskell-tests"
498
499 ;; By default, the build system installs everything to versioned
500 ;; directories such as $libdir/3.0 and relies on a $libdir/default
501 ;; symlink pointed from /etc/ganeti/{lib,share} to actually function.
502 ;; This is done to accommodate installing multiple versions in
503 ;; parallel, but is of little use to us as Guix users can just
504 ;; roll back and forth. Thus, disable it for simplicity.
505 "--disable-version-links"
506
507 ;; Ganeti can optionally take control over SSH host keys and
508 ;; distribute them to nodes as they are added, and also rotate keys
509 ;; with 'gnt-cluster renew-crypto --new-ssh-keys'. Thus it needs to
510 ;; know how to restart the SSH daemon.
511 "--with-sshd-restart-command='herd restart ssh-daemon'"
512
513 ;; Look for OS definitions in this directory by default. It can
514 ;; be changed in the cluster configuration.
515 "--with-os-search-path=/run/current-system/profile/share/ganeti/os"
516
517 ;; The default QEMU executable to use. We don't use the package
518 ;; here because this entry is stored in the cluster configuration.
519 (string-append "--with-kvm-path=/run/current-system/profile/bin/"
520 ,(system->qemu-target (%current-system))))
521 #:phases
522 (modify-phases %standard-phases
523 (add-after 'unpack 'create-vcs-version
524 (lambda _
525 ;; If we are building from a git checkout, we need to create a
526 ;; 'vcs-version' file manually because the build system does
527 ;; not have access to the git repository information.
528 (unless (file-exists? "vcs-version")
529 (call-with-output-file "vcs-version"
530 (lambda (port)
531 (format port "v~a~%" ,version))))
532 #t))
533 (add-after 'unpack 'patch-absolute-file-names
534 (lambda _
535 (substitute* '("lib/utils/process.py"
536 "lib/utils/text.py"
537 "src/Ganeti/Constants.hs"
538 "src/Ganeti/HTools/CLI.hs"
539 "test/py/ganeti.config_unittest.py"
540 "test/py/ganeti.hooks_unittest.py"
541 "test/py/ganeti.utils.process_unittest.py"
542 "test/py/ganeti.utils.text_unittest.py"
543 "test/py/ganeti.utils.wrapper_unittest.py")
544 (("/bin/sh") (which "sh"))
545 (("/bin/bash") (which "bash"))
546 (("/usr/bin/env") (which "env"))
547 (("/bin/true") (which "true")))
548
549 ;; This script is called by the node daemon at startup to perform
550 ;; sanity checks on the cluster IP addresses, and it is also used
551 ;; in a master-failover scenario. Add absolute references to
552 ;; avoid propagating these executables.
553 (substitute* "tools/master-ip-setup"
554 (("arping") (which "arping"))
555 (("ndisc6") (which "ndisc6"))
556 (("fping") (which "fping"))
557 (("grep") (which "grep"))
558 (("ip addr") (string-append (which "ip") " addr")))
559 #t))
560 (add-after 'unpack 'override-builtin-PATH
561 (lambda _
562 ;; Ganeti runs OS install scripts and similar with a built-in
563 ;; hard coded PATH. Patch so it works on Guix System.
564 (substitute* "src/Ganeti/Constants.hs"
565 (("/sbin:/bin:/usr/sbin:/usr/bin")
566 "/run/setuid-programs:/run/current-system/profile/sbin:\
567 /run/current-system/profile/bin"))
568 #t))
569 (add-after 'bootstrap 'patch-sphinx-version-detection
570 (lambda _
571 ;; The build system runs 'sphinx-build --version' to verify that
572 ;; the Sphinx is recent enough, but does not expect the
573 ;; .sphinx-build-real executable name created by the Sphinx wrapper.
574 (substitute* "configure"
575 (("\\$SPHINX --version 2>&1")
576 "$SPHINX --version 2>&1 | sed 's/.sphinx-build-real/sphinx-build/g'"))
577 #t))
578
579 ;; The build system invokes Cabal and GHC, which do not work with
580 ;; GHC_PACKAGE_PATH: <https://github.com/haskell/cabal/issues/3728>.
581 ;; Tweak the build system to do roughly what haskell-build-system does.
582 (add-before 'configure 'configure-haskell
583 (assoc-ref haskell:%standard-phases 'setup-compiler))
584 (add-after 'configure 'do-not-use-GHC_PACKAGE_PATH
585 (lambda _
586 (unsetenv "GHC_PACKAGE_PATH")
587 (substitute* "Makefile"
588 (("\\$\\(CABAL\\)")
589 "$(CABAL) --package-db=../package.conf.d")
590 (("\\$\\(GHC\\)")
591 "$(GHC) -package-db=../package.conf.d"))
592 #t))
593 (add-after 'configure 'make-ghc-use-shared-libraries
594 (lambda _
595 (substitute* "Makefile"
596 (("HFLAGS =") "HFLAGS = -dynamic -fPIC"))
597 #t))
598 (add-after 'configure 'fix-installation-directories
599 (lambda _
600 (substitute* "Makefile"
601 ;; Do not attempt to create /var during install.
602 (("\\$\\(DESTDIR\\)\\$\\{localstatedir\\}")
603 "$(DESTDIR)${prefix}${localstatedir}")
604 ;; Similarly, do not attempt to install the sample ifup scripts
605 ;; to /etc/ganeti.
606 (("\\$\\(DESTDIR\\)\\$\\(ifupdir\\)")
607 "$(DESTDIR)${prefix}$(ifupdir)"))
608 #t))
609 (add-before 'build 'adjust-tests
610 (lambda _
611 ;; Disable tests that can not run. Do it early to prevent
612 ;; touching the Makefile later and triggering a needless rebuild.
613 (substitute* "Makefile"
614 ;; These tests expect the presence of a 'root' user (via
615 ;; ganeti/runtime.py), which fails in the build environment.
616 (("test/py/ganeti\\.asyncnotifier_unittest\\.py") "")
617 (("test/py/ganeti\\.backend_unittest\\.py") "")
618 (("test/py/ganeti\\.daemon_unittest\\.py") "")
619 (("test/py/ganeti\\.tools\\.ensure_dirs_unittest\\.py") "")
620 (("test/py/ganeti\\.utils\\.io_unittest-runasroot\\.py") "")
621 ;; Disable the bash_completion test, as it requires the full
622 ;; bash instead of bash-minimal.
623 (("test/py/bash_completion\\.bash")
624 "")
625 ;; This test requires networking.
626 (("test/py/import-export_unittest\\.bash")
627 ""))
628
629 ;; Many of the Makefile targets reset PYTHONPATH before running
630 ;; the Python interpreter, which does not work very well for us.
631 (substitute* "Makefile"
632 (("PYTHONPATH=")
633 (string-append "PYTHONPATH=" (getenv "PYTHONPATH") ":")))
634 #t))
635 (add-after 'build 'build-bash-completions
636 (lambda _
637 (let ((orig-pythonpath (getenv "PYTHONPATH")))
638 (setenv "PYTHONPATH" (string-append ".:" orig-pythonpath))
639 (invoke "./autotools/build-bash-completion")
640 (setenv "PYTHONPATH" orig-pythonpath)
641 #t)))
642 (add-before 'check 'pre-check
643 (lambda* (#:key inputs #:allow-other-keys)
644 ;; Set TZDIR so that time zones are found.
645 (setenv "TZDIR" (string-append (assoc-ref inputs "tzdata")
646 "/share/zoneinfo"))
647
648 ;; This test checks whether PYTHONPATH is untouched, and extends
649 ;; it to include test directories if so. Add an else branch for
650 ;; our modified PYTHONPATH, in order to prevent a confusing test
651 ;; failure where expired certificates are not cleaned because
652 ;; check-cert-expired is silently crashing.
653 (substitute* "test/py/ganeti-cleaner_unittest.bash"
654 (("then export PYTHONPATH=(.*)" all testpath)
655 (string-append all "else export PYTHONPATH="
656 (getenv "PYTHONPATH") ":" testpath "\n")))
657
658 (substitute* "test/py/ganeti.utils.process_unittest.py"
659 ;; This test attempts to run an executable with
660 ;; RunCmd(..., reset_env=True), which fails because the default
661 ;; PATH from Constants.hs does not exist in the build container.
662 ((".*def testResetEnv.*" all)
663 (string-append " @unittest.skipIf(True, "
664 "\"cannot reset env in the build container\")\n"
665 all))
666
667 ;; XXX: Somehow this test fails in the build container, but
668 ;; works in 'guix environment -C', even without /bin/sh?
669 ((".*def testPidFile.*" all)
670 (string-append " @unittest.skipIf(True, "
671 "\"testPidFile fails in the build container\")\n"
672 all)))
673
674 ;; XXX: Why are these links not added automatically.
675 (with-directory-excursion "test/hs"
676 (for-each (lambda (file)
677 (symlink "../../src/htools" file))
678 '("hspace" "hscan" "hinfo" "hbal" "hroller"
679 "hcheck" "hail" "hsqueeze")))
680 #t))
681 (add-after 'install 'install-bash-completions
682 (lambda* (#:key outputs #:allow-other-keys)
683 (let* ((out (assoc-ref outputs "out"))
684 (compdir (string-append out "/etc/bash_completion.d")))
685 (mkdir-p compdir)
686 (copy-file "doc/examples/bash_completion"
687 (string-append compdir "/ganeti"))
688 ;; The one file contains completions for many different
689 ;; executables. Create symlinks for found completions.
690 (with-directory-excursion compdir
691 (for-each
692 (lambda (prog) (symlink "ganeti" prog))
693 (call-with-input-file "ganeti"
694 (lambda (port)
695 (let loop ((line (read-line port))
696 (progs '()))
697 (if (eof-object? line)
698 progs
699 (if (string-prefix? "complete" line)
700 (loop (read-line port)
701 ;; Extract "prog" from lines of the form:
702 ;; "complete -F _prog -o filenames prog".
703 ;; Note that 'burnin' is listed with the
704 ;; absolute file name, which is why we
705 ;; run everything through 'basename'.
706 (cons (basename (car (reverse (string-split
707 line #\ ))))
708 progs))
709 (loop (read-line port) progs))))))))
710 #t)))
711 ;; Wrap all executables with PYTHONPATH. We can't borrow the phase
712 ;; from python-build-system because we also need to wrap the scripts
713 ;; in $out/lib/ganeti such as "node-daemon-setup".
714 (add-after 'install 'wrap
715 (lambda* (#:key inputs outputs #:allow-other-keys)
716 (let* ((out (assoc-ref outputs "out"))
717 (sbin (string-append out "/sbin"))
718 (lib (string-append out "/lib"))
719 (python (assoc-ref inputs "python"))
720 (major+minor (python-version python))
721 (PYTHONPATH (string-append lib "/python" major+minor
722 "/site-packages:"
723 (getenv "PYTHONPATH"))))
724 (define (shell-script? file)
725 (call-with-ascii-input-file file
726 (lambda (port)
727 (let ((shebang (false-if-exception (read-line port))))
728 (and shebang
729 (string-prefix? "#!" shebang)
730 (or (string-contains shebang "/bin/bash")
731 (string-contains shebang "/bin/sh")))))))
732
733 (define (wrap? file)
734 ;; Do not wrap shell scripts because some are meant to be
735 ;; sourced, which breaks if they are wrapped. We do wrap
736 ;; the Haskell executables because some call out to Python
737 ;; directly.
738 (and (executable-file? file)
739 (not (symbolic-link? file))
740 (not (shell-script? file))))
741
742 (for-each (lambda (file)
743 (wrap-program file
744 `("PYTHONPATH" ":" prefix (,PYTHONPATH))))
745 (filter wrap?
746 (append (find-files (string-append lib "/ganeti"))
747 (find-files sbin))))
748 #t))))))
749 (native-inputs
750 `(("haskell" ,ghc)
751 ("cabal" ,cabal-install)
752 ("m4" ,m4)
753
754 ;; These inputs are necessary to bootstrap the package, because we
755 ;; have patched the build system.
756 ("autoconf" ,autoconf)
757 ("automake" ,automake)
758
759 ;; For the documentation.
760 ("python-docutils" ,python-docutils)
761 ("sphinx" ,python-sphinx)
762 ("pandoc" ,pandoc)
763 ("dot" ,graphviz)
764
765 ;; Test dependencies.
766 ("fakeroot" ,fakeroot)
767 ("ghc-temporary" ,ghc-temporary)
768 ("ghc-test-framework" ,ghc-test-framework)
769 ("ghc-test-framework-hunit" ,ghc-test-framework-hunit)
770 ("ghc-test-framework-quickcheck2" ,ghc-test-framework-quickcheck2)
771 ("python-mock" ,python-mock)
772 ("python-pyyaml" ,python-pyyaml)
773 ("openssh" ,openssh)
774 ("procps" ,procps)
775 ("shelltestrunner" ,shelltestrunner)
776 ("tzdata" ,tzdata-for-tests)))
777 (inputs
778 `(("arping" ,iputils) ;must be the iputils version
779 ("curl" ,curl)
780 ("fping" ,fping)
781 ("iproute2" ,iproute)
782 ("ndisc6" ,ndisc6)
783 ("socat" ,socat)
784 ("qemu" ,qemu-minimal) ;for qemu-img
785 ("ghc-attoparsec" ,ghc-attoparsec)
786 ("ghc-base64-bytestring" ,ghc-base64-bytestring)
787 ("ghc-cryptonite" ,ghc-cryptonite)
788 ("ghc-curl" ,ghc-curl)
789 ("ghc-hinotify" ,ghc-hinotify)
790 ("ghc-hslogger" ,ghc-hslogger)
791 ("ghc-json" ,ghc-json)
792 ("ghc-lens" ,ghc-lens)
793 ("ghc-lifted-base" ,ghc-lifted-base)
794 ("ghc-network" ,ghc-network)
795 ("ghc-old-time" ,ghc-old-time)
796 ("ghc-psqueue" ,ghc-psqueue)
797 ("ghc-regex-pcre" ,ghc-regex-pcre)
798 ("ghc-utf8-string" ,ghc-utf8-string)
799 ("ghc-zlib" ,ghc-zlib)
800
801 ;; For the optional metadata daemon.
802 ("ghc-snap-core" ,ghc-snap-core)
803 ("ghc-snap-server" ,ghc-snap-server)
804
805 ("python" ,python)
806 ("python-pyopenssl" ,python-pyopenssl)
807 ("python-simplejson" ,python-simplejson)
808 ("python-pyparsing" ,python-pyparsing)
809 ("python-pyinotify" ,python-pyinotify)
810 ("python-pycurl" ,python-pycurl)
811 ("python-bitarray" ,python-bitarray)
812 ("python-paramiko" ,python-paramiko)
813 ("python-psutil" ,python-psutil)))
814 (home-page "https://www.ganeti.org/")
815 (synopsis "Cluster-based virtual machine management system")
816 (description
817 "Ganeti is a virtual machine management tool built on top of existing
818 virtualization technologies such as Xen or KVM. Ganeti controls:
819
820 @itemize @bullet
821 @item Disk creation management;
822 @item Operating system installation for instances (in co-operation with
823 OS-specific install scripts); and
824 @item Startup, shutdown, and failover between physical systems.
825 @end itemize
826
827 Ganeti is designed to facilitate cluster management of virtual servers and
828 to provide fast and simple recovery after physical failures, using
829 commodity hardware.")
830 (license license:bsd-2)))
831
832 (define-public ganeti-instance-guix
833 (package
834 (name "ganeti-instance-guix")
835 (version "0.6")
836 (home-page "https://github.com/mbakke/ganeti-instance-guix")
837 (source (origin
838 (method git-fetch)
839 (uri (git-reference (url home-page) (commit version)))
840 (file-name (git-file-name name version))
841 (sha256
842 (base32
843 "0aa08irpcpns6mhjgsplc5f0p8ab1qcr9ah1gj5z66kxgqyflzrp"))))
844 (build-system gnu-build-system)
845 (arguments
846 '(#:configure-flags '("--sysconfdir=/etc" "--localstatedir=/var")))
847 (native-inputs
848 `(("autoconf" ,autoconf)
849 ("automake" ,automake)))
850 (inputs
851 `(("util-linux" ,util-linux)
852 ("qemu-img" ,qemu-minimal)))
853 (synopsis "Guix OS integration for Ganeti")
854 (description
855 "This package provides a guest OS definition for Ganeti that uses
856 Guix to build virtual machines.")
857 (license license:gpl3+)))
858
859 (define-public ganeti-instance-debootstrap
860 (package
861 (name "ganeti-instance-debootstrap")
862 ;; We need two commits on top of the latest release for compatibility
863 ;; with newer sfdisk, as well as gnt-network integration.
864 (version "0.16-2-ge145396")
865 (home-page "https://github.com/ganeti/instance-debootstrap")
866 (source (origin
867 (method git-fetch)
868 (uri (git-reference (url home-page) (commit version)))
869 (file-name (git-file-name name version))
870 (sha256
871 (base32
872 "0f2isw9d8lawzj21rrq1q9xhq8xfa65rqbhqmrn59z201x9q1336"))))
873 (build-system gnu-build-system)
874 (arguments
875 '(#:configure-flags '("--sysconfdir=/etc" "--localstatedir=/var")
876 #:phases (modify-phases %standard-phases
877 (add-after 'unpack 'add-absolute-references
878 (lambda _
879 (substitute* "common.sh.in"
880 (("/sbin/blkid") (which "blkid"))
881 (("kpartx -")
882 (string-append (which "kpartx") " -")))
883 (substitute* "import"
884 (("restore -r")
885 (string-append (which "restore") " -r")))
886 (substitute* "export"
887 (("dump -0")
888 (string-append (which "dump") " -0")))
889 (substitute* "create"
890 (("debootstrap") (which "debootstrap"))
891 (("`which run-parts`") (which "run-parts"))
892 ;; Here we actually need to hard code /bin/passwd
893 ;; because it's called via chroot, which fails if
894 ;; "/bin" is not in PATH.
895 (("passwd") "/bin/passwd"))
896 #t))
897 (add-after 'unpack 'set-dpkg-arch
898 (lambda* (#:key system #:allow-other-keys)
899 ;; The create script passes --arch to debootstrap,
900 ;; and defaults to `dpkg --print-architecture` when
901 ;; ARCH is not set in variant.conf. Hard code the
902 ;; build-time architecture to avoid the dpkg dependency.
903 (let ((dpkg-arch
904 (cond ((string-prefix? "x86_64" system)
905 "amd64")
906 ((string-prefix? "i686" system)
907 "i386")
908 ((string-prefix? "aarch64" system)
909 "arm64")
910 (else (car (string-split system #\-))))))
911 (substitute* "create"
912 (("`dpkg --print-architecture`")
913 dpkg-arch))
914 #t)))
915 (add-after 'configure 'adjust-Makefile
916 (lambda _
917 ;; Do not attempt to create /etc/ganeti/instance-debootstrap
918 ;; and /etc/default/ganeti-instance-debootstrap during install.
919 ;; They are created by the Ganeti service.
920 (substitute* "Makefile"
921 (("\\$\\(variantsdir\\)")
922 "$(prefix)/etc/ganeti/instance-debootstrap/variants")
923 (("\\$\\(defaultsdir\\)")
924 "$(prefix)/etc/default/ganeti-instance-debootstrap"))
925 #t))
926 (add-after 'install 'make-variants.list-symlink
927 (lambda* (#:key outputs #:allow-other-keys)
928 ;; The Ganeti OS API mandates a variants.list file that
929 ;; describes all supported "variants" of this OS.
930 ;; Guix generates this file, so make the original file
931 ;; a symlink to it.
932 (with-directory-excursion (string-append
933 (assoc-ref outputs "out")
934 "/share/ganeti/os/debootstrap")
935 (delete-file "variants.list")
936 (symlink "/etc/ganeti/instance-debootstrap/variants/variants.list"
937 "variants.list"))
938 #t)))))
939 (native-inputs
940 `(("autoconf" ,autoconf)
941 ("automake" ,automake)))
942 (inputs
943 `(("debianutils" ,debianutils)
944 ("debootstrap" ,debootstrap)
945 ("dump" ,dump)
946 ("kpartx" ,multipath-tools)
947 ("util-linux" ,util-linux)))
948 (synopsis "Debian OS integration for Ganeti")
949 (description
950 "This package provides a guest OS definition for Ganeti. It installs
951 Debian or a derivative using @command{debootstrap}.")
952 (license license:gpl2+)))
953
954 (define-public libosinfo
955 (package
956 (name "libosinfo")
957 (version "1.7.1")
958 (source
959 (origin
960 (method url-fetch)
961 (uri (string-append "https://releases.pagure.org/libosinfo/libosinfo-"
962 version ".tar.xz"))
963 (sha256
964 (base32
965 "1s97sv24bybggjx6hgqba2qdqz3ivfpd4cmkh4zm5y59sim109mv"))))
966 (build-system meson-build-system)
967 (arguments
968 `(#:configure-flags
969 (list (string-append "-Dwith-usb-ids-path="
970 (assoc-ref %build-inputs "usb.ids"))
971 (string-append "-Dwith-pci-ids-path="
972 (assoc-ref %build-inputs "pci.ids")))
973 #:phases
974 (modify-phases %standard-phases
975 (add-after 'unpack 'patch-osinfo-path
976 (lambda* (#:key inputs #:allow-other-keys)
977 (substitute* "osinfo/osinfo_loader.c"
978 (("path = DATA_DIR.*")
979 (string-append "path = \"" (assoc-ref inputs "osinfo-db")
980 "/share/osinfo\";")))
981 #t)))))
982 (inputs
983 `(("libsoup" ,libsoup)
984 ("libxml2" ,libxml2)
985 ("libxslt" ,libxslt)
986 ("osinfo-db" ,osinfo-db)))
987 (native-inputs
988 `(("glib" ,glib "bin") ; glib-mkenums, etc.
989 ("gobject-introspection" ,gobject-introspection)
990 ("gtk-doc" ,gtk-doc/stable)
991 ("vala" ,vala)
992 ("intltool" ,intltool)
993 ("pkg-config" ,pkg-config)
994 ("pci.ids"
995 ,(origin
996 (method url-fetch)
997 (uri "https://github.com/pciutils/pciids/raw/ad02084f0bc143e3c15e31a6152a3dfb1d7a3156/pci.ids")
998 (sha256
999 (base32
1000 "0kfhpj5rnh24hz2714qhfmxk281vwc2w50sm73ggw5d15af7zfsw"))))
1001 ("usb.ids"
1002 ,(origin
1003 (method url-fetch)
1004 (uri "https://svn.code.sf.net/p/linux-usb/repo/trunk/htdocs/usb.ids?r=2681")
1005 (file-name "usb.ids")
1006 (sha256
1007 (base32
1008 "1m6yhvz5k8aqzxgk7xj3jkk8frl1hbv0h3vgj4wbnvnx79qnvz3r"))))))
1009 (home-page "https://libosinfo.org/")
1010 (synopsis "Operating system information database")
1011 (description "libosinfo is a GObject based library API for managing
1012 information about operating systems, hypervisors and the (virtual) hardware
1013 devices they can support. It includes a database containing device metadata
1014 and provides APIs to match/identify optimal devices for deploying an operating
1015 system on a hypervisor. Via GObject Introspection, the API is available in
1016 all common programming languages. Vala bindings are also provided.")
1017 ;; The library files are released under LGPLv2.1 or later; the source
1018 ;; files in the "tools" directory are released under GPLv2+.
1019 (license (list license:lgpl2.1+ license:gpl2+))))
1020
1021 (define-public lxc
1022 (package
1023 (name "lxc")
1024 (version "4.0.6")
1025 (source (origin
1026 (method url-fetch)
1027 (uri (string-append
1028 "https://linuxcontainers.org/downloads/lxc/lxc-"
1029 version ".tar.gz"))
1030 (sha256
1031 (base32
1032 "0qz4l7mlhq7hx53q606qgvkyzyr01glsw290v8ppzvxn1fydlrci"))))
1033 (build-system gnu-build-system)
1034 (native-inputs
1035 `(("pkg-config" ,pkg-config)))
1036 (inputs
1037 `(("gnutls" ,gnutls)
1038 ("libcap" ,libcap)
1039 ("libseccomp" ,libseccomp)
1040 ("libselinux" ,libselinux)))
1041 (arguments
1042 `(#:configure-flags
1043 (list (string-append "--docdir=" (assoc-ref %outputs "out")
1044 "/share/doc/" ,name "-" ,version)
1045 "--sysconfdir=/etc"
1046 "--localstatedir=/var")
1047 #:phases
1048 (modify-phases %standard-phases
1049 (replace 'install
1050 (lambda* (#:key outputs #:allow-other-keys)
1051 (let* ((out (assoc-ref outputs "out"))
1052 (bashcompdir (string-append out "/etc/bash_completion.d")))
1053 (invoke "make" "install"
1054 (string-append "bashcompdir=" bashcompdir)
1055 ;; Don't install files into /var and /etc.
1056 "LXCPATH=/tmp/var/lib/lxc"
1057 "localstatedir=/tmp/var"
1058 "sysconfdir=/tmp/etc"
1059 "sysconfigdir=/tmp/etc/default")))))))
1060 (synopsis "Linux container tools")
1061 (home-page "https://linuxcontainers.org/")
1062 (description
1063 "LXC is a userspace interface for the Linux kernel containment features.
1064 Through a powerful API and simple tools, it lets Linux users easily create and
1065 manage system or application containers.")
1066 (license license:lgpl2.1+)))
1067
1068 (define-public libvirt
1069 (package
1070 (name "libvirt")
1071 (version "7.2.0")
1072 (source
1073 (origin
1074 (method url-fetch)
1075 (uri (string-append "https://libvirt.org/sources/libvirt-"
1076 version ".tar.xz"))
1077 (sha256
1078 (base32 "1l6i1rz1v9rnp61sgzlrlbsfh03208dbm3b259i0jl5sqz85kx01"))
1079 (patches (search-patches "libvirt-add-install-prefix.patch"))))
1080 (build-system meson-build-system)
1081 (arguments
1082 `(#:configure-flags
1083 (list "-Ddriver_qemu=enabled"
1084 "-Dqemu_user=nobody"
1085 "-Dqemu_group=kvm"
1086 "-Dstorage_disk=enabled"
1087 "-Dstorage_dir=enabled"
1088 "-Dpolkit=enabled"
1089 "-Dnls=enabled" ;translations
1090 (string-append "-Ddocdir=" (assoc-ref %outputs "out") "/share/doc/"
1091 ,name "-" ,version)
1092 "-Dbash_completion=enabled"
1093 (string-append "-Dinstall_prefix=" (assoc-ref %outputs "out"))
1094 "--sysconfdir=/etc"
1095 "--localstatedir=/var")
1096 #:meson ,meson-0.55
1097 #:phases
1098 (modify-phases %standard-phases
1099 (add-before 'configure 'disable-broken-tests
1100 (lambda _
1101 (let ((tests (list "commandtest" ; hangs idly
1102 "qemuxml2argvtest" ; fails
1103 "virnetsockettest"))) ; tries to network
1104 (substitute* "tests/meson.build"
1105 (((format #f ".*'name': '(~a)'.*" (string-join tests "|")))
1106 ""))
1107 #t)))
1108 (add-before 'install 'no-polkit-magic
1109 ;; Meson ‘magically’ invokes pkexec, which fails (not setuid).
1110 (lambda _
1111 (setenv "PKEXEC_UID" "something")
1112 #t)))))
1113 (inputs
1114 `(("libxml2" ,libxml2)
1115 ("eudev" ,eudev)
1116 ("libpciaccess" ,libpciaccess)
1117 ("gnutls" ,gnutls)
1118 ("dbus" ,dbus)
1119 ("libpcap" ,libpcap)
1120 ("libnl" ,libnl)
1121 ("libssh2" ,libssh2) ;optional
1122 ("libtirpc" ,libtirpc) ;for <rpc/rpc.h>
1123 ("libuuid" ,util-linux "lib")
1124 ("lvm2" ,lvm2) ;for libdevmapper
1125 ("curl" ,curl)
1126 ("openssl" ,openssl)
1127 ("readline" ,readline)
1128 ("cyrus-sasl" ,cyrus-sasl)
1129 ("libyajl" ,libyajl)
1130 ("audit" ,audit)
1131 ("dmidecode" ,dmidecode)
1132 ("dnsmasq" ,dnsmasq)
1133 ("ebtables" ,ebtables)
1134 ("parted" ,parted)
1135 ("iproute" ,iproute)
1136 ("iptables" ,iptables)))
1137 (native-inputs
1138 `(("bash-completion" ,bash-completion)
1139 ("gettext" ,gettext-minimal)
1140 ("xsltproc" ,libxslt)
1141 ("perl" ,perl)
1142 ("pkg-config" ,pkg-config)
1143 ("polkit" ,polkit)
1144 ("python" ,python-wrapper)
1145 ("python-docutils" ,python-docutils) ;for rst2html
1146 ("rpcsvc-proto" ,rpcsvc-proto))) ;for rpcgen
1147 (home-page "https://libvirt.org")
1148 (synopsis "Simple API for virtualization")
1149 (description "Libvirt is a C toolkit to interact with the virtualization
1150 capabilities of recent versions of Linux. The library aims at providing long
1151 term stable C API initially for the Xen paravirtualization but should be able
1152 to integrate other virtualization mechanisms if needed.")
1153 (license license:lgpl2.1+)))
1154
1155 (define-public libvirt-glib
1156 (package
1157 (name "libvirt-glib")
1158 (version "4.0.0")
1159 (source (origin
1160 (method url-fetch)
1161 (uri (string-append "ftp://libvirt.org/libvirt/glib/"
1162 "libvirt-glib-" version ".tar.xz"))
1163 (sha256
1164 (base32
1165 "1gdcvqz88qkp402zra9csc6391f2xki1270x683n6ixakl3gf8w4"))))
1166 (build-system meson-build-system)
1167 (inputs
1168 `(("openssl" ,openssl)
1169 ("cyrus-sasl" ,cyrus-sasl)
1170 ("lvm2" ,lvm2) ; for libdevmapper
1171 ("libyajl" ,libyajl)))
1172 (native-inputs
1173 `(("pkg-config" ,pkg-config)
1174 ("intltool" ,intltool)
1175 ("glib" ,glib "bin")
1176 ("vala" ,vala)))
1177 (propagated-inputs
1178 ;; ‘Required:’ by the installed .pc files.
1179 `(("glib" ,glib)
1180 ("libvirt" ,libvirt)
1181 ("libxml2" ,libxml2)
1182 ("gobject-introspection" ,gobject-introspection)))
1183 (home-page "https://libvirt.org")
1184 (synopsis "GLib wrapper around libvirt")
1185 (description "libvirt-glib wraps the libvirt library to provide a
1186 high-level object-oriented API better suited for glib-based applications, via
1187 three libraries:
1188
1189 @enumerate
1190 @item libvirt-glib - GLib main loop integration & misc helper APIs
1191 @item libvirt-gconfig - GObjects for manipulating libvirt XML documents
1192 @item libvirt-gobject - GObjects for managing libvirt objects
1193 @end enumerate
1194 ")
1195 (license license:lgpl2.1+)))
1196
1197 (define-public python-libvirt
1198 (package
1199 (name "python-libvirt")
1200 (version "7.2.0")
1201 (source
1202 (origin
1203 (method url-fetch)
1204 (uri (string-append "https://libvirt.org/sources/python/libvirt-python-"
1205 version ".tar.gz"))
1206 (sha256
1207 (base32 "1ryfimhf47s9k4n0gys233bh15l68fccs2bvj8bjwqjm9k2vmhy0"))))
1208 (build-system python-build-system)
1209 (arguments
1210 `(#:phases
1211 (modify-phases %standard-phases
1212 (add-after 'unpack 'patch-nosetests-path
1213 (lambda* (#:key inputs #:allow-other-keys)
1214 (substitute* "setup.py"
1215 (("\"/usr/bin/nosetests\"")
1216 (string-append "\"" (which "nosetests") "\""))
1217 (("self\\.spawn\\(\\[sys\\.executable, nose\\]\\)")
1218 (format #f "self.spawn([\"~a\", nose])" (which "bash"))))
1219 #t)))))
1220 (inputs
1221 `(("libvirt" ,libvirt)))
1222 (propagated-inputs
1223 `(("python-lxml" ,python-lxml)))
1224 (native-inputs
1225 `(("pkg-config" ,pkg-config)
1226 ("python-nose" ,python-nose)))
1227 (home-page "https://libvirt.org")
1228 (synopsis "Python bindings to libvirt")
1229 (description "This package provides Python bindings to the libvirt
1230 virtualization library.")
1231 (license license:lgpl2.1+)))
1232
1233 (define-public python2-libvirt
1234 (package-with-python2 python-libvirt))
1235
1236 (define-public virt-manager
1237 (package
1238 (name "virt-manager")
1239 (version "3.2.0")
1240 (source (origin
1241 (method url-fetch)
1242 (uri (string-append "https://virt-manager.org/download/sources"
1243 "/virt-manager/virt-manager-"
1244 version ".tar.gz"))
1245 (sha256
1246 (base32
1247 "11kvpzcmyir91qz0dsnk7748jbb4wr8mrc744w117qc91pcy6vrb"))))
1248 (build-system python-build-system)
1249 (arguments
1250 `(#:use-setuptools? #f ; uses custom distutils 'install' command
1251 #:tests? #f ; TODO The tests currently fail
1252 ; RuntimeError: Loop condition wasn't
1253 ; met
1254 #:imported-modules ((guix build glib-or-gtk-build-system)
1255 ,@%python-build-system-modules)
1256 #:modules ((ice-9 match)
1257 (srfi srfi-26)
1258 (guix build python-build-system)
1259 ((guix build glib-or-gtk-build-system) #:prefix glib-or-gtk:)
1260 (guix build utils))
1261 #:phases
1262 (modify-phases %standard-phases
1263 (add-after 'unpack 'fix-setup
1264 (lambda* (#:key outputs #:allow-other-keys)
1265 (substitute* "virtinst/buildconfig.py"
1266 (("/usr") (assoc-ref outputs "out")))
1267 #t))
1268 (add-after 'unpack 'fix-default-uri
1269 (lambda* (#:key inputs #:allow-other-keys)
1270 ;; Xen is not available for now - so only patch qemu.
1271 (substitute* "virtManager/createconn.py"
1272 (("/usr(/bin/qemu-system)" _ suffix)
1273 (string-append (assoc-ref inputs "qemu") suffix)))
1274 #t))
1275 (add-before 'wrap 'wrap-with-GI_TYPELIB_PATH
1276 (lambda* (#:key inputs outputs #:allow-other-keys)
1277 (let* ((bin (string-append (assoc-ref outputs "out") "/bin"))
1278 (bin-files (find-files bin ".*"))
1279 (paths (map (match-lambda
1280 ((output . directory)
1281 (let* ((girepodir (string-append
1282 directory
1283 "/lib/girepository-1.0")))
1284 (if (file-exists? girepodir)
1285 girepodir #f))))
1286 inputs)))
1287 (for-each (lambda (file)
1288 (format #t "wrapping ~a\n" file)
1289 (wrap-program file
1290 `("GI_TYPELIB_PATH" ":" prefix
1291 ,(filter identity paths))))
1292 bin-files))
1293 #t))
1294 (replace 'check
1295 (lambda* (#:key tests? #:allow-other-keys)
1296 (when tests?
1297 (setenv "HOME" "/tmp")
1298 (setenv "XDG_CACHE_HOME" "/tmp")
1299 (system "Xvfb :1 &")
1300 (setenv "DISPLAY" ":1")
1301 ;; Dogtail requires that Assistive Technology support be enabled
1302 (setenv "GTK_MODULES" "gail:atk-bridge")
1303 (invoke "dbus-run-session" "--" "pytest" "--uitests"))
1304 #t))
1305 (add-after 'install 'glib-or-gtk-compile-schemas
1306 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
1307 (add-after 'install 'glib-or-gtk-wrap
1308 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap)))))
1309 (inputs
1310 `(("dconf" ,dconf)
1311 ("gtk+" ,gtk+)
1312 ("gtk-vnc" ,gtk-vnc)
1313 ("gtksourceview" ,gtksourceview)
1314 ("libvirt" ,libvirt)
1315 ("libvirt-glib" ,libvirt-glib)
1316 ("libosinfo" ,libosinfo)
1317 ("vte" ,vte)
1318 ("python-libvirt" ,python-libvirt)
1319 ("python-requests" ,python-requests)
1320 ("python-pycairo" ,python-pycairo)
1321 ("python-pygobject" ,python-pygobject)
1322 ("python-libxml2" ,python-libxml2)
1323 ("spice-gtk" ,spice-gtk)))
1324 ;; virt-manager searches for qemu-img or kvm-img in the PATH.
1325 (propagated-inputs
1326 `(("qemu" ,qemu)))
1327 (native-inputs
1328 `(("glib" ,glib "bin") ; glib-compile-schemas
1329 ("gobject-introspection" ,gobject-introspection)
1330 ("gtk+" ,gtk+ "bin") ; gtk-update-icon-cache
1331 ("perl" ,perl) ; pod2man
1332 ("intltool" ,intltool)
1333 ("rst2man" ,python-docutils)
1334 ;; The following are required for running the tests
1335 ;; ("python-pytest" ,python-pytest)
1336 ;; ("python-dogtail" ,python-dogtail)
1337 ;; ("xvfb" ,xorg-server-for-tests)
1338 ;; ("dbus" ,dbus)
1339 ;; ("at-spi2-core" ,at-spi2-core)
1340 ;; ("gsettings-desktop-schemas" ,gsettings-desktop-schemas)
1341 ))
1342 (home-page "https://virt-manager.org/")
1343 (synopsis "Manage virtual machines")
1344 (description
1345 "The virt-manager application is a desktop user interface for managing
1346 virtual machines through libvirt. It primarily targets KVM VMs, but also
1347 manages Xen and LXC (Linux containers). It presents a summary view of running
1348 domains, their live performance and resource utilization statistics.")
1349 (license license:gpl2+)))
1350
1351 (define-public criu
1352 (package
1353 (name "criu")
1354 (version "3.15")
1355 (source (origin
1356 (method url-fetch)
1357 (uri (string-append "https://download.openvz.org/criu/criu-"
1358 version ".tar.bz2"))
1359 (sha256
1360 (base32
1361 "09d0j24x0cyc7wkgi7cnxqgfjk7kbdlm79zxpj8d356sa3rw2z24"))))
1362 (build-system gnu-build-system)
1363 (arguments
1364 `(#:test-target "test"
1365 #:tests? #f ; tests require mounting as root
1366 #:make-flags
1367 (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
1368 (string-append "LIBDIR=" (assoc-ref %outputs "out")
1369 "/lib")
1370 (string-append "ASCIIDOC=" (assoc-ref %build-inputs "asciidoc")
1371 "/bin/asciidoc")
1372 (string-append "XMLTO=" (assoc-ref %build-inputs "xmlto")
1373 "/bin/xmlto"))
1374 #:phases
1375 (modify-phases %standard-phases
1376 (replace 'configure
1377 (lambda* (#:key inputs #:allow-other-keys)
1378 ;; The includes for libnl are located in a sub-directory.
1379 (setenv "C_INCLUDE_PATH"
1380 (string-append (assoc-ref inputs "libnl")
1381 "/include/libnl3:"
1382 (or (getenv "C_INCLUDE_PATH") "")))
1383 #t))
1384 (add-after 'configure 'fix-documentation
1385 (lambda* (#:key inputs outputs #:allow-other-keys)
1386 (substitute* "Documentation/Makefile"
1387 (("-m custom.xsl")
1388 (string-append
1389 "-m custom.xsl --skip-validation -x "
1390 (assoc-ref inputs "docbook-xsl") "/xml/xsl/"
1391 ,(package-name docbook-xsl) "-"
1392 ,(package-version docbook-xsl)
1393 "/manpages/docbook.xsl")))
1394 #t))
1395 (add-after 'unpack 'hardcode-variables
1396 (lambda* (#:key inputs #:allow-other-keys)
1397 ;; Hardcode arm version detection
1398 (substitute* "Makefile"
1399 (("ARMV.*:=.*") "ARMV := 7\n"))
1400 ;; We are currently using python-2
1401 (substitute* "crit/Makefile"
1402 (("\\$\\(PYTHON\\)") "python2"))
1403 (substitute* "lib/Makefile"
1404 (("\\$\\(PYTHON\\)")
1405 (string-append (assoc-ref inputs "python")
1406 "/bin/python")))
1407 #t))
1408 (add-before 'build 'fix-symlink
1409 (lambda* (#:key inputs #:allow-other-keys)
1410 ;; The file 'images/google/protobuf/descriptor.proto' points to
1411 ;; /usr/include/..., which obviously does not exist.
1412 (let* ((file "google/protobuf/descriptor.proto")
1413 (target (string-append "images/" file))
1414 (source (string-append (assoc-ref inputs "protobuf")
1415 "/include/" file)))
1416 (delete-file target)
1417 (symlink source target)
1418 #t)))
1419 (add-after 'install 'wrap
1420 (lambda* (#:key inputs outputs #:allow-other-keys)
1421 ;; Make sure 'crit' runs with the correct PYTHONPATH.
1422 (let* ((out (assoc-ref outputs "out"))
1423 (path (string-append out
1424 "/lib/python"
1425 (string-take (string-take-right
1426 (assoc-ref inputs "python") 5) 3)
1427 "/site-packages:"
1428 (getenv "PYTHONPATH"))))
1429 (wrap-program (string-append out "/bin/crit")
1430 `("PYTHONPATH" ":" prefix (,path))))
1431 #t)))))
1432 (inputs
1433 `(("protobuf" ,protobuf)
1434 ("python" ,python-2)
1435 ("python2-protobuf" ,python2-protobuf)
1436 ("python2-ipaddr" ,python2-ipaddr)
1437 ("iproute" ,iproute)
1438 ("libaio" ,libaio)
1439 ("libcap" ,libcap)
1440 ("libnet" ,libnet)
1441 ("libnl" ,libnl)
1442 ("libbsd" ,libbsd)
1443 ("nftables" ,nftables)))
1444 (native-inputs
1445 `(("pkg-config" ,pkg-config)
1446 ("perl" ,perl)
1447 ("protobuf-c" ,protobuf-c)
1448 ("asciidoc" ,asciidoc)
1449 ("xmlto" ,xmlto)
1450 ("docbook-xml" ,docbook-xml)
1451 ("docbook-xsl" ,docbook-xsl)))
1452 (home-page "https://criu.org")
1453 (synopsis "Checkpoint and restore in user space")
1454 (description "Using this tool, you can freeze a running application (or
1455 part of it) and checkpoint it to a hard drive as a collection of files. You
1456 can then use the files to restore and run the application from the point it
1457 was frozen at. The distinctive feature of the CRIU project is that it is
1458 mainly implemented in user space.")
1459 ;; The project is licensed under GPLv2; files in the lib/ directory are
1460 ;; LGPLv2.1.
1461 (license (list license:gpl2 license:lgpl2.1))))
1462
1463 (define-public qmpbackup
1464 (package
1465 (name "qmpbackup")
1466 (version "0.2")
1467 (source (origin
1468 (method git-fetch)
1469 (uri (git-reference
1470 (url "https://github.com/abbbi/qmpbackup")
1471 (commit version)))
1472 (file-name (git-file-name name version))
1473 (sha256
1474 (base32
1475 "0swhp5byz44brhyis1a39p11fyn9q84xz5q6v2fah29r7d71kmmx"))))
1476 (build-system python-build-system)
1477 (arguments
1478 `(#:python ,python-2))
1479 (home-page "https://github.com/abbbi/qmpbackup")
1480 (synopsis "Backup and restore QEMU machines")
1481 (description "qmpbackup is designed to create and restore full and
1482 incremental backups of running QEMU virtual machines via QMP, the QEMU
1483 Machine Protocol.")
1484 (license license:gpl3+)))
1485
1486 (define-public looking-glass-client
1487 (let ((commit "182c4752d57690da7f99d5e788de9b8baea33895"))
1488 (package
1489 (name "looking-glass-client")
1490 (version (string-append "a12-" (string-take commit 7)))
1491 (source
1492 (origin
1493 (method git-fetch)
1494 (uri (git-reference (url "https://github.com/gnif/LookingGlass")
1495 (commit commit)))
1496 (file-name (git-file-name name version))
1497 (sha256
1498 (base32
1499 "02bq46ndmzq9cihazzn7xq1x7q5nzm7iw4l9lqzihxcxp9famkhw"))
1500 (modules '((guix build utils)))
1501 (snippet
1502 '(begin
1503 ;; Do not create binaries optimized for the CPU of the build machine,
1504 ;; for reproducibility and compatibility. TODO: in the next version
1505 ;; of looking glass, this is exposed as a CMake configure option.
1506 (substitute* "client/CMakeLists.txt"
1507 (("-march=native")
1508 ""))
1509 #t))))
1510 (build-system cmake-build-system)
1511 (inputs `(("fontconfig" ,fontconfig)
1512 ("glu" ,glu)
1513 ("mesa" ,mesa)
1514 ("openssl" ,openssl)
1515 ("sdl2" ,sdl2)
1516 ("sdl2-ttf" ,sdl2-ttf)
1517 ("spice-protocol" ,spice-protocol)
1518 ("wayland" ,wayland)))
1519 (native-inputs `(("libconfig" ,libconfig)
1520 ("nettle" ,nettle)
1521 ("pkg-config" ,pkg-config)))
1522 (arguments
1523 `(#:tests? #f ;; No tests are available.
1524 #:make-flags '("CC=gcc")
1525 #:phases (modify-phases %standard-phases
1526 (add-before 'configure 'chdir-to-client
1527 (lambda* (#:key outputs #:allow-other-keys)
1528 (chdir "client")
1529 #t))
1530 (add-after 'chdir-to-client 'add-missing-include
1531 (lambda _
1532 ;; Mimic upstream commit b9797529893, required since the
1533 ;; update to Mesa 19.2.
1534 (substitute* "renderers/egl/shader.h"
1535 (("#include <stdbool\\.h>")
1536 "#include <stdbool.h>\n#include <stddef.h>"))
1537 #t))
1538 (replace 'install
1539 (lambda* (#:key outputs #:allow-other-keys)
1540 (install-file "looking-glass-client"
1541 (string-append (assoc-ref outputs "out")
1542 "/bin"))
1543 #t)))))
1544 (home-page "https://looking-glass.hostfission.com")
1545 (synopsis "KVM Frame Relay (KVMFR) implementation")
1546 (description "Looking Glass allows the use of a KVM (Kernel-based Virtual
1547 Machine) configured for VGA PCI Pass-through without an attached physical
1548 monitor, keyboard or mouse. It displays the VM's rendered contents on your main
1549 monitor/GPU.")
1550 ;; This package requires SSE instructions.
1551 (supported-systems '("i686-linux" "x86_64-linux"))
1552 (license license:gpl2+))))
1553
1554 (define-public runc
1555 (package
1556 (name "runc")
1557 (version "1.0.0-rc93")
1558 (source (origin
1559 (method url-fetch)
1560 (uri (string-append
1561 "https://github.com/opencontainers/runc/releases/"
1562 "download/v" version "/runc.tar.xz"))
1563 (file-name (string-append name "-" version ".tar.xz"))
1564 (sha256
1565 (base32
1566 "0b90r1bkvlqli53ca1yc1l488dba0isd3i6l7nlhszxi8p7hzvkh"))))
1567 (build-system go-build-system)
1568 (arguments
1569 '(#:import-path "github.com/opencontainers/runc"
1570 #:install-source? #f
1571 ;; XXX: 20/139 tests fail due to missing /var, cgroups and apparmor in
1572 ;; the build environment.
1573 #:tests? #f
1574 #:phases
1575 (modify-phases %standard-phases
1576 (replace 'build
1577 (lambda* (#:key import-path #:allow-other-keys)
1578 (with-directory-excursion (string-append "src/" import-path)
1579 (invoke "make" "all" "man"))))
1580 (replace 'check
1581 (lambda* (#:key tests? #:allow-other-keys)
1582 (when tests?
1583 (invoke "make" "localunittest"))))
1584 (replace 'install
1585 (lambda* (#:key import-path outputs #:allow-other-keys)
1586 (with-directory-excursion (string-append "src/" import-path)
1587 (let ((out (assoc-ref outputs "out")))
1588 (invoke "make" "install" "install-bash" "install-man"
1589 (string-append "PREFIX=" out)))))))))
1590 (native-inputs
1591 `(("go-md2man" ,go-github-com-go-md2man)
1592 ("pkg-config" ,pkg-config)))
1593 (inputs
1594 `(("libseccomp" ,libseccomp)))
1595 (synopsis "Open container initiative runtime")
1596 (home-page "https://opencontainers.org/")
1597 (description
1598 "@command{runc} is a command line client for running applications
1599 packaged according to the
1600 @uref{https://github.com/opencontainers/runtime-spec/blob/master/spec.md, Open
1601 Container Initiative (OCI) format} and is a compliant implementation of the
1602 Open Container Initiative specification.")
1603 (license license:asl2.0)))
1604
1605 (define-public umoci
1606 (package
1607 (name "umoci")
1608 (version "0.4.7")
1609 (source
1610 (origin
1611 (method url-fetch)
1612 (uri (string-append
1613 "https://github.com/opencontainers/umoci/releases/download/v"
1614 version "/umoci.tar.xz"))
1615 (file-name (string-append "umoci-" version ".tar.xz"))
1616 (sha256
1617 (base32 "0fvljj9k4f83wbqzd8nbijz0p1zaq633f8yxyvl5sy3wjf03ffk9"))))
1618 (build-system go-build-system)
1619 (arguments
1620 '(#:import-path "github.com/opencontainers/umoci"
1621 #:install-source? #f
1622 #:phases
1623 (modify-phases %standard-phases
1624 (replace 'unpack
1625 (lambda* (#:key source import-path #:allow-other-keys)
1626 ;; Unpack the tarball into 'umoci' instead of "runc-${version}".
1627 (let ((dest (string-append "src/" import-path)))
1628 (mkdir-p dest)
1629 (invoke "tar" "-C" (string-append "src/" import-path)
1630 "--strip-components=1"
1631 "-xvf" source))))
1632 (replace 'build
1633 (lambda* (#:key import-path #:allow-other-keys)
1634 (with-directory-excursion (string-append "src/" import-path)
1635 ;; TODO: build manpages with 'go-md2man'.
1636 (invoke "make" "SHELL=bash"))))
1637 (replace 'install
1638 (lambda* (#:key import-path outputs #:allow-other-keys)
1639 (let* ((out (assoc-ref outputs "out"))
1640 (bindir (string-append out "/bin")))
1641 (install-file (string-append "src/" import-path "/umoci")
1642 bindir)
1643 #t))))))
1644 (home-page "https://umo.ci/")
1645 (synopsis "Tool for modifying Open Container images")
1646 (description
1647 "@command{umoci} is a tool that allows for high-level modification of an
1648 Open Container Initiative (OCI) image layout and its tagged images.")
1649 (license license:asl2.0)))
1650
1651 (define-public skopeo
1652 (package
1653 (name "skopeo")
1654 (version "1.2.2")
1655 (source (origin
1656 (method git-fetch)
1657 (uri (git-reference
1658 (url "https://github.com/containers/skopeo")
1659 (commit (string-append "v" version))))
1660 (file-name (git-file-name name version))
1661 (sha256
1662 (base32
1663 "03sznybn3rqjyplc6w4b7mfa6gas8db15p5vnmfm1xqw72ldylgc"))))
1664 (build-system go-build-system)
1665 (native-inputs
1666 `(("pkg-config" ,pkg-config)
1667 ("go-github-com-go-md2man" ,go-github-com-go-md2man)))
1668 (inputs
1669 `(("btrfs-progs" ,btrfs-progs)
1670 ("eudev" ,eudev)
1671 ("libassuan" ,libassuan)
1672 ("libselinux" ,libselinux)
1673 ("libostree" ,libostree)
1674 ("lvm2" ,lvm2)
1675 ("glib" ,glib)
1676 ("gpgme" ,gpgme)))
1677 (arguments
1678 '(#:import-path "github.com/containers/skopeo"
1679 #:install-source? #f
1680 #:tests? #f ; The tests require Docker
1681 #:phases
1682 (modify-phases %standard-phases
1683 (replace 'build
1684 (lambda* (#:key import-path #:allow-other-keys)
1685 (with-directory-excursion (string-append "src/" import-path)
1686 (invoke "make" "bin/skopeo"))))
1687 (add-after 'build 'build-docs
1688 (lambda* (#:key import-path #:allow-other-keys)
1689 (with-directory-excursion (string-append "src/" import-path)
1690 (invoke "make" "docs"))))
1691 (replace 'install
1692 (lambda* (#:key import-path outputs #:allow-other-keys)
1693 (with-directory-excursion (string-append "src/" import-path)
1694 (let ((out (assoc-ref outputs "out")))
1695 (install-file "default-policy.json"
1696 (string-append out "/etc/containers"))
1697 (invoke "make" "install-binary" "install-completions" "install-docs"
1698 (string-append "PREFIX=" out)))))))))
1699 (home-page "https://github.com/containers/skopeo")
1700 (synopsis "Interact with container images and container image registries")
1701 (description
1702 "@command{skopeo} is a command line utility providing various operations
1703 with container images and container image registries. It can:
1704 @enumerate
1705
1706 @item Copy container images between various containers image stores,
1707 converting them as necessary.
1708
1709 @item Convert a Docker schema 2 or schema 1 container image to an OCI image.
1710
1711 @item Inspect a repository on a container registry without needlessly pulling
1712 the image.
1713
1714 @item Sign and verify container images.
1715
1716 @item Delete container images from a remote container registry.
1717
1718 @end enumerate")
1719 (license license:asl2.0)))
1720
1721 (define-public python-vagrant
1722 (package
1723 (name "python-vagrant")
1724 (version "0.5.15")
1725 (source
1726 (origin
1727 (method url-fetch)
1728 (uri (pypi-uri "python-vagrant" version))
1729 (sha256
1730 (base32
1731 "1ikrh6canhcxg5y7pzmkcnnydikppv7s6sm9prfx90nk0ac8m6mg"))))
1732 (build-system python-build-system)
1733 (arguments
1734 '(#:tests? #f)) ; tests involve running vagrant.
1735 (home-page "https://github.com/todddeluca/python-vagrant")
1736 (synopsis "Python bindings for Vagrant")
1737 (description
1738 "Python-vagrant is a Python module that provides a thin wrapper around the
1739 @code{vagrant} command line executable, allowing programmatic control of Vagrant
1740 virtual machines.")
1741 (license license:expat)))
1742
1743 (define-public bubblewrap
1744 (package
1745 (name "bubblewrap")
1746 (version "0.4.1")
1747 (source (origin
1748 (method url-fetch)
1749 (uri (string-append "https://github.com/containers/bubblewrap/"
1750 "releases/download/v" version "/bubblewrap-"
1751 version ".tar.xz"))
1752 (sha256
1753 (base32
1754 "00ycgi6q2yngh06bnz50wkvar6r2jnjf3j158grhi9k13jdrpimr"))))
1755 (build-system gnu-build-system)
1756 (arguments
1757 `(#:phases
1758 (modify-phases %standard-phases
1759 (add-after 'unpack 'fix-test
1760 (lambda* (#:key outputs #:allow-other-keys)
1761 ;; Tests try to access /var/tmp, which is not possible in our build
1762 ;; environment. Let's give them another directory.
1763 ;; /tmp gets overriden in some tests, so we need another directory.
1764 ;; the only possibility is the output directory.
1765 (let ((tmp-dir (string-append (assoc-ref outputs "out") "/tmp")))
1766 (mkdir-p tmp-dir)
1767 (substitute* "tests/test-run.sh"
1768 (("/var/tmp") tmp-dir)
1769 ;; Tests create a temporary python script, so fix its shebang.
1770 (("/usr/bin/env python") (which "python"))
1771 ;; Some tests try to access /usr, but that doesn't exist.
1772 ;; Give them /gnu instead.
1773 (("/usr") "/gnu")
1774 (("--ro-bind /bin /bin") "--ro-bind /gnu /bin")
1775 (("--ro-bind /sbin /sbin") "--ro-bind /gnu /sbin")
1776 (("--ro-bind /lib /lib") "--ro-bind /gnu /lib")
1777 ((" */bin/bash") (which "bash"))
1778 (("/bin/sh") (which "sh"))
1779 (("findmnt") (which "findmnt"))))
1780 #t))
1781 ;; Remove the directory we gave to tests to have a clean package.
1782 (add-after 'check 'remove-tmp-dir
1783 (lambda* (#:key outputs #:allow-other-keys)
1784 (delete-file-recursively (string-append (assoc-ref outputs "out") "/tmp"))
1785 #t)))))
1786 (inputs
1787 `(("libcap" ,libcap)))
1788 (native-inputs
1789 `(("python" ,python-wrapper)
1790 ("util-linux" ,util-linux)))
1791 (home-page "https://github.com/containers/bubblewrap")
1792 (synopsis "Unprivileged sandboxing tool")
1793 (description "Bubblewrap is aimed at running applications in a sandbox,
1794 restricting their access to parts of the operating system or user data such as
1795 the home directory. Bubblewrap always creates a new mount namespace, and the
1796 user can specify exactly what parts of the file system should be made visible
1797 in the sandbox. These directories are mounted with the @code{nodev} option
1798 by default and can be made read-only.")
1799 (license license:lgpl2.0+)))
1800
1801 (define-public bochs
1802 (package
1803 (name "bochs")
1804 (version "2.6.11")
1805 (source
1806 (origin
1807 (method url-fetch)
1808 (uri (string-append "https://sourceforge.net/projects/bochs/files/bochs/"
1809 version "/bochs-" version ".tar.gz"))
1810 (sha256
1811 (base32 "0ql8q6y1k356li1g9gbvl21448mlxphxxi6kjb2b3pxvzd0pp2b3"))))
1812 (build-system gnu-build-system)
1813 (arguments
1814 `(#:tests? #f)) ; no tests exist
1815 (inputs
1816 `(("libxrandr" ,libxrandr)))
1817 (home-page "http://bochs.sourceforge.net/")
1818 (synopsis "Emulator for x86 PC")
1819 (description
1820 "Bochs is an emulator which can emulate Intel x86 CPU, common I/O
1821 devices, and a custom BIOS. It can also be compiled to emulate many different
1822 x86 CPUs, from early 386 to the most recent x86-64 Intel and AMD processors.
1823 Bochs can run most Operating Systems inside the emulation including Linux,
1824 DOS or Microsoft Windows.")
1825 (license license:lgpl2.0+)))
1826
1827 (define-public xen
1828 (package
1829 (name "xen")
1830 (version "4.14.1")
1831 (source (origin
1832 (method git-fetch)
1833 (uri (git-reference
1834 (url "git://xenbits.xenproject.org/xen.git")
1835 (commit (string-append "RELEASE-" version))))
1836 (file-name (git-file-name name version))
1837 (sha256
1838 (base32
1839 "1r90rvypw76ya9clqw5p02gm1k8hxz73f7gr95ca778nnzvb7xjw"))))
1840 (build-system gnu-build-system)
1841 (arguments
1842 `(#:configure-flags
1843 (list "--enable-rpath"
1844 "--disable-qemu-traditional" ; It tries to do "git clone"
1845 "--disable-rombios" ; would try to "git clone" via etherboot.
1846 ;; TODO: Re-enable stubdom (it's "more secure" to use it).
1847 "--disable-stubdom" ; tries to "git clone" old patched newlib.
1848 (string-append "--with-initddir="
1849 (assoc-ref %outputs "out")
1850 "/etc/init.d")
1851 (string-append "--with-system-qemu="
1852 (assoc-ref %build-inputs "qemu")
1853 "/bin/qemu-system-i386")
1854 (string-append "--with-system-seabios="
1855 (assoc-ref %build-inputs "seabios")
1856 "/share/firmware/bios.bin")
1857 (string-append "--with-system-ovmf="
1858 (assoc-ref %build-inputs "ovmf")
1859 "/share/firmware/ovmf_ia32.bin"))
1860 #:make-flags (list "-j" "1"
1861 "XEN_BUILD_DATE=Thu Jan 1 01:00:01 CET 1970"
1862 "XEN_BUILD_TIME=01:00:01"
1863 "XEN_BUILD_HOST="
1864 "ETHERBOOT_NICS="
1865 "SMBIOS_REL_DATE=01/01/1970"
1866 "VGABIOS_REL_DATE=01 Jan 1970"
1867 ; QEMU_TRADITIONAL_LOC
1868 ; QEMU_UPSTREAM_LOC
1869 "SYSCONFIG_DIR=/tmp/etc/default"
1870 (string-append "BASH_COMPLETION_DIR="
1871 (assoc-ref %outputs "out")
1872 "/etc/bash_completion.d")
1873 (string-append "BOOT_DIR="
1874 (assoc-ref %outputs "out")
1875 "/boot")
1876 (string-append "DEBUG_DIR="
1877 (assoc-ref %outputs "out")
1878 "/lib/debug")
1879 (string-append "EFI_DIR="
1880 (assoc-ref %outputs "out")
1881 "/lib/efi") ; TODO lib64 ?
1882 "MINIOS_UPSTREAM_URL="
1883 ;(string-append "DISTDIR="
1884 ; (assoc-ref %outputs "out"))
1885 )
1886 #:test-target "test"
1887 #:phases
1888 (modify-phases %standard-phases
1889 (add-after 'unpack 'unpack-mini-os
1890 (lambda* (#:key inputs #:allow-other-keys)
1891 (copy-recursively (assoc-ref inputs "mini-os") "extras/mini-os")
1892 #t))
1893 (add-after 'unpack-mini-os 'patch
1894 (lambda* (#:key inputs outputs #:allow-other-keys)
1895 (substitute* "tools/firmware/Rules.mk"
1896 (("override XEN_TARGET_ARCH = x86_32")
1897 (string-append "override XEN_TARGET_ARCH = x86_32
1898 override CC = " (assoc-ref inputs "cross-gcc") "/bin/i686-linux-gnu-gcc"))
1899 (("^CFLAGS =$")
1900 (string-append "CFLAGS=-I" (assoc-ref inputs "cross-libc")
1901 "/include\n")))
1902 (substitute* "config/x86_32.mk"
1903 (("CFLAGS += -m32 -march=i686")
1904 (string-append "CFLAGS += -march=i686 -I"
1905 (assoc-ref inputs "cross-libc")
1906 "/include")))
1907 ;; /var is not in /gnu/store , so don't try to create it.
1908 (substitute* '("tools/Makefile"
1909 "tools/xenstore/Makefile"
1910 "tools/xenpaging/Makefile")
1911 (("\\$\\(INSTALL_DIR\\) .*XEN_(DUMP|LOG|RUN|LIB|PAGING)_DIR.*")
1912 "\n")
1913 (("\\$\\(INSTALL_DIR\\) .*XEN_(RUN|LIB)_STORED.*")
1914 "\n"))
1915 ;; Prevent xen from creating /etc .
1916 (substitute* "tools/examples/Makefile"
1917 ((" install-readmes") "")
1918 ((" install-configs") ""))
1919 ;; Set rpath.
1920 (substitute* "tools/pygrub/setup.py"
1921 (("library_dirs =")
1922 ; TODO: extra_link_args = ['-Wl,-rpath=/opt/foo'],
1923 (string-append "runtime_library_dirs = ['"
1924 (assoc-ref outputs "out")
1925 "/lib'],\nlibrary_dirs =")))
1926 #t))
1927 (add-before 'configure 'patch-xen-script-directory
1928 (lambda* (#:key outputs #:allow-other-keys)
1929 (substitute* '("configure"
1930 "tools/configure"
1931 "docs/configure")
1932 (("XEN_SCRIPT_DIR=.*")
1933 (string-append "XEN_SCRIPT_DIR="
1934 (assoc-ref outputs "out")
1935 "/etc/xen/scripts")))
1936 #t))
1937 (add-before 'configure 'set-environment-up
1938 (lambda* (#:key make-flags #:allow-other-keys)
1939 (define (cross? x)
1940 (string-contains x "cross-i686-linux"))
1941 (define (filter-environment! filter-predicate
1942 environment-variable-names)
1943 (for-each
1944 (lambda (env-name)
1945 (let* ((env-value (getenv env-name))
1946 (search-path (search-path-as-string->list env-value))
1947 (new-search-path (filter filter-predicate
1948 search-path))
1949 (new-env-value (list->search-path-as-string
1950 new-search-path ":")))
1951 (setenv env-name new-env-value)))
1952 environment-variable-names))
1953 (setenv "CROSS_C_INCLUDE_PATH" (getenv "C_INCLUDE_PATH"))
1954 (setenv "CROSS_CPLUS_INCLUDE_PATH" (getenv "CPLUS_INCLUDE_PATH"))
1955 (setenv "CROSS_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
1956 (filter-environment! cross?
1957 '("CROSS_C_INCLUDE_PATH" "CROSS_CPLUS_INCLUDE_PATH"
1958 "CROSS_LIBRARY_PATH"))
1959 (filter-environment! (lambda (e) (not (cross? e)))
1960 '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"
1961 "LIBRARY_PATH"))
1962 ;; Guix tries to be helpful and automatically adds
1963 ;; mini-os-git-checkout/include to the include path,
1964 ;; but actually we don't want it to be there (yet).
1965 (filter-environment! (lambda (e)
1966 (not
1967 (string-contains e
1968 "mini-os-git-checkout")))
1969 '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"
1970 "LIBRARY_PATH"))
1971 (setenv "EFI_VENDOR" "guix")
1972 #t))
1973 (replace 'build
1974 (lambda* (#:key make-flags #:allow-other-keys)
1975 (apply invoke "make" "world" make-flags))))))
1976 (inputs
1977 `(("acpica" ,acpica) ; TODO: patch iasl invocation.
1978 ("bridge-utils" ,bridge-utils) ; TODO: patch invocations.
1979 ("glib" ,glib)
1980 ("iproute" ,iproute) ; TODO: patch invocations.
1981 ("libaio" ,libaio)
1982 ("libx11" ,libx11)
1983 ("libyajl" ,libyajl)
1984 ("ncurses" ,ncurses)
1985 ("openssl" ,openssl)
1986 ("ovmf" ,ovmf)
1987 ("pixman" ,pixman)
1988 ("qemu" ,qemu-minimal)
1989 ("seabios" ,seabios)
1990 ("util-linux" ,util-linux "lib") ; uuid
1991 ; TODO: ocaml-findlib, ocaml-nox.
1992 ("xz" ,xz) ; for liblzma
1993 ("zlib" ,zlib)))
1994 (native-inputs
1995 `(("dev86" ,dev86)
1996 ("bison" ,bison)
1997 ("cmake" ,cmake-minimal)
1998 ("figlet" ,figlet)
1999 ("flex" ,flex)
2000 ("gettext" ,gettext-minimal)
2001 ("libnl" ,libnl)
2002 ("mini-os"
2003 ,(origin
2004 (method git-fetch)
2005 (uri (git-reference
2006 (url "http://xenbits.xen.org/git-http/mini-os.git")
2007 (commit (string-append "xen-RELEASE-" version))))
2008 (sha256
2009 (base32
2010 "1i8pcl19n60i2m9vlg79q3nknpj209c9ic5x10wxaicx45kc107f"))
2011 (file-name "mini-os-git-checkout")))
2012 ("perl" ,perl)
2013 ; TODO: markdown
2014 ("pkg-config" ,pkg-config)
2015 ("python" ,python-2)
2016 ("wget" ,wget)
2017 ("cross-gcc" ,(cross-gcc "i686-linux-gnu"
2018 #:xbinutils (cross-binutils "i686-linux-gnu")
2019 #:libc (cross-libc "i686-linux-gnu")))
2020 ("cross-libc" ,(cross-libc "i686-linux-gnu")) ; header files
2021 ("cross-libc-static" ,(cross-libc "i686-linux-gnu") "static")))
2022 (home-page "https://xenproject.org/")
2023 (synopsis "Xen Virtual Machine Monitor")
2024 (description "This package provides the Xen Virtual Machine Monitor
2025 which is a hypervisor.")
2026 ;; TODO: Some files are licensed differently. List those.
2027 (license license:gpl2)
2028 (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux"))))
2029
2030 (define-public osinfo-db-tools
2031 (package
2032 (name "osinfo-db-tools")
2033 (version "1.8.0")
2034 (source (origin
2035 (method url-fetch)
2036 (uri (string-append "https://releases.pagure.org/libosinfo/osinfo-db-tools-"
2037 version ".tar.xz"))
2038
2039 (sha256
2040 (base32
2041 "038q3gzdbkfkhpicj0755mw1q4gbvn57pslpw8n2dp3lds9im0g9"))))
2042 (build-system meson-build-system)
2043 (inputs
2044 `(("libsoup" ,libsoup)
2045 ("libxml2" ,libxml2)
2046 ("libxslt" ,libxslt)
2047 ("json-glib" ,json-glib)
2048 ("libarchive" ,libarchive)))
2049 (native-inputs
2050 `(("perl" ,perl)
2051 ("gobject-introspection" ,gobject-introspection)
2052 ("gettext" ,gettext-minimal)
2053 ("pkg-config" ,pkg-config)
2054 ;; Tests
2055 ("python" ,python)
2056 ("pytest" ,python-pytest)
2057 ("requests" ,python-requests)))
2058 (home-page "https://gitlab.com/libosinfo/osinfo-db-tools")
2059 (synopsis "Tools for managing the osinfo database")
2060 (description "This package contains a set of tools to assist
2061 administrators and developers in managing the database.")
2062 (license license:lgpl2.0+)))
2063
2064 (define-public osinfo-db
2065 (package
2066 (name "osinfo-db")
2067 (version "20201218")
2068 (source (origin
2069 (method url-fetch)
2070 (uri (string-append "https://releases.pagure.org/libosinfo/osinfo-db-"
2071 version ".tar.xz"))
2072 (sha256
2073 (base32
2074 "0ydbindwgw7kg861rqii5036gq0dbbbmv35dzrmmv937ddfsxwh0"))))
2075 (build-system trivial-build-system)
2076 (arguments
2077 `(#:modules ((guix build utils))
2078 #:builder
2079 (begin
2080 (use-modules (guix build utils))
2081 (let* ((out (assoc-ref %outputs "out"))
2082 (osinfo-dir (string-append out "/share/osinfo"))
2083 (source (assoc-ref %build-inputs "source"))
2084 (osinfo-db-import
2085 (string-append (assoc-ref %build-inputs "osinfo-db-tools")
2086 "/bin/osinfo-db-import")))
2087 (mkdir-p osinfo-dir)
2088 (invoke osinfo-db-import "--dir" osinfo-dir source)
2089 #t))))
2090 (native-inputs
2091 `(("intltool" ,intltool)
2092 ("osinfo-db-tools" ,osinfo-db-tools)))
2093 (home-page "https://gitlab.com/libosinfo/osinfo-db")
2094 (synopsis "Database of information about operating systems")
2095 (description "Osinfo-db provides the database files for use with the
2096 libosinfo library. It provides information about guest operating systems for
2097 use with virtualization provisioning tools")
2098 (license license:lgpl2.0+)))
2099
2100 (define-public python-transient
2101 (package
2102 (name "python-transient")
2103 (version "0.12")
2104 (source
2105 (origin
2106 (method url-fetch)
2107 (uri (pypi-uri "transient" version))
2108 (sha256
2109 (base32
2110 "148yiqrmcscsi6787y0f27i1y9cf0gcw3mqfv5frhpmsmv62mv5z"))))
2111 (build-system python-build-system)
2112 (arguments
2113 `(#:tests? #f ; Requires behave
2114 #:phases (modify-phases %standard-phases
2115 (add-after 'unpack 'fix-dependencies
2116 (lambda _
2117 (substitute* "setup.py"
2118 (("==")
2119 ">="))
2120 #t)))))
2121 (propagated-inputs
2122 `(("python-beautifultable" ,python-beautifultable)
2123 ("python-click" ,python-click)
2124 ("python-importlib-resources"
2125 ,python-importlib-resources)
2126 ("python-lark-parser" ,python-lark-parser)
2127 ("python-marshmallow" ,python-marshmallow)
2128 ("python-progressbar2" ,python-progressbar2)
2129 ("python-requests" ,python-requests)
2130 ("python-toml" ,python-toml)))
2131 (native-inputs
2132 `(("python-black" ,python-black)
2133 ("python-mypy" ,python-mypy)
2134 ("python-pyhamcrest" ,python-pyhamcrest)
2135 ("python-twine" ,python-twine)))
2136 (home-page
2137 "https://github.com/ALSchwalm/transient")
2138 (synopsis
2139 "QEMU Wrapper written in Python")
2140 (description
2141 "@code{transient} is a wrapper for QEMU allowing the creation of virtual
2142 machines with shared folder, ssh, and disk creation support.")
2143 (license license:expat)))