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