e1b780bbe109e910b30235a3eebee2ba16e030f8
[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 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 bison)
47 #:use-module (gnu packages build-tools)
48 #:use-module (gnu packages check)
49 #:use-module (gnu packages cmake)
50 #:use-module (gnu packages compression)
51 #:use-module (gnu packages cross-base)
52 #:use-module (gnu packages curl)
53 #:use-module (gnu packages cyrus-sasl)
54 #:use-module (gnu packages debian)
55 #:use-module (gnu packages disk)
56 #:use-module (gnu packages dns)
57 #:use-module (gnu packages docbook)
58 #:use-module (gnu packages documentation)
59 #:use-module (gnu packages figlet)
60 #:use-module (gnu packages firmware)
61 #:use-module (gnu packages flex)
62 #:use-module (gnu packages fontutils)
63 #:use-module (gnu packages freedesktop)
64 #:use-module (gnu packages gettext)
65 #:use-module (gnu packages gl)
66 #:use-module (gnu packages glib)
67 #:use-module (gnu packages gnome)
68 #:use-module (gnu packages gnupg)
69 #:use-module (gnu packages golang)
70 #:use-module (gnu packages graphviz)
71 #:use-module (gnu packages gtk)
72 #:use-module (gnu packages haskell)
73 #:use-module (gnu packages haskell-apps)
74 #:use-module (gnu packages haskell-check)
75 #:use-module (gnu packages haskell-crypto)
76 #:use-module (gnu packages haskell-web)
77 #:use-module (gnu packages haskell-xyz)
78 #:use-module (gnu packages image)
79 #:use-module (gnu packages libbsd)
80 #:use-module (gnu packages libusb)
81 #:use-module (gnu packages linux)
82 #:use-module (gnu packages m4)
83 #:use-module (gnu packages ncurses)
84 #:use-module (gnu packages nettle)
85 #:use-module (gnu packages networking)
86 #:use-module (gnu packages ninja)
87 #:use-module (gnu packages onc-rpc)
88 #:use-module (gnu packages package-management)
89 #:use-module (gnu packages perl)
90 #:use-module (gnu packages pcre)
91 #:use-module (gnu packages pkg-config)
92 #:use-module (gnu packages polkit)
93 #:use-module (gnu packages protobuf)
94 #:use-module (gnu packages python)
95 #:use-module (gnu packages python-build)
96 #:use-module (gnu packages python-check)
97 #:use-module (gnu packages python-crypto)
98 #:use-module (gnu packages python-web)
99 #:use-module (gnu packages python-xyz)
100 #:use-module (gnu packages pulseaudio)
101 #:use-module (gnu packages selinux)
102 #:use-module (gnu packages sdl)
103 #:use-module (gnu packages sphinx)
104 #:use-module (gnu packages spice)
105 #:use-module (gnu packages ssh)
106 #:use-module (gnu packages texinfo)
107 #:use-module (gnu packages textutils)
108 #:use-module (gnu packages tls)
109 #:use-module (gnu packages web)
110 #:use-module (gnu packages wget)
111 #:use-module (gnu packages xdisorg)
112 #:use-module (gnu packages xml)
113 #:use-module (gnu packages xorg)
114 #:use-module (guix build-system cmake)
115 #:use-module (guix build-system gnu)
116 #:use-module (guix build-system go)
117 #:use-module (guix build-system meson)
118 #:use-module (guix build-system python)
119 #:use-module (guix build-system trivial)
120 #:use-module (guix download)
121 #:use-module (guix git-download)
122 #:use-module ((guix licenses) #:prefix license:)
123 #:use-module (guix packages)
124 #:use-module (guix utils)
125 #:use-module (srfi srfi-1)
126 #:use-module (srfi srfi-26)
127 #:use-module (ice-9 match))
128
129 (define (qemu-patch commit file-name sha256-bv)
130 "Return an origin for COMMIT."
131 (origin
132 (method url-fetch)
133 (uri (string-append
134 "http://git.qemu.org/?p=qemu.git;a=commitdiff_plain;h="
135 commit))
136 (hash (content-hash sha256-bv sha256))
137 (file-name file-name)))
138
139 (define-public qemu
140 (package
141 (name "qemu")
142 (version "5.2.0")
143 (source
144 (origin
145 (method url-fetch)
146 (uri (string-append "https://download.qemu.org/qemu-"
147 version ".tar.xz"))
148 (sha256
149 (base32
150 "1g0pvx4qbirpcn9mni704y03n3lvkmw2c0rbcwvydyr8ns4xh66b"))
151 (patches (search-patches "qemu-CVE-2021-20203.patch"
152 "qemu-build-info-manual.patch"))
153 (modules '((guix build utils)))
154 (snippet
155 '(begin
156 ;; Fix a bug in the do_ioctl_ifconf() function of qemu to
157 ;; make ioctl(…, SIOCGIFCONF, …) work for emulated 64 bit
158 ;; architectures. The size of struct ifreq is handled
159 ;; incorrectly.
160 ;; https://lists.nongnu.org/archive/html/qemu-devel/2021-01/msg01545.html
161 (substitute* '("linux-user/syscall.c")
162 (("^([[:blank:]]*)const argtype ifreq_arg_type.*$" line indent)
163 (string-append line indent "const argtype ifreq_max_type[] = "
164 "{ MK_STRUCT(STRUCT_ifmap_ifreq) };\n"))
165 (("^([[:blank:]]*)target_ifreq_size[[:blank:]]=.*$" _ indent)
166 (string-append indent "target_ifreq_size = "
167 "thunk_type_size(ifreq_max_type, 0);")))
168 ;; Delete the bundled meson copy.
169 (delete-file-recursively "meson")))))
170 (outputs '("out" "static" "doc")) ;5.3 MiB of HTML docs
171 (build-system gnu-build-system)
172 (arguments
173 ;; FIXME: Disable tests on i686 to work around
174 ;; <https://bugs.gnu.org/40527>.
175 `(#:tests? ,(or (%current-target-system)
176 (not (string=? "i686-linux" (%current-system))))
177 #:configure-flags
178 (let ((gcc (string-append (assoc-ref %build-inputs "gcc") "/bin/gcc"))
179 (out (assoc-ref %outputs "out")))
180 (list (string-append "--cc=" gcc)
181 ;; Some architectures insist on using HOST_CC.
182 (string-append "--host-cc=" gcc)
183 (string-append "--prefix=" out)
184 "--sysconfdir=/etc"
185 (string-append "--smbd=" out "/libexec/samba-wrapper")
186 "--disable-debug-info" ;for space considerations
187 ;; The binaries need to be linked against -lrt.
188 (string-append "--extra-ldflags=-lrt")))
189 ;; Make build and test output verbose to facilitate investigation upon failure.
190 #:make-flags '("V=1")
191 #:modules ((srfi srfi-1)
192 (srfi srfi-26)
193 (ice-9 ftw)
194 (ice-9 match)
195 ,@%gnu-build-system-modules)
196 #:phases
197 (modify-phases %standard-phases
198 (add-after 'set-paths 'hide-glibc
199 (lambda* (#:key inputs #:allow-other-keys)
200 ;; Work around https://issues.guix.info/issue/36882. We need to
201 ;; remove glibc from C_INCLUDE_PATH so that the one hardcoded in GCC,
202 ;; at the bottom of GCC include search-path is used.
203 (let* ((filters '("libc"))
204 (input-directories
205 (filter-map (lambda (input)
206 (match input
207 ((name . dir)
208 (and (not (member name filters))
209 dir))))
210 inputs)))
211 (set-path-environment-variable "C_INCLUDE_PATH"
212 '("include")
213 input-directories))))
214 (add-after 'unpack 'extend-test-time-outs
215 (lambda _
216 ;; These tests can time out on heavily-loaded and/or slow storage.
217 (substitute* (cons* "tests/qemu-iotests/common.qemu"
218 (find-files "tests/qemu-iotests" "^[0-9]+$"))
219 (("QEMU_COMM_TIMEOUT=[0-9]+" match)
220 (string-append match "9")))))
221 (add-after 'unpack 'disable-unusable-tests
222 (lambda _
223 (substitute* "tests/meson.build"
224 ;; Comment out the test-qga test, which needs /sys and
225 ;; fails within the build environment.
226 (("tests.*test-qga.*$" all)
227 (string-append "# " all))
228 ;; Comment out the test-char test, which needs networking and
229 ;; fails within the build environment.
230 (("check-unit-.* tests/test-char" all)
231 (string-append "# " all)))))
232 (add-after 'patch-source-shebangs 'patch-embedded-shebangs
233 (lambda _
234 ;; Ensure the executables created by these source files reference
235 ;; /bin/sh from the store so they work inside the build container.
236 (substitute* '("block/cloop.c" "migration/exec.c"
237 "net/tap.c" "tests/qtest/libqtest.c")
238 (("/bin/sh") (which "sh")))
239 (substitute* "Makefile"
240 (("SHELL = /usr/bin/env bash -o pipefail")
241 "SHELL = bash -o pipefail"))
242 (substitute* "tests/qemu-iotests/check"
243 (("#!/usr/bin/env python3")
244 (string-append "#!" (which "python3"))))))
245 (add-before 'configure 'fix-optionrom-makefile
246 (lambda _
247 ;; Work around the inability of the rules defined in this
248 ;; Makefile to locate the firmware files (e.g.: No rule to make
249 ;; target 'multiboot.bin') by extending the VPATH.
250 (substitute* "pc-bios/optionrom/Makefile"
251 (("^VPATH = \\$\\(SRC_DIR\\)")
252 "VPATH = $(SRC_DIR):$(TOPSRC_DIR)/pc-bios"))))
253 ;; XXX ./configure is being re-run at beginning of build phase...
254 (replace 'configure
255 (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
256 ;; The `configure' script doesn't understand some of the
257 ;; GNU options. Thus, add a new phase that's compatible.
258 (let ((out (assoc-ref outputs "out")))
259 (setenv "SHELL" (which "bash"))
260 ;; Ensure config.status gets the correct shebang off the bat.
261 ;; The build system gets confused if we change it later and
262 ;; attempts to re-run the whole configuration, and fails.
263 (substitute* "configure"
264 (("#!/bin/sh")
265 (string-append "#!" (which "sh"))))
266 (mkdir-p "b/qemu")
267 (chdir "b/qemu")
268 (apply invoke "../../configure" configure-flags))))
269 ;; Configure, build and install QEMU user-emulation static binaries.
270 (add-after 'configure 'configure-user-static
271 (lambda* (#:key inputs outputs #:allow-other-keys)
272 (let* ((gcc (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
273 (static (assoc-ref outputs "static"))
274 ;; This is the common set of configure flags; it is
275 ;; duplicated here to isolate this phase from manipulations
276 ;; to the #:configure-flags build argument, as done in
277 ;; derived packages such as qemu-minimal.
278 (configure-flags (list (string-append "--cc=" gcc)
279 (string-append "--host-cc=" gcc)
280 "--sysconfdir=/etc"
281 "--disable-debug-info")))
282 (mkdir-p "../user-static")
283 (with-directory-excursion "../user-static"
284 (apply invoke "../../configure"
285 "--static"
286 "--disable-docs" ;already built
287 "--disable-system"
288 "--enable-linux-user"
289 (string-append "--prefix=" static)
290 configure-flags)))))
291 (add-after 'build 'build-user-static
292 (lambda args
293 (with-directory-excursion "../user-static"
294 (apply (assoc-ref %standard-phases 'build) args))))
295 (add-after 'install 'install-user-static
296 (lambda* (#:key outputs #:allow-other-keys)
297 (let* ((static (assoc-ref outputs "static"))
298 (bin (string-append static "/bin")))
299 (with-directory-excursion "../user-static"
300 (for-each (cut install-file <> bin)
301 (append-map (cut find-files <> "^qemu-" #:stat stat)
302 (scandir "."
303 (cut string-suffix?
304 "-linux-user" <>))))))))
305 ;; Create a wrapper for Samba. This allows QEMU to use Samba without
306 ;; pulling it in as an input. Note that you need to explicitly install
307 ;; Samba in your Guix profile for Samba support.
308 (add-after 'install 'create-samba-wrapper
309 (lambda* (#:key inputs outputs #:allow-other-keys)
310 (let* ((out (assoc-ref outputs "out"))
311 (libexec (string-append out "/libexec")))
312 (call-with-output-file "samba-wrapper"
313 (lambda (port)
314 (format port "#!/bin/sh
315 exec smbd $@")))
316 (chmod "samba-wrapper" #o755)
317 (install-file "samba-wrapper" libexec))))
318 (add-after 'install 'move-html-doc
319 (lambda* (#:key inputs outputs #:allow-other-keys)
320 (let* ((out (assoc-ref outputs "out"))
321 (doc (assoc-ref outputs "doc"))
322 (qemu-doc (string-append doc "/share/doc/qemu-" ,version)))
323 (mkdir-p qemu-doc)
324 (rename-file (string-append out "/share/doc/qemu")
325 (string-append qemu-doc "/html"))))))))
326 (inputs ; TODO: Add optional inputs.
327 `(("alsa-lib" ,alsa-lib)
328 ("attr" ,attr)
329 ("glib" ,glib)
330 ("gtk+" ,gtk+)
331 ("libaio" ,libaio)
332 ("libattr" ,attr)
333 ("libcacard" ,libcacard) ; smartcard support
334 ("libcap-ng" ,libcap-ng) ; virtfs support requires libcap-ng & libattr
335 ("libdrm" ,libdrm)
336 ("libepoxy" ,libepoxy)
337 ("libjpeg" ,libjpeg-turbo)
338 ("libpng" ,libpng)
339 ("libseccomp" ,libseccomp)
340 ("libusb" ,libusb) ;USB pass-through support
341 ("mesa" ,mesa)
342 ("ncurses" ,ncurses)
343 ;; ("pciutils" ,pciutils)
344 ("pixman" ,pixman)
345 ("pulseaudio" ,pulseaudio)
346 ("sdl2" ,sdl2)
347 ("spice" ,spice)
348 ("usbredir" ,usbredir)
349 ("util-linux" ,util-linux)
350 ("vde2" ,vde2)
351 ("virglrenderer" ,virglrenderer)
352 ("zlib" ,zlib)))
353 (native-inputs `(("gettext" ,gettext-minimal)
354 ("glib:bin" ,glib "bin") ; gtester, etc.
355 ("perl" ,perl)
356 ("flex" ,flex)
357 ("bison" ,bison)
358 ;; Using meson 0.57.1 enables reproducible QEMU builds.
359 ("meson" ,meson-next)
360 ("ninja" ,ninja)
361 ("pkg-config" ,pkg-config)
362 ("python-wrapper" ,python-wrapper)
363 ("python-sphinx" ,python-sphinx)
364 ("texinfo" ,texinfo)
365 ;; The following static libraries are required to build
366 ;; the static output of QEMU.
367 ("glib-static" ,glib-static)
368 ("pcre:static" ,pcre "static")
369 ("zlib:static" ,zlib "static")))
370 (home-page "https://www.qemu.org")
371 (synopsis "Machine emulator and virtualizer")
372 (description
373 "QEMU is a generic machine emulator and virtualizer.
374
375 When used as a machine emulator, QEMU can run OSes and programs made for one
376 machine (e.g. an ARM board) on a different machine---e.g., your own PC. By
377 using dynamic translation, it achieves very good performance.
378
379 When used as a virtualizer, QEMU achieves near native performances by
380 executing the guest code directly on the host CPU. QEMU supports
381 virtualization when executing under the Xen hypervisor or using
382 the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86,
383 server and embedded PowerPC, and S390 guests.")
384
385 ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
386 (license license:gpl2)
387
388 ;; Several tests fail on MIPS; see <http://hydra.gnu.org/build/117914>.
389 (supported-systems (fold delete %supported-systems
390 '("mips64el-linux" "i586-gnu")))))
391
392 (define-public qemu-minimal
393 ;; QEMU without GUI support, only supporting the host's architecture
394 (package
395 (inherit qemu)
396 (name "qemu-minimal")
397 (synopsis
398 "Machine emulator and virtualizer (without GUI) for the host architecture")
399 (arguments
400 (substitute-keyword-arguments (package-arguments qemu)
401 ((#:configure-flags configure-flags '(list))
402 ;; Restrict to the host's architecture.
403 (let* ((system (or (%current-target-system)
404 (%current-system)))
405 (target-list-arg
406 (match system
407 ((? (cut string-prefix? "i686" <>))
408 "--target-list=i386-softmmu")
409 ((? (cut string-prefix? "x86_64" <>))
410 "--target-list=i386-softmmu,x86_64-softmmu")
411 ((? (cut string-prefix? "mips64" <>))
412 (string-append "--target-list=mips-softmmu,mipsel-softmmu,"
413 "mips64-softmmu,mips64el-softmmu"))
414 ((? (cut string-prefix? "mips" <>))
415 "--target-list=mips-softmmu,mipsel-softmmu")
416 ((? (cut string-prefix? "aarch64" <>))
417 "--target-list=arm-softmmu,aarch64-softmmu")
418 ((? (cut string-prefix? "arm" <>))
419 "--target-list=arm-softmmu")
420 ((? (cut string-prefix? "alpha" <>))
421 "--target-list=alpha-softmmu")
422 ((? (cut string-prefix? "powerpc64" <>))
423 "--target-list=ppc-softmmu,ppc64-softmmu")
424 ((? (cut string-prefix? "powerpc" <>))
425 "--target-list=ppc-softmmu")
426 ((? (cut string-prefix? "s390" <>))
427 "--target-list=s390x-softmmu")
428 ((? (cut string-prefix? "riscv" <>))
429 "--target-list=riscv32-softmmu,riscv64-softmmu")
430 (else ; An empty list actually builds all the targets.
431 '()))))
432 `(cons ,target-list-arg ,configure-flags)))))
433
434 ;; Remove dependencies on optional libraries, notably GUI libraries.
435 (native-inputs (fold alist-delete (package-native-inputs qemu)
436 '("gettext")))
437 (inputs (fold alist-delete (package-inputs qemu)
438 '("libusb" "mesa" "sdl2" "spice" "virglrenderer" "gtk+"
439 "usbredir" "libdrm" "libepoxy" "pulseaudio" "vde2"
440 "libcacard")))))
441
442 (define (system->qemu-target system)
443 (cond
444 ((string-prefix? "i686" system)
445 "qemu-system-i386")
446 ((string-prefix? "arm" system)
447 "qemu-system-arm")
448 (else
449 (string-append "qemu-system-" (match (string-split system #\-)
450 ((arch kernel) arch)
451 (_ system))))))
452
453 (define-public ganeti
454 (package
455 (name "ganeti")
456 ;; Note: we use a pre-release for Python 3 compatibility as well as many
457 ;; other fixes.
458 (version "3.0.0beta1-24-g024cc9fa2")
459 (source (origin
460 (method git-fetch)
461 (uri (git-reference
462 (url "https://github.com/ganeti/ganeti")
463 (commit (string-append "v" version))))
464 (sha256
465 (base32 "1ll34qd2mifni3bhg7cnir3xfnkafig8ch33qndqwrsby0y5ssia"))
466 (file-name (git-file-name name version))
467 (patches (search-patches "ganeti-shepherd-support.patch"
468 "ganeti-shepherd-master-failover.patch"
469 "ganeti-deterministic-manual.patch"
470 "ganeti-drbd-compat.patch"
471 "ganeti-os-disk-size.patch"
472 "ganeti-haskell-pythondir.patch"
473 "ganeti-disable-version-symlinks.patch"
474 "ganeti-preserve-PYTHONPATH.patch"))))
475 (build-system gnu-build-system)
476 (arguments
477 `(#:imported-modules (,@%gnu-build-system-modules
478 (guix build haskell-build-system)
479 (guix build python-build-system))
480 #:modules (,@%gnu-build-system-modules
481 ((guix build haskell-build-system) #:prefix haskell:)
482 ((guix build python-build-system) #:select (python-version))
483 (ice-9 rdelim))
484
485 ;; The default test target includes a lot of checks that are only really
486 ;; relevant for developers such as NEWS file checking, line lengths, etc.
487 ;; We are only interested in the "py-tests" and "hs-tests" targets: this
488 ;; is the closest we've got even though it includes a little more.
489 #:test-target "check-TESTS"
490
491 #:configure-flags
492 (list "--localstatedir=/var"
493 "--sharedstatedir=/var"
494 "--sysconfdir=/etc"
495 "--enable-haskell-tests"
496
497 ;; By default, the build system installs everything to versioned
498 ;; directories such as $libdir/3.0 and relies on a $libdir/default
499 ;; symlink pointed from /etc/ganeti/{lib,share} to actually function.
500 ;; This is done to accommodate installing multiple versions in
501 ;; parallel, but is of little use to us as Guix users can just
502 ;; roll back and forth. Thus, disable it for simplicity.
503 "--disable-version-links"
504
505 ;; Ganeti can optionally take control over SSH host keys and
506 ;; distribute them to nodes as they are added, and also rotate keys
507 ;; with 'gnt-cluster renew-crypto --new-ssh-keys'. Thus it needs to
508 ;; know how to restart the SSH daemon.
509 "--with-sshd-restart-command='herd restart ssh-daemon'"
510
511 ;; Look for OS definitions in this directory by default. It can
512 ;; be changed in the cluster configuration.
513 "--with-os-search-path=/run/current-system/profile/share/ganeti/os"
514
515 ;; The default QEMU executable to use. We don't use the package
516 ;; here because this entry is stored in the cluster configuration.
517 (string-append "--with-kvm-path=/run/current-system/profile/bin/"
518 ,(system->qemu-target (%current-system))))
519 #:phases
520 (modify-phases %standard-phases
521 (add-after 'unpack 'create-vcs-version
522 (lambda _
523 ;; If we are building from a git checkout, we need to create a
524 ;; 'vcs-version' file manually because the build system does
525 ;; not have access to the git repository information.
526 (unless (file-exists? "vcs-version")
527 (call-with-output-file "vcs-version"
528 (lambda (port)
529 (format port "v~a~%" ,version))))
530 #t))
531 (add-after 'unpack 'patch-absolute-file-names
532 (lambda _
533 (substitute* '("lib/utils/process.py"
534 "lib/utils/text.py"
535 "src/Ganeti/Constants.hs"
536 "src/Ganeti/HTools/CLI.hs"
537 "test/py/ganeti.config_unittest.py"
538 "test/py/ganeti.hooks_unittest.py"
539 "test/py/ganeti.utils.process_unittest.py"
540 "test/py/ganeti.utils.text_unittest.py"
541 "test/py/ganeti.utils.wrapper_unittest.py")
542 (("/bin/sh") (which "sh"))
543 (("/bin/bash") (which "bash"))
544 (("/usr/bin/env") (which "env"))
545 (("/bin/true") (which "true")))
546
547 ;; This script is called by the node daemon at startup to perform
548 ;; sanity checks on the cluster IP addresses, and it is also used
549 ;; in a master-failover scenario. Add absolute references to
550 ;; avoid propagating these executables.
551 (substitute* "tools/master-ip-setup"
552 (("arping") (which "arping"))
553 (("ndisc6") (which "ndisc6"))
554 (("fping") (which "fping"))
555 (("grep") (which "grep"))
556 (("ip addr") (string-append (which "ip") " addr")))
557 #t))
558 (add-after 'unpack 'override-builtin-PATH
559 (lambda _
560 ;; Ganeti runs OS install scripts and similar with a built-in
561 ;; hard coded PATH. Patch so it works on Guix System.
562 (substitute* "src/Ganeti/Constants.hs"
563 (("/sbin:/bin:/usr/sbin:/usr/bin")
564 "/run/setuid-programs:/run/current-system/profile/sbin:\
565 /run/current-system/profile/bin"))
566 #t))
567 (add-after 'bootstrap 'patch-sphinx-version-detection
568 (lambda _
569 ;; The build system runs 'sphinx-build --version' to verify that
570 ;; the Sphinx is recent enough, but does not expect the
571 ;; .sphinx-build-real executable name created by the Sphinx wrapper.
572 (substitute* "configure"
573 (("\\$SPHINX --version 2>&1")
574 "$SPHINX --version 2>&1 | sed 's/.sphinx-build-real/sphinx-build/g'"))
575 #t))
576
577 ;; The build system invokes Cabal and GHC, which do not work with
578 ;; GHC_PACKAGE_PATH: <https://github.com/haskell/cabal/issues/3728>.
579 ;; Tweak the build system to do roughly what haskell-build-system does.
580 (add-before 'configure 'configure-haskell
581 (assoc-ref haskell:%standard-phases 'setup-compiler))
582 (add-after 'configure 'do-not-use-GHC_PACKAGE_PATH
583 (lambda _
584 (unsetenv "GHC_PACKAGE_PATH")
585 (substitute* "Makefile"
586 (("\\$\\(CABAL\\)")
587 "$(CABAL) --package-db=../package.conf.d")
588 (("\\$\\(GHC\\)")
589 "$(GHC) -package-db=../package.conf.d"))
590 #t))
591 (add-after 'configure 'make-ghc-use-shared-libraries
592 (lambda _
593 (substitute* "Makefile"
594 (("HFLAGS =") "HFLAGS = -dynamic -fPIC"))
595 #t))
596 (add-after 'configure 'fix-installation-directories
597 (lambda _
598 (substitute* "Makefile"
599 ;; Do not attempt to create /var during install.
600 (("\\$\\(DESTDIR\\)\\$\\{localstatedir\\}")
601 "$(DESTDIR)${prefix}${localstatedir}")
602 ;; Similarly, do not attempt to install the sample ifup scripts
603 ;; to /etc/ganeti.
604 (("\\$\\(DESTDIR\\)\\$\\(ifupdir\\)")
605 "$(DESTDIR)${prefix}$(ifupdir)"))
606 #t))
607 (add-before 'build 'adjust-tests
608 (lambda _
609 ;; Disable tests that can not run. Do it early to prevent
610 ;; touching the Makefile later and triggering a needless rebuild.
611 (substitute* "Makefile"
612 ;; These tests expect the presence of a 'root' user (via
613 ;; ganeti/runtime.py), which fails in the build environment.
614 (("test/py/ganeti\\.asyncnotifier_unittest\\.py") "")
615 (("test/py/ganeti\\.backend_unittest\\.py") "")
616 (("test/py/ganeti\\.daemon_unittest\\.py") "")
617 (("test/py/ganeti\\.tools\\.ensure_dirs_unittest\\.py") "")
618 (("test/py/ganeti\\.utils\\.io_unittest-runasroot\\.py") "")
619 ;; Disable the bash_completion test, as it requires the full
620 ;; bash instead of bash-minimal.
621 (("test/py/bash_completion\\.bash")
622 "")
623 ;; This test requires networking.
624 (("test/py/import-export_unittest\\.bash")
625 ""))
626
627 ;; Many of the Makefile targets reset PYTHONPATH before running
628 ;; the Python interpreter, which does not work very well for us.
629 (substitute* "Makefile"
630 (("PYTHONPATH=")
631 (string-append "PYTHONPATH=" (getenv "PYTHONPATH") ":")))
632 #t))
633 (add-after 'build 'build-bash-completions
634 (lambda _
635 (let ((orig-pythonpath (getenv "PYTHONPATH")))
636 (setenv "PYTHONPATH" (string-append ".:" orig-pythonpath))
637 (invoke "./autotools/build-bash-completion")
638 (setenv "PYTHONPATH" orig-pythonpath)
639 #t)))
640 (add-before 'check 'pre-check
641 (lambda* (#:key inputs #:allow-other-keys)
642 ;; Set TZDIR so that time zones are found.
643 (setenv "TZDIR" (string-append (assoc-ref inputs "tzdata")
644 "/share/zoneinfo"))
645
646 ;; This test checks whether PYTHONPATH is untouched, and extends
647 ;; it to include test directories if so. Add an else branch for
648 ;; our modified PYTHONPATH, in order to prevent a confusing test
649 ;; failure where expired certificates are not cleaned because
650 ;; check-cert-expired is silently crashing.
651 (substitute* "test/py/ganeti-cleaner_unittest.bash"
652 (("then export PYTHONPATH=(.*)" all testpath)
653 (string-append all "else export PYTHONPATH="
654 (getenv "PYTHONPATH") ":" testpath "\n")))
655
656 (substitute* "test/py/ganeti.utils.process_unittest.py"
657 ;; This test attempts to run an executable with
658 ;; RunCmd(..., reset_env=True), which fails because the default
659 ;; PATH from Constants.hs does not exist in the build container.
660 ((".*def testResetEnv.*" all)
661 (string-append " @unittest.skipIf(True, "
662 "\"cannot reset env in the build container\")\n"
663 all))
664
665 ;; XXX: Somehow this test fails in the build container, but
666 ;; works in 'guix environment -C', even without /bin/sh?
667 ((".*def testPidFile.*" all)
668 (string-append " @unittest.skipIf(True, "
669 "\"testPidFile fails in the build container\")\n"
670 all)))
671
672 ;; XXX: Why are these links not added automatically.
673 (with-directory-excursion "test/hs"
674 (for-each (lambda (file)
675 (symlink "../../src/htools" file))
676 '("hspace" "hscan" "hinfo" "hbal" "hroller"
677 "hcheck" "hail" "hsqueeze")))
678 #t))
679 (add-after 'install 'install-bash-completions
680 (lambda* (#:key outputs #:allow-other-keys)
681 (let* ((out (assoc-ref outputs "out"))
682 (compdir (string-append out "/etc/bash_completion.d")))
683 (mkdir-p compdir)
684 (copy-file "doc/examples/bash_completion"
685 (string-append compdir "/ganeti"))
686 ;; The one file contains completions for many different
687 ;; executables. Create symlinks for found completions.
688 (with-directory-excursion compdir
689 (for-each
690 (lambda (prog) (symlink "ganeti" prog))
691 (call-with-input-file "ganeti"
692 (lambda (port)
693 (let loop ((line (read-line port))
694 (progs '()))
695 (if (eof-object? line)
696 progs
697 (if (string-prefix? "complete" line)
698 (loop (read-line port)
699 ;; Extract "prog" from lines of the form:
700 ;; "complete -F _prog -o filenames prog".
701 ;; Note that 'burnin' is listed with the
702 ;; absolute file name, which is why we
703 ;; run everything through 'basename'.
704 (cons (basename (car (reverse (string-split
705 line #\ ))))
706 progs))
707 (loop (read-line port) progs))))))))
708 #t)))
709 ;; Wrap all executables with PYTHONPATH. We can't borrow the phase
710 ;; from python-build-system because we also need to wrap the scripts
711 ;; in $out/lib/ganeti such as "node-daemon-setup".
712 (add-after 'install 'wrap
713 (lambda* (#:key inputs outputs #:allow-other-keys)
714 (let* ((out (assoc-ref outputs "out"))
715 (sbin (string-append out "/sbin"))
716 (lib (string-append out "/lib"))
717 (python (assoc-ref inputs "python"))
718 (major+minor (python-version python))
719 (PYTHONPATH (string-append lib "/python" major+minor
720 "/site-packages:"
721 (getenv "PYTHONPATH"))))
722 (define (shell-script? file)
723 (call-with-ascii-input-file file
724 (lambda (port)
725 (let ((shebang (false-if-exception (read-line port))))
726 (and shebang
727 (string-prefix? "#!" shebang)
728 (or (string-contains shebang "/bin/bash")
729 (string-contains shebang "/bin/sh")))))))
730
731 (define (wrap? file)
732 ;; Do not wrap shell scripts because some are meant to be
733 ;; sourced, which breaks if they are wrapped. We do wrap
734 ;; the Haskell executables because some call out to Python
735 ;; directly.
736 (and (executable-file? file)
737 (not (symbolic-link? file))
738 (not (shell-script? file))))
739
740 (for-each (lambda (file)
741 (wrap-program file
742 `("PYTHONPATH" ":" prefix (,PYTHONPATH))))
743 (filter wrap?
744 (append (find-files (string-append lib "/ganeti"))
745 (find-files sbin))))
746 #t))))))
747 (native-inputs
748 `(("haskell" ,ghc)
749 ("cabal" ,cabal-install)
750 ("m4" ,m4)
751
752 ;; These inputs are necessary to bootstrap the package, because we
753 ;; have patched the build system.
754 ("autoconf" ,autoconf)
755 ("automake" ,automake)
756
757 ;; For the documentation.
758 ("python-docutils" ,python-docutils)
759 ("sphinx" ,python-sphinx)
760 ("pandoc" ,pandoc)
761 ("dot" ,graphviz)
762
763 ;; Test dependencies.
764 ("fakeroot" ,fakeroot)
765 ("ghc-temporary" ,ghc-temporary)
766 ("ghc-test-framework" ,ghc-test-framework)
767 ("ghc-test-framework-hunit" ,ghc-test-framework-hunit)
768 ("ghc-test-framework-quickcheck2" ,ghc-test-framework-quickcheck2)
769 ("python-mock" ,python-mock)
770 ("python-pyyaml" ,python-pyyaml)
771 ("openssh" ,openssh)
772 ("procps" ,procps)
773 ("shelltestrunner" ,shelltestrunner)
774 ("tzdata" ,tzdata-for-tests)))
775 (inputs
776 `(("arping" ,iputils) ;must be the iputils version
777 ("curl" ,curl)
778 ("fping" ,fping)
779 ("iproute2" ,iproute)
780 ("ndisc6" ,ndisc6)
781 ("socat" ,socat)
782 ("qemu" ,qemu-minimal) ;for qemu-img
783 ("ghc-attoparsec" ,ghc-attoparsec)
784 ("ghc-base64-bytestring" ,ghc-base64-bytestring)
785 ("ghc-cryptonite" ,ghc-cryptonite)
786 ("ghc-curl" ,ghc-curl)
787 ("ghc-hinotify" ,ghc-hinotify)
788 ("ghc-hslogger" ,ghc-hslogger)
789 ("ghc-json" ,ghc-json)
790 ("ghc-lens" ,ghc-lens)
791 ("ghc-lifted-base" ,ghc-lifted-base)
792 ("ghc-network" ,ghc-network)
793 ("ghc-old-time" ,ghc-old-time)
794 ("ghc-psqueue" ,ghc-psqueue)
795 ("ghc-regex-pcre" ,ghc-regex-pcre)
796 ("ghc-utf8-string" ,ghc-utf8-string)
797 ("ghc-zlib" ,ghc-zlib)
798
799 ;; For the optional metadata daemon.
800 ("ghc-snap-core" ,ghc-snap-core)
801 ("ghc-snap-server" ,ghc-snap-server)
802
803 ("python" ,python)
804 ("python-pyopenssl" ,python-pyopenssl)
805 ("python-simplejson" ,python-simplejson)
806 ("python-pyparsing" ,python-pyparsing)
807 ("python-pyinotify" ,python-pyinotify)
808 ("python-pycurl" ,python-pycurl)
809 ("python-bitarray" ,python-bitarray)
810 ("python-paramiko" ,python-paramiko)
811 ("python-psutil" ,python-psutil)))
812 (home-page "https://www.ganeti.org/")
813 (synopsis "Cluster-based virtual machine management system")
814 (description
815 "Ganeti is a virtual machine management tool built on top of existing
816 virtualization technologies such as Xen or KVM. Ganeti controls:
817
818 @itemize @bullet
819 @item Disk creation management;
820 @item Operating system installation for instances (in co-operation with
821 OS-specific install scripts); and
822 @item Startup, shutdown, and failover between physical systems.
823 @end itemize
824
825 Ganeti is designed to facilitate cluster management of virtual servers and
826 to provide fast and simple recovery after physical failures, using
827 commodity hardware.")
828 (license license:bsd-2)))
829
830 (define-public ganeti-instance-guix
831 (package
832 (name "ganeti-instance-guix")
833 (version "0.6")
834 (home-page "https://github.com/mbakke/ganeti-instance-guix")
835 (source (origin
836 (method git-fetch)
837 (uri (git-reference (url home-page) (commit version)))
838 (file-name (git-file-name name version))
839 (sha256
840 (base32
841 "0aa08irpcpns6mhjgsplc5f0p8ab1qcr9ah1gj5z66kxgqyflzrp"))))
842 (build-system gnu-build-system)
843 (arguments
844 '(#:configure-flags '("--sysconfdir=/etc" "--localstatedir=/var")))
845 (native-inputs
846 `(("autoconf" ,autoconf)
847 ("automake" ,automake)))
848 (inputs
849 `(("util-linux" ,util-linux)
850 ("qemu-img" ,qemu-minimal)))
851 (synopsis "Guix OS integration for Ganeti")
852 (description
853 "This package provides a guest OS definition for Ganeti that uses
854 Guix to build virtual machines.")
855 (license license:gpl3+)))
856
857 (define-public ganeti-instance-debootstrap
858 (package
859 (name "ganeti-instance-debootstrap")
860 ;; We need two commits on top of the latest release for compatibility
861 ;; with newer sfdisk, as well as gnt-network integration.
862 (version "0.16-2-ge145396")
863 (home-page "https://github.com/ganeti/instance-debootstrap")
864 (source (origin
865 (method git-fetch)
866 (uri (git-reference (url home-page) (commit version)))
867 (file-name (git-file-name name version))
868 (sha256
869 (base32
870 "0f2isw9d8lawzj21rrq1q9xhq8xfa65rqbhqmrn59z201x9q1336"))))
871 (build-system gnu-build-system)
872 (arguments
873 '(#:configure-flags '("--sysconfdir=/etc" "--localstatedir=/var")
874 #:phases (modify-phases %standard-phases
875 (add-after 'unpack 'add-absolute-references
876 (lambda _
877 (substitute* "common.sh.in"
878 (("/sbin/blkid") (which "blkid"))
879 (("kpartx -")
880 (string-append (which "kpartx") " -")))
881 (substitute* "import"
882 (("restore -r")
883 (string-append (which "restore") " -r")))
884 (substitute* "export"
885 (("dump -0")
886 (string-append (which "dump") " -0")))
887 (substitute* "create"
888 (("debootstrap") (which "debootstrap"))
889 (("`which run-parts`") (which "run-parts"))
890 ;; Here we actually need to hard code /bin/passwd
891 ;; because it's called via chroot, which fails if
892 ;; "/bin" is not in PATH.
893 (("passwd") "/bin/passwd"))
894 #t))
895 (add-after 'unpack 'set-dpkg-arch
896 (lambda* (#:key system #:allow-other-keys)
897 ;; The create script passes --arch to debootstrap,
898 ;; and defaults to `dpkg --print-architecture` when
899 ;; ARCH is not set in variant.conf. Hard code the
900 ;; build-time architecture to avoid the dpkg dependency.
901 (let ((dpkg-arch
902 (cond ((string-prefix? "x86_64" system)
903 "amd64")
904 ((string-prefix? "i686" system)
905 "i386")
906 ((string-prefix? "aarch64" system)
907 "arm64")
908 (else (car (string-split system #\-))))))
909 (substitute* "create"
910 (("`dpkg --print-architecture`")
911 dpkg-arch))
912 #t)))
913 (add-after 'configure 'adjust-Makefile
914 (lambda _
915 ;; Do not attempt to create /etc/ganeti/instance-debootstrap
916 ;; and /etc/default/ganeti-instance-debootstrap during install.
917 ;; They are created by the Ganeti service.
918 (substitute* "Makefile"
919 (("\\$\\(variantsdir\\)")
920 "$(prefix)/etc/ganeti/instance-debootstrap/variants")
921 (("\\$\\(defaultsdir\\)")
922 "$(prefix)/etc/default/ganeti-instance-debootstrap"))
923 #t))
924 (add-after 'install 'make-variants.list-symlink
925 (lambda* (#:key outputs #:allow-other-keys)
926 ;; The Ganeti OS API mandates a variants.list file that
927 ;; describes all supported "variants" of this OS.
928 ;; Guix generates this file, so make the original file
929 ;; a symlink to it.
930 (with-directory-excursion (string-append
931 (assoc-ref outputs "out")
932 "/share/ganeti/os/debootstrap")
933 (delete-file "variants.list")
934 (symlink "/etc/ganeti/instance-debootstrap/variants/variants.list"
935 "variants.list"))
936 #t)))))
937 (native-inputs
938 `(("autoconf" ,autoconf)
939 ("automake" ,automake)))
940 (inputs
941 `(("debianutils" ,debianutils)
942 ("debootstrap" ,debootstrap)
943 ("dump" ,dump)
944 ("kpartx" ,multipath-tools)
945 ("util-linux" ,util-linux)))
946 (synopsis "Debian OS integration for Ganeti")
947 (description
948 "This package provides a guest OS definition for Ganeti. It installs
949 Debian or a derivative using @command{debootstrap}.")
950 (license license:gpl2+)))
951
952 (define-public libosinfo
953 (package
954 (name "libosinfo")
955 (version "1.7.1")
956 (source
957 (origin
958 (method url-fetch)
959 (uri (string-append "https://releases.pagure.org/libosinfo/libosinfo-"
960 version ".tar.xz"))
961 (sha256
962 (base32
963 "1s97sv24bybggjx6hgqba2qdqz3ivfpd4cmkh4zm5y59sim109mv"))))
964 (build-system meson-build-system)
965 (arguments
966 `(#:configure-flags
967 (list (string-append "-Dwith-usb-ids-path="
968 (assoc-ref %build-inputs "usb.ids"))
969 (string-append "-Dwith-pci-ids-path="
970 (assoc-ref %build-inputs "pci.ids")))
971 #:phases
972 (modify-phases %standard-phases
973 (add-after 'unpack 'patch-osinfo-path
974 (lambda* (#:key inputs #:allow-other-keys)
975 (substitute* "osinfo/osinfo_loader.c"
976 (("path = DATA_DIR.*")
977 (string-append "path = \"" (assoc-ref inputs "osinfo-db")
978 "/share/osinfo\";")))
979 #t)))))
980 (inputs
981 `(("libsoup" ,libsoup)
982 ("libxml2" ,libxml2)
983 ("libxslt" ,libxslt)
984 ("osinfo-db" ,osinfo-db)))
985 (native-inputs
986 `(("glib" ,glib "bin") ; glib-mkenums, etc.
987 ("gobject-introspection" ,gobject-introspection)
988 ("gtk-doc" ,gtk-doc/stable)
989 ("vala" ,vala)
990 ("intltool" ,intltool)
991 ("pkg-config" ,pkg-config)
992 ("pci.ids"
993 ,(origin
994 (method url-fetch)
995 (uri "https://github.com/pciutils/pciids/raw/ad02084f0bc143e3c15e31a6152a3dfb1d7a3156/pci.ids")
996 (sha256
997 (base32
998 "0kfhpj5rnh24hz2714qhfmxk281vwc2w50sm73ggw5d15af7zfsw"))))
999 ("usb.ids"
1000 ,(origin
1001 (method url-fetch)
1002 (uri "https://svn.code.sf.net/p/linux-usb/repo/trunk/htdocs/usb.ids?r=2681")
1003 (file-name "usb.ids")
1004 (sha256
1005 (base32
1006 "1m6yhvz5k8aqzxgk7xj3jkk8frl1hbv0h3vgj4wbnvnx79qnvz3r"))))))
1007 (home-page "https://libosinfo.org/")
1008 (synopsis "Operating system information database")
1009 (description "libosinfo is a GObject based library API for managing
1010 information about operating systems, hypervisors and the (virtual) hardware
1011 devices they can support. It includes a database containing device metadata
1012 and provides APIs to match/identify optimal devices for deploying an operating
1013 system on a hypervisor. Via GObject Introspection, the API is available in
1014 all common programming languages. Vala bindings are also provided.")
1015 ;; The library files are released under LGPLv2.1 or later; the source
1016 ;; files in the "tools" directory are released under GPLv2+.
1017 (license (list license:lgpl2.1+ license:gpl2+))))
1018
1019 (define-public lxc
1020 (package
1021 (name "lxc")
1022 (version "4.0.6")
1023 (source (origin
1024 (method url-fetch)
1025 (uri (string-append
1026 "https://linuxcontainers.org/downloads/lxc/lxc-"
1027 version ".tar.gz"))
1028 (sha256
1029 (base32
1030 "0qz4l7mlhq7hx53q606qgvkyzyr01glsw290v8ppzvxn1fydlrci"))))
1031 (build-system gnu-build-system)
1032 (native-inputs
1033 `(("pkg-config" ,pkg-config)))
1034 (inputs
1035 `(("gnutls" ,gnutls)
1036 ("libcap" ,libcap)
1037 ("libseccomp" ,libseccomp)
1038 ("libselinux" ,libselinux)))
1039 (arguments
1040 `(#:configure-flags
1041 (list (string-append "--docdir=" (assoc-ref %outputs "out")
1042 "/share/doc/" ,name "-" ,version)
1043 "--sysconfdir=/etc"
1044 "--localstatedir=/var")
1045 #:phases
1046 (modify-phases %standard-phases
1047 (replace 'install
1048 (lambda* (#:key outputs #:allow-other-keys)
1049 (let* ((out (assoc-ref outputs "out"))
1050 (bashcompdir (string-append out "/etc/bash_completion.d")))
1051 (invoke "make" "install"
1052 (string-append "bashcompdir=" bashcompdir)
1053 ;; Don't install files into /var and /etc.
1054 "LXCPATH=/tmp/var/lib/lxc"
1055 "localstatedir=/tmp/var"
1056 "sysconfdir=/tmp/etc"
1057 "sysconfigdir=/tmp/etc/default")))))))
1058 (synopsis "Linux container tools")
1059 (home-page "https://linuxcontainers.org/")
1060 (description
1061 "LXC is a userspace interface for the Linux kernel containment features.
1062 Through a powerful API and simple tools, it lets Linux users easily create and
1063 manage system or application containers.")
1064 (license license:lgpl2.1+)))
1065
1066 (define-public libvirt
1067 (package
1068 (name "libvirt")
1069 (version "7.1.0")
1070 (source
1071 (origin
1072 (method url-fetch)
1073 (uri (string-append "https://libvirt.org/sources/libvirt-"
1074 version ".tar.xz"))
1075 (sha256
1076 (base32 "0v50ckf56h6jd9bmqwp0lh2cmb7qqjmcb6y3mz2i2r15h06ih3w7"))
1077 (patches
1078 (search-patches "libvirt-do-not-create-var-dirs.patch"))))
1079 (build-system meson-build-system)
1080 (arguments
1081 `(#:meson ,meson-0.55 ;; libvirt requires meson 0.54 or higher.
1082 #:configure-flags
1083 (list "-Ddriver_qemu=enabled"
1084 "-Dqemu_user=nobody"
1085 "-Dqemu_group=kvm"
1086 "-Dpolkit=enabled")
1087 #:phases
1088 (modify-phases %standard-phases
1089 (add-after 'unpack 'fix-sysconfdir-and-localstatedir
1090 (lambda _
1091 (substitute* "meson.build"
1092 ;; We set the prefix to be the package output, but we need
1093 ;; localstatedir to be /var. Sadly the build system doesn't
1094 ;; seem to allow that easily.
1095 (("localstatedir = prefix / get_option\\('localstatedir'\\)")
1096 "localstatedir = get_option('localstatedir')")
1097 ;; On the other hand, we keep sysconfdir using the prefix so
1098 ;; that we install configuration files in the package output.
1099 ;; However, we need to make sure the C code refers to /etc via
1100 ;; SYSCONFDIR, and not the read-only configuration in the
1101 ;; package output.
1102 (("set_quoted\\('SYSCONFDIR', sysconfdir\\)")
1103 "set_quoted('SYSCONFDIR', '/etc')"))
1104 #t))
1105 (add-before 'configure 'disable-broken-tests
1106 (lambda _
1107 (substitute* "tests/meson.build"
1108 (("\\{ 'name': 'commandtest'.*") "") ; hangs idly
1109 (("\\{ 'name': 'qemuxml2argvtest'.*") "") ; fails
1110 (("\\{ 'name': 'virnetsockettest'.*") "")) ; tries to network
1111 #t)))))
1112 (inputs
1113 `(("libxml2" ,libxml2)
1114 ("eudev" ,eudev)
1115 ("libpciaccess" ,libpciaccess)
1116 ("gnutls" ,gnutls)
1117 ("dbus" ,dbus)
1118 ("libpcap" ,libpcap)
1119 ("libnl" ,libnl)
1120 ("libtirpc" ,libtirpc) ;for <rpc/rpc.h>
1121 ("libuuid" ,util-linux "lib")
1122 ("lvm2" ,lvm2) ;for libdevmapper
1123 ("curl" ,curl)
1124 ("openssl" ,openssl)
1125 ("cyrus-sasl" ,cyrus-sasl)
1126 ("libyajl" ,libyajl)
1127 ("audit" ,audit)
1128 ("dmidecode" ,dmidecode)
1129 ("dnsmasq" ,dnsmasq)
1130 ("ebtables" ,ebtables)
1131 ("iproute" ,iproute)
1132 ("iptables" ,iptables)))
1133 (native-inputs
1134 `(("xsltproc" ,libxslt)
1135 ("perl" ,perl)
1136 ("pkg-config" ,pkg-config)
1137 ("polkit" ,polkit)
1138 ("python" ,python-wrapper)
1139 ("python-docutils" ,python-docutils) ;for rst2html
1140 ("rpcsvc-proto" ,rpcsvc-proto))) ;for 'rpcgen'
1141 (home-page "https://libvirt.org")
1142 (synopsis "Simple API for virtualization")
1143 (description "Libvirt is a C toolkit to interact with the virtualization
1144 capabilities of recent versions of Linux. The library aims at providing long
1145 term stable C API initially for the Xen paravirtualization but should be able
1146 to integrate other virtualization mechanisms if needed.")
1147 (license license:lgpl2.1+)))
1148
1149 (define-public libvirt-glib
1150 (package
1151 (name "libvirt-glib")
1152 (version "3.0.0")
1153 (source (origin
1154 (method url-fetch)
1155 (uri (string-append "ftp://libvirt.org/libvirt/glib/"
1156 "libvirt-glib-" version ".tar.gz"))
1157 (sha256
1158 (base32
1159 "1zpbv4ninc57c9rw4zmmkvvqn7154iv1qfr20kyxn8xplalqrzvz"))))
1160 (build-system gnu-build-system)
1161 (inputs
1162 `(("openssl" ,openssl)
1163 ("cyrus-sasl" ,cyrus-sasl)
1164 ("lvm2" ,lvm2) ; for libdevmapper
1165 ("libyajl" ,libyajl)))
1166 (native-inputs
1167 `(("pkg-config" ,pkg-config)
1168 ("intltool" ,intltool)
1169 ("glib" ,glib "bin")
1170 ("vala" ,vala)))
1171 (propagated-inputs
1172 ;; ‘Required:’ by the installed .pc files.
1173 `(("glib" ,glib)
1174 ("libvirt" ,libvirt)
1175 ("libxml2" ,libxml2)
1176 ("gobject-introspection" ,gobject-introspection)))
1177 (home-page "https://libvirt.org")
1178 (synopsis "GLib wrapper around libvirt")
1179 (description "libvirt-glib wraps the libvirt library to provide a
1180 high-level object-oriented API better suited for glib-based applications, via
1181 three libraries:
1182
1183 @enumerate
1184 @item libvirt-glib - GLib main loop integration & misc helper APIs
1185 @item libvirt-gconfig - GObjects for manipulating libvirt XML documents
1186 @item libvirt-gobject - GObjects for managing libvirt objects
1187 @end enumerate
1188 ")
1189 (license license:lgpl2.1+)))
1190
1191 (define-public python-libvirt
1192 (package
1193 (name "python-libvirt")
1194 (version "7.1.0")
1195 (source
1196 (origin
1197 (method url-fetch)
1198 (uri (string-append "https://libvirt.org/sources/python/libvirt-python-"
1199 version ".tar.gz"))
1200 (sha256
1201 (base32 "0dq0qn0xx5hflaq5apj5pm79ba0wcl3w0j9klx8bg73z80gd7bzs"))))
1202 (build-system python-build-system)
1203 (arguments
1204 `(#:phases
1205 (modify-phases %standard-phases
1206 (add-after 'unpack 'patch-nosetests-path
1207 (lambda* (#:key inputs #:allow-other-keys)
1208 (substitute* "setup.py"
1209 (("\"/usr/bin/nosetests\"")
1210 (string-append "\"" (which "nosetests") "\""))
1211 (("self\\.spawn\\(\\[sys\\.executable, nose\\]\\)")
1212 (format #f "self.spawn([\"~a\", nose])" (which "bash"))))
1213 #t)))))
1214 (inputs
1215 `(("libvirt" ,libvirt)))
1216 (propagated-inputs
1217 `(("python-lxml" ,python-lxml)))
1218 (native-inputs
1219 `(("pkg-config" ,pkg-config)
1220 ("python-nose" ,python-nose)))
1221 (home-page "https://libvirt.org")
1222 (synopsis "Python bindings to libvirt")
1223 (description "This package provides Python bindings to the libvirt
1224 virtualization library.")
1225 (license license:lgpl2.1+)))
1226
1227 (define-public python2-libvirt
1228 (package-with-python2 python-libvirt))
1229
1230 (define-public virt-manager
1231 (package
1232 (name "virt-manager")
1233 (version "2.2.1")
1234 (source (origin
1235 (method url-fetch)
1236 (uri (string-append "https://virt-manager.org/download/sources"
1237 "/virt-manager/virt-manager-"
1238 version ".tar.gz"))
1239 (sha256
1240 (base32
1241 "06ws0agxlip6p6n3n43knsnjyd91gqhh2dadgc33wl9lx1k8vn6g"))))
1242 (build-system python-build-system)
1243 (arguments
1244 `(#:use-setuptools? #f ; uses custom distutils 'install' command
1245 #:test-target "test_ui"
1246 #:tests? #f ; TODO The tests currently fail
1247 ; RuntimeError: Loop condition wasn't
1248 ; met
1249 #:imported-modules ((guix build glib-or-gtk-build-system)
1250 ,@%python-build-system-modules)
1251 #:modules ((ice-9 match)
1252 (srfi srfi-26)
1253 (guix build python-build-system)
1254 ((guix build glib-or-gtk-build-system) #:prefix glib-or-gtk:)
1255 (guix build utils))
1256 #:phases
1257 (modify-phases %standard-phases
1258 (add-after 'unpack 'fix-setup
1259 (lambda* (#:key outputs #:allow-other-keys)
1260 (substitute* "virtinst/buildconfig.py"
1261 (("/usr") (assoc-ref outputs "out")))
1262 #t))
1263 (add-after 'unpack 'fix-qemu-img-reference
1264 (lambda* (#:key inputs #:allow-other-keys)
1265 (substitute* "virtconv/formats.py"
1266 (("/usr(/bin/qemu-img)" _ suffix)
1267 (string-append (assoc-ref inputs "qemu") suffix)))
1268 #t))
1269 (add-after 'unpack 'fix-default-uri
1270 (lambda* (#:key inputs #:allow-other-keys)
1271 ;; Xen is not available for now - so only patch qemu.
1272 (substitute* "virtManager/createconn.py"
1273 (("/usr(/bin/qemu-system)" _ suffix)
1274 (string-append (assoc-ref inputs "qemu") suffix)))
1275 #t))
1276 (add-before 'wrap 'wrap-with-GI_TYPELIB_PATH
1277 (lambda* (#:key inputs outputs #:allow-other-keys)
1278 (let* ((bin (string-append (assoc-ref outputs "out") "/bin"))
1279 (bin-files (find-files bin ".*"))
1280 (paths (map (match-lambda
1281 ((output . directory)
1282 (let* ((girepodir (string-append
1283 directory
1284 "/lib/girepository-1.0")))
1285 (if (file-exists? girepodir)
1286 girepodir #f))))
1287 inputs)))
1288 (for-each (lambda (file)
1289 (format #t "wrapping ~a\n" file)
1290 (wrap-program file
1291 `("GI_TYPELIB_PATH" ":" prefix
1292 ,(filter identity paths))))
1293 bin-files))
1294 #t))
1295 (replace 'check
1296 (lambda* (#:key tests? #:allow-other-keys)
1297 (when tests?
1298 (setenv "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" "--" "python" "setup.py" "test_ui"))
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 ;; The following are required for running the tests
1334 ;; ("python-dogtail" ,python-dogtail)
1335 ;; ("xvfb" ,xorg-server-for-tests)
1336 ;; ("dbus" ,dbus)
1337 ;; ("at-spi2-core" ,at-spi2-core)
1338 ;; ("gsettings-desktop-schemas" ,gsettings-desktop-schemas)
1339 ))
1340 (home-page "https://virt-manager.org/")
1341 (synopsis "Manage virtual machines")
1342 (description
1343 "The virt-manager application is a desktop user interface for managing
1344 virtual machines through libvirt. It primarily targets KVM VMs, but also
1345 manages Xen and LXC (Linux containers). It presents a summary view of running
1346 domains, their live performance and resource utilization statistics.")
1347 (license license:gpl2+)))
1348
1349 (define-public criu
1350 (package
1351 (name "criu")
1352 (version "3.15")
1353 (source (origin
1354 (method url-fetch)
1355 (uri (string-append "https://download.openvz.org/criu/criu-"
1356 version ".tar.bz2"))
1357 (sha256
1358 (base32
1359 "09d0j24x0cyc7wkgi7cnxqgfjk7kbdlm79zxpj8d356sa3rw2z24"))))
1360 (build-system gnu-build-system)
1361 (arguments
1362 `(#:test-target "test"
1363 #:tests? #f ; tests require mounting as root
1364 #:make-flags
1365 (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
1366 (string-append "LIBDIR=" (assoc-ref %outputs "out")
1367 "/lib")
1368 (string-append "ASCIIDOC=" (assoc-ref %build-inputs "asciidoc")
1369 "/bin/asciidoc")
1370 (string-append "XMLTO=" (assoc-ref %build-inputs "xmlto")
1371 "/bin/xmlto"))
1372 #:phases
1373 (modify-phases %standard-phases
1374 (replace 'configure
1375 (lambda* (#:key inputs #:allow-other-keys)
1376 ;; The includes for libnl are located in a sub-directory.
1377 (setenv "C_INCLUDE_PATH"
1378 (string-append (assoc-ref inputs "libnl")
1379 "/include/libnl3:"
1380 (or (getenv "C_INCLUDE_PATH") "")))
1381 #t))
1382 (add-after 'configure 'fix-documentation
1383 (lambda* (#:key inputs outputs #:allow-other-keys)
1384 (substitute* "Documentation/Makefile"
1385 (("-m custom.xsl")
1386 (string-append
1387 "-m custom.xsl --skip-validation -x "
1388 (assoc-ref inputs "docbook-xsl") "/xml/xsl/"
1389 ,(package-name docbook-xsl) "-"
1390 ,(package-version docbook-xsl)
1391 "/manpages/docbook.xsl")))
1392 #t))
1393 (add-after 'unpack 'hardcode-variables
1394 (lambda* (#:key inputs #:allow-other-keys)
1395 ;; Hardcode arm version detection
1396 (substitute* "Makefile"
1397 (("ARMV.*:=.*") "ARMV := 7\n"))
1398 ;; We are currently using python-2
1399 (substitute* "crit/Makefile"
1400 (("\\$\\(PYTHON\\)") "python2"))
1401 (substitute* "lib/Makefile"
1402 (("\\$\\(PYTHON\\)")
1403 (string-append (assoc-ref inputs "python")
1404 "/bin/python")))
1405 #t))
1406 (add-before 'build 'fix-symlink
1407 (lambda* (#:key inputs #:allow-other-keys)
1408 ;; The file 'images/google/protobuf/descriptor.proto' points to
1409 ;; /usr/include/..., which obviously does not exist.
1410 (let* ((file "google/protobuf/descriptor.proto")
1411 (target (string-append "images/" file))
1412 (source (string-append (assoc-ref inputs "protobuf")
1413 "/include/" file)))
1414 (delete-file target)
1415 (symlink source target)
1416 #t)))
1417 (add-after 'install 'wrap
1418 (lambda* (#:key inputs outputs #:allow-other-keys)
1419 ;; Make sure 'crit' runs with the correct PYTHONPATH.
1420 (let* ((out (assoc-ref outputs "out"))
1421 (path (string-append out
1422 "/lib/python"
1423 (string-take (string-take-right
1424 (assoc-ref inputs "python") 5) 3)
1425 "/site-packages:"
1426 (getenv "PYTHONPATH"))))
1427 (wrap-program (string-append out "/bin/crit")
1428 `("PYTHONPATH" ":" prefix (,path))))
1429 #t)))))
1430 (inputs
1431 `(("protobuf" ,protobuf)
1432 ("python" ,python-2)
1433 ("python2-protobuf" ,python2-protobuf)
1434 ("python2-ipaddr" ,python2-ipaddr)
1435 ("iproute" ,iproute)
1436 ("libaio" ,libaio)
1437 ("libcap" ,libcap)
1438 ("libnet" ,libnet)
1439 ("libnl" ,libnl)
1440 ("libbsd" ,libbsd)
1441 ("nftables" ,nftables)))
1442 (native-inputs
1443 `(("pkg-config" ,pkg-config)
1444 ("perl" ,perl)
1445 ("protobuf-c" ,protobuf-c)
1446 ("asciidoc" ,asciidoc)
1447 ("xmlto" ,xmlto)
1448 ("docbook-xml" ,docbook-xml)
1449 ("docbook-xsl" ,docbook-xsl)))
1450 (home-page "https://criu.org")
1451 (synopsis "Checkpoint and restore in user space")
1452 (description "Using this tool, you can freeze a running application (or
1453 part of it) and checkpoint it to a hard drive as a collection of files. You
1454 can then use the files to restore and run the application from the point it
1455 was frozen at. The distinctive feature of the CRIU project is that it is
1456 mainly implemented in user space.")
1457 ;; The project is licensed under GPLv2; files in the lib/ directory are
1458 ;; LGPLv2.1.
1459 (license (list license:gpl2 license:lgpl2.1))))
1460
1461 (define-public qmpbackup
1462 (package
1463 (name "qmpbackup")
1464 (version "0.2")
1465 (source (origin
1466 (method git-fetch)
1467 (uri (git-reference
1468 (url "https://github.com/abbbi/qmpbackup")
1469 (commit version)))
1470 (file-name (git-file-name name version))
1471 (sha256
1472 (base32
1473 "0swhp5byz44brhyis1a39p11fyn9q84xz5q6v2fah29r7d71kmmx"))))
1474 (build-system python-build-system)
1475 (arguments
1476 `(#:python ,python-2))
1477 (home-page "https://github.com/abbbi/qmpbackup")
1478 (synopsis "Backup and restore QEMU machines")
1479 (description "qmpbackup is designed to create and restore full and
1480 incremental backups of running QEMU virtual machines via QMP, the QEMU
1481 Machine Protocol.")
1482 (license license:gpl3+)))
1483
1484 (define-public looking-glass-client
1485 (let ((commit "182c4752d57690da7f99d5e788de9b8baea33895"))
1486 (package
1487 (name "looking-glass-client")
1488 (version (string-append "a12-" (string-take commit 7)))
1489 (source
1490 (origin
1491 (method git-fetch)
1492 (uri (git-reference (url "https://github.com/gnif/LookingGlass")
1493 (commit commit)))
1494 (file-name (git-file-name name version))
1495 (sha256
1496 (base32
1497 "02bq46ndmzq9cihazzn7xq1x7q5nzm7iw4l9lqzihxcxp9famkhw"))
1498 (modules '((guix build utils)))
1499 (snippet
1500 '(begin
1501 ;; Do not create binaries optimized for the CPU of the build machine,
1502 ;; for reproducibility and compatibility. TODO: in the next version
1503 ;; of looking glass, this is exposed as a CMake configure option.
1504 (substitute* "client/CMakeLists.txt"
1505 (("-march=native")
1506 ""))
1507 #t))))
1508 (build-system cmake-build-system)
1509 (inputs `(("fontconfig" ,fontconfig)
1510 ("glu" ,glu)
1511 ("mesa" ,mesa)
1512 ("openssl" ,openssl)
1513 ("sdl2" ,sdl2)
1514 ("sdl2-ttf" ,sdl2-ttf)
1515 ("spice-protocol" ,spice-protocol)
1516 ("wayland" ,wayland)))
1517 (native-inputs `(("libconfig" ,libconfig)
1518 ("nettle" ,nettle)
1519 ("pkg-config" ,pkg-config)))
1520 (arguments
1521 `(#:tests? #f ;; No tests are available.
1522 #:make-flags '("CC=gcc")
1523 #:phases (modify-phases %standard-phases
1524 (add-before 'configure 'chdir-to-client
1525 (lambda* (#:key outputs #:allow-other-keys)
1526 (chdir "client")
1527 #t))
1528 (add-after 'chdir-to-client 'add-missing-include
1529 (lambda _
1530 ;; Mimic upstream commit b9797529893, required since the
1531 ;; update to Mesa 19.2.
1532 (substitute* "renderers/egl/shader.h"
1533 (("#include <stdbool\\.h>")
1534 "#include <stdbool.h>\n#include <stddef.h>"))
1535 #t))
1536 (replace 'install
1537 (lambda* (#:key outputs #:allow-other-keys)
1538 (install-file "looking-glass-client"
1539 (string-append (assoc-ref outputs "out")
1540 "/bin"))
1541 #t)))))
1542 (home-page "https://looking-glass.hostfission.com")
1543 (synopsis "KVM Frame Relay (KVMFR) implementation")
1544 (description "Looking Glass allows the use of a KVM (Kernel-based Virtual
1545 Machine) configured for VGA PCI Pass-through without an attached physical
1546 monitor, keyboard or mouse. It displays the VM's rendered contents on your main
1547 monitor/GPU.")
1548 ;; This package requires SSE instructions.
1549 (supported-systems '("i686-linux" "x86_64-linux"))
1550 (license license:gpl2+))))
1551
1552 (define-public runc
1553 (package
1554 (name "runc")
1555 (version "1.0.0-rc6")
1556 (source (origin
1557 (method url-fetch)
1558 (uri (string-append
1559 "https://github.com/opencontainers/runc/releases/"
1560 "download/v" version "/runc.tar.xz"))
1561 (file-name (string-append name "-" version ".tar.xz"))
1562 (patches (search-patches "runc-CVE-2019-5736.patch"))
1563 (sha256
1564 (base32
1565 "1c7832dq70slkjh8qp2civ1wxhhdd2hrx84pq7db1mmqc9fdr3cc"))))
1566 (build-system go-build-system)
1567 (arguments
1568 '(#:import-path "github.com/opencontainers/runc"
1569 #:install-source? #f
1570 ;; XXX: 20/139 tests fail due to missing /var, cgroups and apparmor in
1571 ;; the build environment.
1572 #:tests? #f
1573 #:phases
1574 (modify-phases %standard-phases
1575 (replace 'unpack
1576 (lambda* (#:key source import-path #:allow-other-keys)
1577 ;; Unpack the tarball into 'runc' instead of 'runc-1.0.0-rc5'.
1578 (let ((dest (string-append "src/" import-path)))
1579 (mkdir-p dest)
1580 (invoke "tar" "-C" (string-append "src/" import-path)
1581 "--strip-components=1"
1582 "-xvf" source))))
1583 (replace 'build
1584 (lambda* (#:key import-path #:allow-other-keys)
1585 (with-directory-excursion (string-append "src/" import-path)
1586 ;; XXX: requires 'go-md2man'.
1587 ;; (invoke "make" "man")
1588 (invoke "make"))))
1589 ;; (replace 'check
1590 ;; (lambda _
1591 ;; (invoke "make" "localunittest")))
1592 (replace 'install
1593 (lambda* (#:key import-path outputs #:allow-other-keys)
1594 (with-directory-excursion (string-append "src/" import-path)
1595 (let ((out (assoc-ref outputs "out")))
1596 (invoke "make" "install" "install-bash"
1597 (string-append "PREFIX=" out)))))))))
1598 (native-inputs
1599 `(("pkg-config" ,pkg-config)))
1600 (inputs
1601 `(("libseccomp" ,libseccomp)))
1602 (synopsis "Open container initiative runtime")
1603 (home-page "https://www.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.6")
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 "06q7xfwnqysc013hapx31jhlzmyg8qb467qfkynj673qc7p9bd6h"))))
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.2")
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 "03sznybn3rqjyplc6w4b7mfa6gas8db15p5vnmfm1xqw72ldylgc"))))
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)))