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