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