gnu: emacs-helm: Update to 3.8.7.
[jackhill/guix/guix.git] / gnu / packages / virtualization.scm
CommitLineData
b15fcf9e 1;;; GNU Guix --- Functional package management for GNU
73761d80 2;;; Copyright © 2013-2017, 2020-2022 Ludovic Courtès <ludo@gnu.org>
ecfe88b7 3;;; Copyright © 2015, 2016, 2017, 2018 Mark H Weaver <mhw@netris.org>
25de37e1 4;;; Copyright © 2016, 2017, 2018. 2019, 2020, 2021 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>
9c769ace 9;;; Copyright © 2017–2021 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>
0d4ae86b 15;;; Copyright © 2020, 2021 Brice Waegeneire <brice@waegenei.re>
08cf730a 16;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
93f69b02 17;;; Copyright © 2020, 2021 Marius Bakke <mbakke@fastmail.com>
5daac1a7 18;;; Copyright © 2020, 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
dd8e4411 19;;; Copyright © 2020 Brett Gilio <brettg@gnu.org>
d15fdb66 20;;; Copyright © 2021 Leo Famulari <leo@famulari.name>
0cee62d4 21;;; Copyright © 2021, 2022 Pierre Langlois <pierre.langlois@gmx.com>
404f6145 22;;; Copyright © 2021 Dion Mendel <guix@dm9.info>
5edfa6d1 23;;; Copyright © 2021 Andrew Whatson <whatson@gmail.com>
66df86a2
RG
24;;; Copyright © 2021 Vincent Legoll <vincent.legoll@gmail.com>
25;;; Copyright © 2021 Petr Hodina <phodina@protonmail.com>
26;;; Copyright © 2021 Raghav Gururajan <rg@raghavgururajan.name>
d997fcd3 27;;; Copyright © 2022 Oleg Pykhalov <go.wigust@gmail.com>
178ca9ef 28;;; Copyright © 2022 Ekaitz Zarraga <ekaitz@elenq.tech>
9afad0c1 29;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net>
10ff74d3 30;;; Copyright © 2022 Zhu Zihao <all_but_last@163.com>
b15fcf9e
LC
31;;;
32;;; This file is part of GNU Guix.
33;;;
34;;; GNU Guix is free software; you can redistribute it and/or modify it
35;;; under the terms of the GNU General Public License as published by
36;;; the Free Software Foundation; either version 3 of the License, or (at
37;;; your option) any later version.
38;;;
39;;; GNU Guix is distributed in the hope that it will be useful, but
40;;; WITHOUT ANY WARRANTY; without even the implied warranty of
41;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42;;; GNU General Public License for more details.
43;;;
44;;; You should have received a copy of the GNU General Public License
45;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
46
59132b80 47(define-module (gnu packages virtualization)
161ed547 48 #:use-module (gnu packages)
063477ba 49 #:use-module (gnu packages acl)
309693e0 50 #:use-module (gnu packages admin)
35e8900d 51 #:use-module (gnu packages assembly)
efcada41 52 #:use-module (gnu packages attr)
309693e0 53 #:use-module (gnu packages autotools)
e9126381 54 #:use-module (gnu packages backup)
72a91d74 55 #:use-module (gnu packages base)
0d4ae86b 56 #:use-module (gnu packages bash)
ecfe88b7 57 #:use-module (gnu packages bison)
178ca9ef 58 #:use-module (gnu packages bootloaders)
15423d38 59 #:use-module (gnu packages build-tools)
a0f6c3b3 60 #:use-module (gnu packages check)
5edfa6d1 61 #:use-module (gnu packages cluster)
35e8900d 62 #:use-module (gnu packages cmake)
b15fcf9e 63 #:use-module (gnu packages compression)
35e8900d 64 #:use-module (gnu packages cross-base)
309693e0
RW
65 #:use-module (gnu packages curl)
66 #:use-module (gnu packages cyrus-sasl)
7b572c5f 67 #:use-module (gnu packages debian)
309693e0 68 #:use-module (gnu packages disk)
8fc7bd23 69 #:use-module (gnu packages dns)
fe420383
RW
70 #:use-module (gnu packages docbook)
71 #:use-module (gnu packages documentation)
35e8900d
DM
72 #:use-module (gnu packages figlet)
73 #:use-module (gnu packages firmware)
ecfe88b7 74 #:use-module (gnu packages flex)
fb9472a3 75 #:use-module (gnu packages fontutils)
16a47f23 76 #:use-module (gnu packages freedesktop)
90a8ef8c 77 #:use-module (gnu packages gettext)
d997fcd3 78 #:use-module (gnu packages gcc)
efcada41
DC
79 #:use-module (gnu packages gl)
80 #:use-module (gnu packages glib)
a0f6c3b3 81 #:use-module (gnu packages gnome)
7714a069 82 #:use-module (gnu packages gnupg)
de7f03ce 83 #:use-module (gnu packages golang)
72a91d74 84 #:use-module (gnu packages graphviz)
a0f6c3b3 85 #:use-module (gnu packages gtk)
72a91d74
MB
86 #:use-module (gnu packages haskell)
87 #:use-module (gnu packages haskell-apps)
88 #:use-module (gnu packages haskell-check)
89 #:use-module (gnu packages haskell-crypto)
90 #:use-module (gnu packages haskell-web)
91 #:use-module (gnu packages haskell-xyz)
e55354b8 92 #:use-module (gnu packages image)
5d1601ea 93 #:use-module (gnu packages libbsd)
fb9d7865 94 #:use-module (gnu packages libusb)
efcada41 95 #:use-module (gnu packages linux)
72a91d74 96 #:use-module (gnu packages m4)
d997fcd3 97 #:use-module (gnu packages multiprecision)
efcada41 98 #:use-module (gnu packages ncurses)
71d4ba52 99 #:use-module (gnu packages nettle)
fe420383 100 #:use-module (gnu packages networking)
d15fdb66 101 #:use-module (gnu packages ninja)
308af634 102 #:use-module (gnu packages onc-rpc)
7714a069 103 #:use-module (gnu packages package-management)
5b59df32 104 #:use-module (gnu packages pciutils)
d184fd42 105 #:use-module (gnu packages pcre)
5b59df32 106 #:use-module (gnu packages perl)
efcada41 107 #:use-module (gnu packages pkg-config)
309693e0 108 #:use-module (gnu packages polkit)
fe420383 109 #:use-module (gnu packages protobuf)
efcada41 110 #:use-module (gnu packages python)
13bb41f8 111 #:use-module (gnu packages python-build)
dd8e4411 112 #:use-module (gnu packages python-check)
72a91d74 113 #:use-module (gnu packages python-crypto)
589e3f4e 114 #:use-module (gnu packages python-web)
44d10b1f 115 #:use-module (gnu packages python-xyz)
28e3569f 116 #:use-module (gnu packages pulseaudio)
0d4ae86b 117 #:use-module (gnu packages readline)
5edfa6d1 118 #:use-module (gnu packages rsync)
5d4a8f9b 119 #:use-module (gnu packages selinux)
efcada41 120 #:use-module (gnu packages sdl)
0411aca8 121 #:use-module (gnu packages sphinx)
38b9ce44 122 #:use-module (gnu packages spice)
72a91d74 123 #:use-module (gnu packages ssh)
efcada41 124 #:use-module (gnu packages texinfo)
71d4ba52 125 #:use-module (gnu packages textutils)
309693e0
RW
126 #:use-module (gnu packages tls)
127 #:use-module (gnu packages web)
35e8900d 128 #:use-module (gnu packages wget)
efcada41 129 #:use-module (gnu packages xdisorg)
309693e0 130 #:use-module (gnu packages xml)
8981465b 131 #:use-module (gnu packages xorg)
6da90719 132 #:use-module (guix build-system cmake)
efcada41 133 #:use-module (guix build-system gnu)
de7f03ce 134 #:use-module (guix build-system go)
cfd9913f 135 #:use-module (guix build-system meson)
7cd2032f 136 #:use-module (guix build-system python)
a838fa28 137 #:use-module (guix build-system trivial)
efcada41 138 #:use-module (guix download)
7714a069 139 #:use-module (guix git-download)
b56a8afb 140 #:use-module (guix gexp)
b23b9667 141 #:use-module ((guix licenses) #:prefix license:)
efcada41
DC
142 #:use-module (guix packages)
143 #:use-module (guix utils)
355892e1 144 #:use-module (srfi srfi-1)
d184fd42 145 #:use-module (srfi srfi-26)
355892e1 146 #:use-module (ice-9 match))
b15fcf9e 147
ce0be567 148(define (qemu-patch commit file-name sha256-bv)
e38a71ee
LC
149 "Return an origin for COMMIT."
150 (origin
151 (method url-fetch)
152 (uri (string-append
153 "http://git.qemu.org/?p=qemu.git;a=commitdiff_plain;h="
154 commit))
ce0be567 155 (hash (content-hash sha256-bv sha256))
e38a71ee
LC
156 (file-name file-name)))
157
06da1a6b 158(define-public qemu
b15fcf9e 159 (package
06da1a6b 160 (name "qemu")
30c3ab38 161 (version "6.2.0")
3fe46eef
MC
162 (source
163 (origin
164 (method url-fetch)
165 (uri (string-append "https://download.qemu.org/qemu-"
166 version ".tar.xz"))
167 (sha256
168 (base32
30c3ab38
MB
169 "0iavlsy9hin8k38230j8lfmyipx3965zljls1dp34mmc8n75vqb8"))
170 (patches (search-patches "qemu-build-info-manual.patch"
142344b6 171 "qemu-fix-agent-paths.patch"))
3fe46eef
MC
172 (modules '((guix build utils)))
173 (snippet
174 '(begin
15423d38
MC
175 ;; Delete the bundled meson copy.
176 (delete-file-recursively "meson")))))
d15fdb66 177 (outputs '("out" "static" "doc")) ;5.3 MiB of HTML docs
3fe46eef
MC
178 (build-system gnu-build-system)
179 (arguments
d184fd42
MC
180 ;; FIXME: Disable tests on i686 to work around
181 ;; <https://bugs.gnu.org/40527>.
182 `(#:tests? ,(or (%current-target-system)
4fc21327 183 (not (string=? "i686-linux" (%current-system))))
d184fd42 184 #:configure-flags
2dffe476 185 (let ((gcc (search-input-file %build-inputs "/bin/gcc"))
d184fd42
MC
186 (out (assoc-ref %outputs "out")))
187 (list (string-append "--cc=" gcc)
188 ;; Some architectures insist on using HOST_CC.
189 (string-append "--host-cc=" gcc)
190 (string-append "--prefix=" out)
191 "--sysconfdir=/etc"
192 (string-append "--smbd=" out "/libexec/samba-wrapper")
193 "--disable-debug-info" ;for space considerations
194 ;; The binaries need to be linked against -lrt.
195 (string-append "--extra-ldflags=-lrt")))
a1570c89
MB
196 ;; Make build and test output verbose to facilitate investigation upon failure.
197 #:make-flags '("V=1")
08cf730a 198 #:modules ((srfi srfi-1)
d184fd42
MC
199 (srfi srfi-26)
200 (ice-9 ftw)
08cf730a
MO
201 (ice-9 match)
202 ,@%gnu-build-system-modules)
05051e8b
LC
203 #:phases
204 (modify-phases %standard-phases
1b0cda6b
TGR
205 (add-after 'unpack 'extend-test-time-outs
206 (lambda _
207 ;; These tests can time out on heavily-loaded and/or slow storage.
208 (substitute* (cons* "tests/qemu-iotests/common.qemu"
209 (find-files "tests/qemu-iotests" "^[0-9]+$"))
210 (("QEMU_COMM_TIMEOUT=[0-9]+" match)
b070e3f8 211 (string-append match "9")))))
afeed71a
MC
212 (add-after 'unpack 'disable-unusable-tests
213 (lambda _
c87ebc1b 214 (substitute* "tests/unit/meson.build"
afeed71a
MC
215 ;; Comment out the test-qga test, which needs /sys and
216 ;; fails within the build environment.
d15fdb66 217 (("tests.*test-qga.*$" all)
afeed71a
MC
218 (string-append "# " all))
219 ;; Comment out the test-char test, which needs networking and
220 ;; fails within the build environment.
c87ebc1b 221 ((".*'test-char':.*" all)
3fe46eef 222 (string-append "# " all)))))
0f87f2e6
EF
223 ,@(if (target-riscv64?)
224 `((add-after 'unpack 'disable-some-tests
225 (lambda _
226 ;; qemu.qmp.QMPConnectError: Unexpected empty reply from server
227 (delete-file "tests/qemu-iotests/040")
228 (delete-file "tests/qemu-iotests/041")
229 (delete-file "tests/qemu-iotests/256")
230
231 ;; No 'PCI' bus found for device 'virtio-scsi-pci'
232 (delete-file "tests/qemu-iotests/127")
233 (delete-file "tests/qemu-iotests/267"))))
234 '())
d15fdb66 235 (add-after 'patch-source-shebangs 'patch-embedded-shebangs
d64bd125 236 (lambda* (#:key native-inputs inputs #:allow-other-keys)
35c43fcd
MB
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"
0b5e1287
MB
240 "net/tap.c" "tests/qtest/libqtest.c"
241 "tests/qtest/vhost-user-blk-test.c")
d64bd125 242 (("/bin/sh") (search-input-file inputs "/bin/sh")))
0b5e1287 243 (substitute* "tests/qemu-iotests/testenv.py"
d15fdb66 244 (("#!/usr/bin/env python3")
d64bd125
MB
245 (string-append "#!" (search-input-file (or native-inputs inputs)
246 "/bin/python3"))))))
d15fdb66
LF
247 (add-before 'configure 'fix-optionrom-makefile
248 (lambda _
249 ;; Work around the inability of the rules defined in this
250 ;; Makefile to locate the firmware files (e.g.: No rule to make
251 ;; target 'multiboot.bin') by extending the VPATH.
252 (substitute* "pc-bios/optionrom/Makefile"
253 (("^VPATH = \\$\\(SRC_DIR\\)")
254 "VPATH = $(SRC_DIR):$(TOPSRC_DIR)/pc-bios"))))
255 ;; XXX ./configure is being re-run at beginning of build phase...
05051e8b 256 (replace 'configure
d184fd42 257 (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
05051e8b
LC
258 ;; The `configure' script doesn't understand some of the
259 ;; GNU options. Thus, add a new phase that's compatible.
260 (let ((out (assoc-ref outputs "out")))
261 (setenv "SHELL" (which "bash"))
35c43fcd
MB
262 ;; Ensure config.status gets the correct shebang off the bat.
263 ;; The build system gets confused if we change it later and
d15fdb66 264 ;; attempts to re-run the whole configuration, and fails.
35c43fcd
MB
265 (substitute* "configure"
266 (("#!/bin/sh")
267 (string-append "#!" (which "sh"))))
d184fd42
MC
268 (mkdir-p "b/qemu")
269 (chdir "b/qemu")
270 (apply invoke "../../configure" configure-flags))))
271 ;; Configure, build and install QEMU user-emulation static binaries.
272 (add-after 'configure 'configure-user-static
273 (lambda* (#:key inputs outputs #:allow-other-keys)
bc64d955 274 (let* ((gcc (search-input-file inputs "/bin/gcc"))
d184fd42
MC
275 (static (assoc-ref outputs "static"))
276 ;; This is the common set of configure flags; it is
277 ;; duplicated here to isolate this phase from manipulations
278 ;; to the #:configure-flags build argument, as done in
279 ;; derived packages such as qemu-minimal.
280 (configure-flags (list (string-append "--cc=" gcc)
281 (string-append "--host-cc=" gcc)
282 "--sysconfdir=/etc"
283 "--disable-debug-info")))
284 (mkdir-p "../user-static")
285 (with-directory-excursion "../user-static"
286 (apply invoke "../../configure"
287 "--static"
288 "--disable-docs" ;already built
289 "--disable-system"
290 "--enable-linux-user"
291 (string-append "--prefix=" static)
292 configure-flags)))))
293 (add-after 'build 'build-user-static
294 (lambda args
295 (with-directory-excursion "../user-static"
296 (apply (assoc-ref %standard-phases 'build) args))))
297 (add-after 'install 'install-user-static
298 (lambda* (#:key outputs #:allow-other-keys)
299 (let* ((static (assoc-ref outputs "static"))
300 (bin (string-append static "/bin")))
301 (with-directory-excursion "../user-static"
302 (for-each (cut install-file <> bin)
d15fdb66 303 (append-map (cut find-files <> "^qemu-" #:stat stat)
d184fd42
MC
304 (scandir "."
305 (cut string-suffix?
306 "-linux-user" <>))))))))
0e5d0f66
RH
307 ;; Create a wrapper for Samba. This allows QEMU to use Samba without
308 ;; pulling it in as an input. Note that you need to explicitly install
309 ;; Samba in your Guix profile for Samba support.
38197bb5 310 (add-after 'install 'create-samba-wrapper
0e5d0f66 311 (lambda* (#:key inputs outputs #:allow-other-keys)
4d82e8e5 312 (let* ((out (assoc-ref outputs "out"))
0e5d0f66
RH
313 (libexec (string-append out "/libexec")))
314 (call-with-output-file "samba-wrapper"
315 (lambda (port)
316 (format port "#!/bin/sh
317exec smbd $@")))
318 (chmod "samba-wrapper" #o755)
3fe46eef 319 (install-file "samba-wrapper" libexec))))
4d82e8e5
MC
320 (add-after 'install 'move-html-doc
321 (lambda* (#:key inputs outputs #:allow-other-keys)
322 (let* ((out (assoc-ref outputs "out"))
323 (doc (assoc-ref outputs "doc"))
324 (qemu-doc (string-append doc "/share/doc/qemu-" ,version)))
325 (mkdir-p qemu-doc)
326 (rename-file (string-append out "/share/doc/qemu")
3fe46eef 327 (string-append qemu-doc "/html"))))))))
d64bd125
MB
328 (inputs
329 (list alsa-lib
330 bash-minimal
331 glib
332 gtk+
333 libaio
334 libcacard ;smartcard support
335 attr libcap-ng ;VirtFS support
336 libdrm
337 libepoxy
338 libjpeg-turbo
339 libpng
340 libseccomp
5d65500c 341 liburing
d64bd125
MB
342 libusb ;USB pass-through support
343 mesa
344 ncurses
345 ;; ("pciutils" ,pciutils)
346 pixman
347 pulseaudio
348 sdl2
349 spice
350 usbredir
351 util-linux
352 vde2
353 virglrenderer
2c75adb9
TGR
354
355 ;; Formats to support for .qcow2 (and possibly other) compression.
356 zlib
357 `(,zstd "lib")))
d64bd125
MB
358 (native-inputs
359 (list gettext-minimal
360 `(,glib "bin") ;gtester, etc.
361 perl
362 flex
363 bison
364 meson
365 ninja
366 pkg-config
367 python-wrapper
368 python-sphinx
369 python-sphinx-rtd-theme
370 texinfo
371 ;; The following static libraries are required to build
372 ;; the static output of QEMU.
373 `(,glib "static")
374 `(,pcre "static")
375 `(,zlib "static")))
ce9fbae1 376 (home-page "https://www.qemu.org")
06da1a6b 377 (synopsis "Machine emulator and virtualizer")
72b9eebf 378 (description
50731c51 379 "QEMU is a generic machine emulator and virtualizer.
72b9eebf
LC
380
381When used as a machine emulator, QEMU can run OSes and programs made for one
50731c51
LC
382machine (e.g. an ARM board) on a different machine---e.g., your own PC. By
383using dynamic translation, it achieves very good performance.
72b9eebf
LC
384
385When used as a virtualizer, QEMU achieves near native performances by
386executing the guest code directly on the host CPU. QEMU supports
387virtualization when executing under the Xen hypervisor or using
388the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86,
50731c51
LC
389server and embedded PowerPC, and S390 guests.")
390
391 ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
b23b9667 392 (license license:gpl2)
f47638a3
LC
393
394 ;; Several tests fail on MIPS; see <http://hydra.gnu.org/build/117914>.
654de94e
JN
395 (supported-systems (fold delete %supported-systems
396 '("mips64el-linux" "i586-gnu")))))
50731c51 397
06da1a6b 398(define-public qemu-minimal
355892e1 399 ;; QEMU without GUI support, only supporting the host's architecture
d184fd42
MC
400 (package
401 (inherit qemu)
06da1a6b 402 (name "qemu-minimal")
6858c150 403 (outputs '("out" "doc"))
355892e1
EF
404 (synopsis
405 "Machine emulator and virtualizer (without GUI) for the host architecture")
06da1a6b 406 (arguments
b376ec57 407 (substitute-keyword-arguments (package-arguments qemu)
d184fd42 408 ((#:configure-flags configure-flags '(list))
355892e1 409 ;; Restrict to the host's architecture.
d184fd42
MC
410 (let* ((system (or (%current-target-system)
411 (%current-system)))
412 (target-list-arg
413 (match system
414 ((? (cut string-prefix? "i686" <>))
415 "--target-list=i386-softmmu")
416 ((? (cut string-prefix? "x86_64" <>))
417 "--target-list=i386-softmmu,x86_64-softmmu")
418 ((? (cut string-prefix? "mips64" <>))
419 (string-append "--target-list=mips-softmmu,mipsel-softmmu,"
420 "mips64-softmmu,mips64el-softmmu"))
421 ((? (cut string-prefix? "mips" <>))
422 "--target-list=mips-softmmu,mipsel-softmmu")
423 ((? (cut string-prefix? "aarch64" <>))
424 "--target-list=arm-softmmu,aarch64-softmmu")
425 ((? (cut string-prefix? "arm" <>))
426 "--target-list=arm-softmmu")
427 ((? (cut string-prefix? "alpha" <>))
428 "--target-list=alpha-softmmu")
429 ((? (cut string-prefix? "powerpc64" <>))
430 "--target-list=ppc-softmmu,ppc64-softmmu")
431 ((? (cut string-prefix? "powerpc" <>))
432 "--target-list=ppc-softmmu")
433 ((? (cut string-prefix? "s390" <>))
434 "--target-list=s390x-softmmu")
435 ((? (cut string-prefix? "riscv" <>))
436 "--target-list=riscv32-softmmu,riscv64-softmmu")
437 (else ; An empty list actually builds all the targets.
438 '()))))
6858c150
EF
439 `(cons ,target-list-arg ,configure-flags)))
440 ((#:phases phases)
441 `(modify-phases ,phases
442 (delete 'configure-user-static)
443 (delete 'build-user-static)
444 (delete 'install-user-static)))))
06da1a6b
LC
445
446 ;; Remove dependencies on optional libraries, notably GUI libraries.
0ef4da9f
MB
447 (native-inputs (filter (lambda (input)
448 (match input
449 ;; Work around the fact that modify-inputs can not
450 ;; delete specific outputs; i.e. here we should keep
451 ;; `(,glib "bin"), but not `(,glib "static").
452 ((label package output)
9d9c7d22 453 (not (string=? "static" output)))
0ef4da9f 454 (_ input)))
9d9c7d22
MB
455 (modify-inputs (package-native-inputs qemu)
456 (delete "gettext-minimal"))))
8394619b
LC
457 (inputs (modify-inputs (package-inputs qemu)
458 (delete "libusb"
459 "mesa"
460 "sdl2"
461 "spice"
462 "virglrenderer"
463 "gtk+"
464 "usbredir"
465 "libdrm"
466 "libepoxy"
467 "pulseaudio"
468 "vde2"
469 "libcacard")))))
309693e0 470
72a91d74
MB
471(define (system->qemu-target system)
472 (cond
473 ((string-prefix? "i686" system)
474 "qemu-system-i386")
475 ((string-prefix? "arm" system)
476 "qemu-system-arm")
477 (else
478 (string-append "qemu-system-" (match (string-split system #\-)
479 ((arch kernel) arch)
480 (_ system))))))
481
66df86a2
RG
482(define-public libx86emu
483 (package
484 (name "libx86emu")
15865446 485 (version "3.5")
66df86a2
RG
486 (home-page "https://github.com/wfeldt/libx86emu")
487 (source
488 (origin
489 (method git-fetch)
490 (uri
491 (git-reference
492 (url home-page)
493 (commit version)))
494 (file-name (git-file-name name version))
15865446
TGR
495 (sha256
496 (base32 "11nj3y7maz9ch15b1c2b69gd8d7mpaha377zpdbvfsmg5w9zz93l"))
66df86a2
RG
497 (modules
498 '((guix build utils)))
499 (snippet
500 `(begin
501 ;; Remove git2log program file.
502 (delete-file "git2log")
503 ;; Remove variables that depends on git2log.
504 (substitute* "Makefile"
505 (("GIT2LOG.*=.*$") "")
506 (("GITDEPS.*=.*$") "")
15865446 507 (("BRANCH.*=.*$") ""))))))
66df86a2
RG
508 (build-system gnu-build-system)
509 (arguments
510 `(#:test-target "test"
511 #:phases
512 (modify-phases %standard-phases
513 (add-after 'unpack 'patch
514 (lambda* (#:key outputs #:allow-other-keys)
515 (let* ((out (assoc-ref outputs "out"))
516 (include (string-append out "/include"))
517 (lib (string-append out "/lib")))
518 ;; Correct the values of version and install directories.
519 (substitute* "Makefile"
520 (("VERSION.*=.*$")
521 (string-append "VERSION := "
522 ,version "\n"))
523 (("PREFIX.*=.*$")
524 (string-append "PREFIX := " out "\n"))
525 (("MAJOR_VERSION.*=.*$")
526 (string-append "MAJOR_VERSION := "
527 ,(version-major version) "\n"))
528 (("LIBDIR.*=.*$")
529 (string-append "LIBDIR = " lib "\n"))
530 (("/usr/include") include)))))
531 (delete 'configure)))) ; no configure script
532 (native-inputs
8394619b 533 (list nasm perl))
66df86a2
RG
534 (synopsis "Library for x86 emulation")
535 (description "Libx86emu is a small library to emulate x86 instructions. The
536focus here is not a complete emulation but to cover enough for typical
537firmware blobs. You can
538@enumerate
539@item intercept any memory access or directly map real memory ranges
540@item intercept any i/o access, map real i/o ports, or block any real i/o
541@item intercept any interrupt
542@item add a hook to run after each instruction
543@item recognize a special x86 instruction that can trigger logging
544@item use integrated logging
545@end enumerate")
53d67f46 546 (license (license:x11-style "file://LICENSE"))))
66df86a2 547
72a91d74
MB
548(define-public ganeti
549 (package
550 (name "ganeti")
aa571670 551 (version "3.0.2")
72a91d74
MB
552 (source (origin
553 (method git-fetch)
554 (uri (git-reference
555 (url "https://github.com/ganeti/ganeti")
556 (commit (string-append "v" version))))
557 (sha256
aa571670 558 (base32 "1xw7rm0k411aj0a4hrxz9drn7827bihp6bwizbapfx8k4c3125k4"))
72a91d74
MB
559 (file-name (git-file-name name version))
560 (patches (search-patches "ganeti-shepherd-support.patch"
561 "ganeti-shepherd-master-failover.patch"
72a91d74 562 "ganeti-haskell-pythondir.patch"
dce0249f 563 "ganeti-pyyaml-compat.patch"
98f147db 564 "ganeti-disable-version-symlinks.patch"))))
72a91d74
MB
565 (build-system gnu-build-system)
566 (arguments
567 `(#:imported-modules (,@%gnu-build-system-modules
568 (guix build haskell-build-system)
569 (guix build python-build-system))
570 #:modules (,@%gnu-build-system-modules
571 ((guix build haskell-build-system) #:prefix haskell:)
d801827b 572 ((guix build python-build-system) #:select (site-packages))
89ea3ab2
MB
573 (srfi srfi-1)
574 (srfi srfi-26)
575 (ice-9 match)
72a91d74
MB
576 (ice-9 rdelim))
577
578 ;; The default test target includes a lot of checks that are only really
579 ;; relevant for developers such as NEWS file checking, line lengths, etc.
580 ;; We are only interested in the "py-tests" and "hs-tests" targets: this
581 ;; is the closest we've got even though it includes a little more.
582 #:test-target "check-TESTS"
583
584 #:configure-flags
585 (list "--localstatedir=/var"
586 "--sharedstatedir=/var"
587 "--sysconfdir=/etc"
588 "--enable-haskell-tests"
589
590 ;; By default, the build system installs everything to versioned
591 ;; directories such as $libdir/3.0 and relies on a $libdir/default
592 ;; symlink pointed from /etc/ganeti/{lib,share} to actually function.
593 ;; This is done to accommodate installing multiple versions in
594 ;; parallel, but is of little use to us as Guix users can just
595 ;; roll back and forth. Thus, disable it for simplicity.
596 "--disable-version-links"
597
598 ;; Ganeti can optionally take control over SSH host keys and
599 ;; distribute them to nodes as they are added, and also rotate keys
600 ;; with 'gnt-cluster renew-crypto --new-ssh-keys'. Thus it needs to
601 ;; know how to restart the SSH daemon.
602 "--with-sshd-restart-command='herd restart ssh-daemon'"
603
604 ;; Look for OS definitions in this directory by default. It can
605 ;; be changed in the cluster configuration.
606 "--with-os-search-path=/run/current-system/profile/share/ganeti/os"
607
608 ;; The default QEMU executable to use. We don't use the package
609 ;; here because this entry is stored in the cluster configuration.
610 (string-append "--with-kvm-path=/run/current-system/profile/bin/"
611 ,(system->qemu-target (%current-system))))
612 #:phases
613 (modify-phases %standard-phases
614 (add-after 'unpack 'create-vcs-version
615 (lambda _
616 ;; If we are building from a git checkout, we need to create a
617 ;; 'vcs-version' file manually because the build system does
618 ;; not have access to the git repository information.
619 (unless (file-exists? "vcs-version")
620 (call-with-output-file "vcs-version"
621 (lambda (port)
1ed567c8 622 (format port "v~a~%" ,version))))))
72a91d74 623 (add-after 'unpack 'patch-absolute-file-names
bf34db99 624 (lambda* (#:key inputs #:allow-other-keys)
72a91d74
MB
625 (substitute* '("lib/utils/process.py"
626 "lib/utils/text.py"
627 "src/Ganeti/Constants.hs"
628 "src/Ganeti/HTools/CLI.hs"
629 "test/py/ganeti.config_unittest.py"
630 "test/py/ganeti.hooks_unittest.py"
631 "test/py/ganeti.utils.process_unittest.py"
632 "test/py/ganeti.utils.text_unittest.py"
633 "test/py/ganeti.utils.wrapper_unittest.py")
bf34db99
MB
634 (("/bin/sh") (search-input-file inputs "/bin/sh"))
635 (("/bin/bash") (search-input-file inputs "/bin/bash"))
636 (("/usr/bin/env") (search-input-file inputs "/bin/env"))
637 (("/bin/true") (search-input-file inputs "/bin/true")))
72a91d74
MB
638
639 ;; This script is called by the node daemon at startup to perform
640 ;; sanity checks on the cluster IP addresses, and it is also used
641 ;; in a master-failover scenario. Add absolute references to
642 ;; avoid propagating these executables.
643 (substitute* "tools/master-ip-setup"
bf34db99
MB
644 (("arping") (search-input-file inputs "/bin/arping"))
645 (("ndisc6") (search-input-file inputs "/bin/ndisc6"))
646 (("fping") (search-input-file inputs "/sbin/fping"))
647 (("grep") (search-input-file inputs "/bin/grep"))
648 (("ip addr") (string-append (search-input-file inputs "/sbin/ip")
649 " addr")))))
72a91d74
MB
650 (add-after 'unpack 'override-builtin-PATH
651 (lambda _
652 ;; Ganeti runs OS install scripts and similar with a built-in
653 ;; hard coded PATH. Patch so it works on Guix System.
654 (substitute* "src/Ganeti/Constants.hs"
655 (("/sbin:/bin:/usr/sbin:/usr/bin")
656 "/run/setuid-programs:/run/current-system/profile/sbin:\
1ed567c8 657/run/current-system/profile/bin"))))
72a91d74
MB
658 (add-after 'bootstrap 'patch-sphinx-version-detection
659 (lambda _
660 ;; The build system runs 'sphinx-build --version' to verify that
661 ;; the Sphinx is recent enough, but does not expect the
662 ;; .sphinx-build-real executable name created by the Sphinx wrapper.
663 (substitute* "configure"
664 (("\\$SPHINX --version 2>&1")
1ed567c8
MC
665 "$SPHINX --version 2>&1 \
666| sed 's/.sphinx-build-real/sphinx-build/g'"))))
72a91d74
MB
667
668 ;; The build system invokes Cabal and GHC, which do not work with
669 ;; GHC_PACKAGE_PATH: <https://github.com/haskell/cabal/issues/3728>.
670 ;; Tweak the build system to do roughly what haskell-build-system does.
671 (add-before 'configure 'configure-haskell
672 (assoc-ref haskell:%standard-phases 'setup-compiler))
673 (add-after 'configure 'do-not-use-GHC_PACKAGE_PATH
674 (lambda _
675 (unsetenv "GHC_PACKAGE_PATH")
676 (substitute* "Makefile"
677 (("\\$\\(CABAL\\)")
678 "$(CABAL) --package-db=../package.conf.d")
679 (("\\$\\(GHC\\)")
1ed567c8 680 "$(GHC) -package-db=../package.conf.d"))))
856def7b
TS
681 (add-after 'configure 'make-ghc-use-shared-libraries
682 (lambda _
683 (substitute* "Makefile"
1ed567c8 684 (("HFLAGS =") "HFLAGS = -dynamic -fPIC"))))
72a91d74
MB
685 (add-after 'configure 'fix-installation-directories
686 (lambda _
687 (substitute* "Makefile"
688 ;; Do not attempt to create /var during install.
689 (("\\$\\(DESTDIR\\)\\$\\{localstatedir\\}")
690 "$(DESTDIR)${prefix}${localstatedir}")
691 ;; Similarly, do not attempt to install the sample ifup scripts
692 ;; to /etc/ganeti.
693 (("\\$\\(DESTDIR\\)\\$\\(ifupdir\\)")
1ed567c8 694 "$(DESTDIR)${prefix}$(ifupdir)"))))
72a91d74
MB
695 (add-before 'build 'adjust-tests
696 (lambda _
697 ;; Disable tests that can not run. Do it early to prevent
698 ;; touching the Makefile later and triggering a needless rebuild.
699 (substitute* "Makefile"
700 ;; These tests expect the presence of a 'root' user (via
701 ;; ganeti/runtime.py), which fails in the build environment.
702 (("test/py/ganeti\\.asyncnotifier_unittest\\.py") "")
703 (("test/py/ganeti\\.backend_unittest\\.py") "")
704 (("test/py/ganeti\\.daemon_unittest\\.py") "")
aa571670 705 (("test/py/ganeti\\.hypervisor\\.hv_kvm_unittest\\.py") "")
72a91d74
MB
706 (("test/py/ganeti\\.tools\\.ensure_dirs_unittest\\.py") "")
707 (("test/py/ganeti\\.utils\\.io_unittest-runasroot\\.py") "")
708 ;; Disable the bash_completion test, as it requires the full
709 ;; bash instead of bash-minimal.
710 (("test/py/bash_completion\\.bash")
711 "")
712 ;; This test requires networking.
713 (("test/py/import-export_unittest\\.bash")
1ed567c8 714 ""))))
72a91d74
MB
715 (add-after 'build 'build-bash-completions
716 (lambda _
641b31de
MB
717 (setenv "PYTHONPATH" ".")
718 (invoke "./autotools/build-bash-completion")
719 (unsetenv "PYTHONPATH")))
72a91d74
MB
720 (add-before 'check 'pre-check
721 (lambda* (#:key inputs #:allow-other-keys)
722 ;; Set TZDIR so that time zones are found.
6ea7297e 723 (setenv "TZDIR" (search-input-directory inputs "share/zoneinfo"))
72a91d74 724
72a91d74
MB
725 (substitute* "test/py/ganeti.utils.process_unittest.py"
726 ;; This test attempts to run an executable with
727 ;; RunCmd(..., reset_env=True), which fails because the default
728 ;; PATH from Constants.hs does not exist in the build container.
729 ((".*def testResetEnv.*" all)
730 (string-append " @unittest.skipIf(True, "
731 "\"cannot reset env in the build container\")\n"
732 all))
733
734 ;; XXX: Somehow this test fails in the build container, but
735 ;; works in 'guix environment -C', even without /bin/sh?
736 ((".*def testPidFile.*" all)
737 (string-append " @unittest.skipIf(True, "
738 "\"testPidFile fails in the build container\")\n"
739 all)))
740
741 ;; XXX: Why are these links not added automatically.
742 (with-directory-excursion "test/hs"
743 (for-each (lambda (file)
744 (symlink "../../src/htools" file))
745 '("hspace" "hscan" "hinfo" "hbal" "hroller"
1ed567c8 746 "hcheck" "hail" "hsqueeze")))))
72a91d74
MB
747 (add-after 'install 'install-bash-completions
748 (lambda* (#:key outputs #:allow-other-keys)
749 (let* ((out (assoc-ref outputs "out"))
750 (compdir (string-append out "/etc/bash_completion.d")))
751 (mkdir-p compdir)
752 (copy-file "doc/examples/bash_completion"
89ea3ab2 753 (string-append compdir "/ganeti"))
72a91d74
MB
754 ;; The one file contains completions for many different
755 ;; executables. Create symlinks for found completions.
756 (with-directory-excursion compdir
757 (for-each
758 (lambda (prog) (symlink "ganeti" prog))
759 (call-with-input-file "ganeti"
760 (lambda (port)
761 (let loop ((line (read-line port))
762 (progs '()))
763 (if (eof-object? line)
764 progs
765 (if (string-prefix? "complete" line)
766 (loop (read-line port)
767 ;; Extract "prog" from lines of the form:
768 ;; "complete -F _prog -o filenames prog".
769 ;; Note that 'burnin' is listed with the
770 ;; absolute file name, which is why we
771 ;; run everything through 'basename'.
89ea3ab2
MB
772 (match (string-split line #\ )
773 ((commands ... prog)
774 (cons (basename prog) progs))))
1ed567c8
MC
775 (loop (read-line port) progs)))))))))))
776 ;; Wrap all executables with GUIX_PYTHONPATH. We can't borrow
777 ;; the phase from python-build-system because we also need to wrap
778 ;; the scripts in $out/lib/ganeti such as "node-daemon-setup".
72a91d74 779 (add-after 'install 'wrap
d801827b 780 (lambda* (#:key inputs outputs #:allow-other-keys)
72a91d74
MB
781 (let* ((out (assoc-ref outputs "out"))
782 (sbin (string-append out "/sbin"))
d801827b
MB
783 (lib (string-append out "/lib"))
784 (PYTHONPATH (string-append (site-packages inputs outputs)
785 ":" (getenv "GUIX_PYTHONPATH"))))
72a91d74
MB
786 (define (shell-script? file)
787 (call-with-ascii-input-file file
788 (lambda (port)
789 (let ((shebang (false-if-exception (read-line port))))
790 (and shebang
791 (string-prefix? "#!" shebang)
792 (or (string-contains shebang "/bin/bash")
793 (string-contains shebang "/bin/sh")))))))
794
89ea3ab2 795 (define* (wrap? file #:rest _)
72a91d74
MB
796 ;; Do not wrap shell scripts because some are meant to be
797 ;; sourced, which breaks if they are wrapped. We do wrap
798 ;; the Haskell executables because some call out to Python
799 ;; directly.
800 (and (executable-file? file)
801 (not (symbolic-link? file))
802 (not (shell-script? file))))
803
804 (for-each (lambda (file)
805 (wrap-program file
1ed567c8 806 `("GUIX_PYTHONPATH" ":" prefix
d801827b 807 (,PYTHONPATH))))
89ea3ab2
MB
808 (append-map (cut find-files <> wrap?)
809 (list (string-append lib "/ganeti")
810 sbin)))))))))
72a91d74
MB
811 (native-inputs
812 `(("haskell" ,ghc)
813 ("cabal" ,cabal-install)
814 ("m4" ,m4)
815
816 ;; These inputs are necessary to bootstrap the package, because we
817 ;; have patched the build system.
818 ("autoconf" ,autoconf)
819 ("automake" ,automake)
820
821 ;; For the documentation.
822 ("python-docutils" ,python-docutils)
823 ("sphinx" ,python-sphinx)
88533283 824 ("pandoc" ,pandoc)
72a91d74
MB
825 ("dot" ,graphviz)
826
827 ;; Test dependencies.
828 ("fakeroot" ,fakeroot)
829 ("ghc-temporary" ,ghc-temporary)
830 ("ghc-test-framework" ,ghc-test-framework)
831 ("ghc-test-framework-hunit" ,ghc-test-framework-hunit)
832 ("ghc-test-framework-quickcheck2" ,ghc-test-framework-quickcheck2)
833 ("python-mock" ,python-mock)
834 ("python-pyyaml" ,python-pyyaml)
835 ("openssh" ,openssh)
836 ("procps" ,procps)
837 ("shelltestrunner" ,shelltestrunner)
838 ("tzdata" ,tzdata-for-tests)))
839 (inputs
bf34db99
MB
840 (list iputils ;for 'arping'
841 curl
842 fping
843 iproute
844 ndisc6
845 socat
846 qemu-minimal ;for qemu-img
847 ghc-attoparsec
848 ghc-base64-bytestring
849 ghc-cryptonite
850 ghc-curl
851 ghc-hinotify
852 ghc-hslogger
853 ghc-json
854 ghc-lens
855 ghc-lifted-base
856 ghc-network
857 ghc-old-time
858 ghc-psqueue
859 ghc-regex-pcre
860 ghc-utf8-string
861 ghc-zlib
862 ;; For the optional metadata daemon.
863 ghc-snap-core
864 ghc-snap-server
865 python
866 python-pyopenssl
867 python-simplejson
868 python-pyparsing
869 python-pyinotify
870 python-pycurl
871 python-bitarray
872 python-paramiko
873 python-psutil))
21f4a18e 874 (home-page "https://www.ganeti.org/")
72a91d74
MB
875 (synopsis "Cluster-based virtual machine management system")
876 (description
877 "Ganeti is a virtual machine management tool built on top of existing
878virtualization technologies such as Xen or KVM. Ganeti controls:
879
880@itemize @bullet
881@item Disk creation management;
882@item Operating system installation for instances (in co-operation with
883OS-specific install scripts); and
884@item Startup, shutdown, and failover between physical systems.
885@end itemize
886
887Ganeti is designed to facilitate cluster management of virtual servers and
888to provide fast and simple recovery after physical failures, using
889commodity hardware.")
890 (license license:bsd-2)))
891
ecd5db37
MB
892(define-public ganeti-instance-guix
893 (package
894 (name "ganeti-instance-guix")
b07ea0df 895 (version "0.6.1")
ecd5db37
MB
896 (home-page "https://github.com/mbakke/ganeti-instance-guix")
897 (source (origin
898 (method git-fetch)
899 (uri (git-reference (url home-page) (commit version)))
900 (file-name (git-file-name name version))
901 (sha256
902 (base32
b07ea0df 903 "18h8hdd38h1l89si8122v3ylzvvirs8hiypayklk1nr2wnfgbvff"))))
ecd5db37
MB
904 (build-system gnu-build-system)
905 (arguments
906 '(#:configure-flags '("--sysconfdir=/etc" "--localstatedir=/var")))
907 (native-inputs
8394619b 908 (list autoconf automake))
ecd5db37 909 (inputs
b07ea0df 910 (list util-linux qemu-minimal))
ecd5db37
MB
911 (synopsis "Guix OS integration for Ganeti")
912 (description
913 "This package provides a guest OS definition for Ganeti that uses
914Guix to build virtual machines.")
915 (license license:gpl3+)))
916
7b572c5f
MB
917(define-public ganeti-instance-debootstrap
918 (package
919 (name "ganeti-instance-debootstrap")
920 ;; We need two commits on top of the latest release for compatibility
921 ;; with newer sfdisk, as well as gnt-network integration.
922 (version "0.16-2-ge145396")
923 (home-page "https://github.com/ganeti/instance-debootstrap")
924 (source (origin
925 (method git-fetch)
926 (uri (git-reference (url home-page) (commit version)))
7d49e189 927 (file-name (git-file-name name version))
7b572c5f
MB
928 (sha256
929 (base32
930 "0f2isw9d8lawzj21rrq1q9xhq8xfa65rqbhqmrn59z201x9q1336"))))
931 (build-system gnu-build-system)
932 (arguments
933 '(#:configure-flags '("--sysconfdir=/etc" "--localstatedir=/var")
934 #:phases (modify-phases %standard-phases
935 (add-after 'unpack 'add-absolute-references
936 (lambda _
937 (substitute* "common.sh.in"
938 (("/sbin/blkid") (which "blkid"))
939 (("kpartx -")
940 (string-append (which "kpartx") " -")))
941 (substitute* "import"
942 (("restore -r")
943 (string-append (which "restore") " -r")))
944 (substitute* "export"
945 (("dump -0")
946 (string-append (which "dump") " -0")))
947 (substitute* "create"
948 (("debootstrap") (which "debootstrap"))
949 (("`which run-parts`") (which "run-parts"))
950 ;; Here we actually need to hard code /bin/passwd
951 ;; because it's called via chroot, which fails if
952 ;; "/bin" is not in PATH.
953 (("passwd") "/bin/passwd"))
954 #t))
955 (add-after 'unpack 'set-dpkg-arch
956 (lambda* (#:key system #:allow-other-keys)
957 ;; The create script passes --arch to debootstrap,
958 ;; and defaults to `dpkg --print-architecture` when
959 ;; ARCH is not set in variant.conf. Hard code the
960 ;; build-time architecture to avoid the dpkg dependency.
961 (let ((dpkg-arch
962 (cond ((string-prefix? "x86_64" system)
963 "amd64")
964 ((string-prefix? "i686" system)
965 "i386")
966 ((string-prefix? "aarch64" system)
967 "arm64")
968 (else (car (string-split system #\-))))))
969 (substitute* "create"
970 (("`dpkg --print-architecture`")
971 dpkg-arch))
972 #t)))
973 (add-after 'configure 'adjust-Makefile
974 (lambda _
975 ;; Do not attempt to create /etc/ganeti/instance-debootstrap
976 ;; and /etc/default/ganeti-instance-debootstrap during install.
977 ;; They are created by the Ganeti service.
978 (substitute* "Makefile"
979 (("\\$\\(variantsdir\\)")
980 "$(prefix)/etc/ganeti/instance-debootstrap/variants")
981 (("\\$\\(defaultsdir\\)")
982 "$(prefix)/etc/default/ganeti-instance-debootstrap"))
983 #t))
984 (add-after 'install 'make-variants.list-symlink
985 (lambda* (#:key outputs #:allow-other-keys)
986 ;; The Ganeti OS API mandates a variants.list file that
987 ;; describes all supported "variants" of this OS.
988 ;; Guix generates this file, so make the original file
989 ;; a symlink to it.
990 (with-directory-excursion (string-append
991 (assoc-ref outputs "out")
992 "/share/ganeti/os/debootstrap")
993 (delete-file "variants.list")
994 (symlink "/etc/ganeti/instance-debootstrap/variants/variants.list"
995 "variants.list"))
996 #t)))))
997 (native-inputs
8394619b 998 (list autoconf automake))
7b572c5f
MB
999 (inputs
1000 `(("debianutils" ,debianutils)
1001 ("debootstrap" ,debootstrap)
1002 ("dump" ,dump)
1003 ("kpartx" ,multipath-tools)
1004 ("util-linux" ,util-linux)))
1005 (synopsis "Debian OS integration for Ganeti")
1006 (description
1007 "This package provides a guest OS definition for Ganeti. It installs
1008Debian or a derivative using @command{debootstrap}.")
1009 (license license:gpl2+)))
1010
178ca9ef
EZ
1011(define-public spike
1012 (package
1013 (name "spike")
1014 (version "1.1.0")
1015 (source (origin
1016 (method git-fetch)
1017 (uri (git-reference
1018 (url "https://github.com/riscv-software-src/riscv-isa-sim")
1019 (commit (string-append "v" version))))
1020 (file-name (git-file-name name version))
1021 (sha256
1022 (base32 "0cik2m0byfp9ppq0hpg3xyrlp5ag1i4dww7a7872mlm36xxqagg0"))))
1023 (build-system gnu-build-system)
63641be6
EF
1024 (arguments
1025 (list
1026 #:phases
1027 #~(modify-phases %standard-phases
9afad0c1
AI
1028 (add-before 'configure 'configure-dtc-path
1029 (lambda* (#:key inputs #:allow-other-keys)
1030 ;; Reference dtc by its absolute store path.
1031 (substitute* "riscv/dts.cc"
1032 (("DTC")
1033 (string-append "\"" (search-input-file inputs "/bin/dtc") "\""))))))))
178ca9ef 1034 (inputs
63641be6 1035 (list bash-minimal dtc))
178ca9ef
EZ
1036 (native-inputs
1037 (list python-wrapper))
1038 (home-page "https://github.com/riscv-software-src/riscv-isa-sim")
1039 (synopsis "RISC-V ISA Simulator")
1040 (description "Spike, the RISC-V ISA Simulator, implements a functional model
1041of one or more RISC-V harts.")
1042 (license license:bsd-3)))
1043
a0f6c3b3
RW
1044(define-public libosinfo
1045 (package
1046 (name "libosinfo")
4b3b8733 1047 (version "1.10.0")
a0f6c3b3
RW
1048 (source
1049 (origin
1050 (method url-fetch)
d701f8bd 1051 (uri (string-append "https://releases.pagure.org/libosinfo/libosinfo-"
cfd9913f 1052 version ".tar.xz"))
a0f6c3b3
RW
1053 (sha256
1054 (base32
4b3b8733 1055 "0193sdvv9yj3h6wwhj441d2fhccc7fh0m36sl0fv5pl0ql7y0lm2"))))
cfd9913f 1056 (build-system meson-build-system)
a0f6c3b3 1057 (arguments
5b59df32
BT
1058 (list
1059 #:configure-flags
1060 #~(list (string-append "-Dwith-usb-ids-path="
1061 (search-input-file %build-inputs
1062 "share/hwdata/usb.ids"))
1063 (string-append "-Dwith-pci-ids-path="
1064 (search-input-file %build-inputs
1065 "share/hwdata/pci.ids")))
1066 #:phases
1067 #~(modify-phases %standard-phases
1068 (add-after 'unpack 'patch-osinfo-path
1069 (lambda* (#:key native-inputs inputs #:allow-other-keys)
1070 (substitute* "osinfo/osinfo_loader.c"
1071 (("path = DATA_DIR.*")
1072 (format #f "path = ~s;"
1073 (search-input-directory (or native-inputs inputs)
1074 "share/osinfo")))))))))
1075 (inputs (list libsoup-minimal-2 libxml2 libxslt osinfo-db))
a0f6c3b3 1076 (native-inputs
5b59df32
BT
1077 (list `(,glib "bin") ;glib-mkenums, etc.
1078 gobject-introspection
1079 gtk-doc/stable
1080 `(,hwdata "pci")
1081 `(,hwdata "usb")
1082 vala
1083 intltool
1084 pkg-config))
a0f6c3b3
RW
1085 (home-page "https://libosinfo.org/")
1086 (synopsis "Operating system information database")
1087 (description "libosinfo is a GObject based library API for managing
1088information about operating systems, hypervisors and the (virtual) hardware
1089devices they can support. It includes a database containing device metadata
1090and provides APIs to match/identify optimal devices for deploying an operating
1091system on a hypervisor. Via GObject Introspection, the API is available in
1092all common programming languages. Vala bindings are also provided.")
1093 ;; The library files are released under LGPLv2.1 or later; the source
1094 ;; files in the "tools" directory are released under GPLv2+.
b23b9667 1095 (license (list license:lgpl2.1+ license:gpl2+))))
a0f6c3b3 1096
5d4a8f9b
SB
1097(define-public lxc
1098 (package
1099 (name "lxc")
97e7fbe9 1100 (version "4.0.12")
5d4a8f9b
SB
1101 (source (origin
1102 (method url-fetch)
1103 (uri (string-append
1104 "https://linuxcontainers.org/downloads/lxc/lxc-"
1105 version ".tar.gz"))
1106 (sha256
1107 (base32
97e7fbe9 1108 "1vyk2j5w9gfyh23w3ar09cycyws16mxh3clbb33yhqzwcs1jy96v"))))
5d4a8f9b
SB
1109 (build-system gnu-build-system)
1110 (native-inputs
8394619b 1111 (list pkg-config docbook2x))
5d4a8f9b 1112 (inputs
8394619b 1113 (list gnutls libcap libseccomp libselinux))
5d4a8f9b 1114 (arguments
b56a8afb
TGR
1115 (list #:configure-flags
1116 #~(list (string-append "--docdir=" #$output "/share/doc/"
1117 #$name "-" #$version)
1118 "--sysconfdir=/etc"
1119 "--localstatedir=/var")
1120 #:phases
1121 #~(modify-phases %standard-phases
1122 (replace 'install
1123 (lambda _
1124 (invoke "make" "install"
1125 (string-append "bashcompdir=" #$output
1126 "/etc/bash_completion.d")
1127 ;; Don't install files into /var and /etc.
1128 "LXCPATH=/tmp/var/lib/lxc"
1129 "localstatedir=/tmp/var"
1130 "sysconfdir=/tmp/etc"
1131 "sysconfigdir=/tmp/etc/default"))))))
5d4a8f9b
SB
1132 (synopsis "Linux container tools")
1133 (home-page "https://linuxcontainers.org/")
1134 (description
1135 "LXC is a userspace interface for the Linux kernel containment features.
1136Through a powerful API and simple tools, it lets Linux users easily create and
1137manage system or application containers.")
b23b9667 1138 (license license:lgpl2.1+)))
5d4a8f9b 1139
404f6145
DM
1140(define-public lxcfs
1141 (package
1142 (name "lxcfs")
2445f780 1143 (version "4.0.11")
404f6145
DM
1144 (home-page "https://github.com/lxc/lxcfs")
1145 (source (origin
1146 (method git-fetch)
1147 (uri (git-reference (url home-page)
1148 (commit (string-append "lxcfs-" version))))
1149 (file-name (git-file-name name version))
1150 (sha256
1151 (base32
2445f780 1152 "02cgzh97cgxh9iyf7gkn5ikdc0sfzqfjj6al0hikdf9rbwcscqwd"))))
404f6145
DM
1153 (arguments
1154 '(#:configure-flags '("--localstatedir=/var")))
1155 (native-inputs
8394619b 1156 (list autoconf automake libtool pkg-config))
404f6145 1157 (inputs
8394619b 1158 (list fuse))
404f6145 1159 (build-system gnu-build-system)
98ae5c9d
TGR
1160 (synopsis "FUSE-based file system for LXC")
1161 (description "LXCFS is a small FUSE file system written with the intention
404f6145 1162of making Linux containers feel more like a virtual machine.
98ae5c9d 1163It started as a side project of LXC but can be used by any run-time.")
404f6145
DM
1164 (license license:lgpl2.1+)))
1165
5edfa6d1
AW
1166(define-public lxd
1167 (package
1168 (name "lxd")
9d9f0b96 1169 (version "4.24")
5edfa6d1
AW
1170 (source (origin
1171 (method url-fetch)
1172 (uri (string-append
1173 "https://github.com/lxc/lxd/releases/download/"
1174 "lxd-" version "/lxd-" version ".tar.gz"))
1175 (sha256
1176 (base32
9d9f0b96 1177 "0lmjmvm98m6yjxcqlfw690i71nazfzgrm3mzbjj77g1631df3ylp"))))
5edfa6d1
AW
1178 (build-system go-build-system)
1179 (arguments
1180 `(#:import-path "github.com/lxc/lxd"
1181 #:tests? #f ;; tests fail due to missing /var, cgroups, etc.
1182 #:modules ((guix build go-build-system)
1183 (guix build union)
1184 (guix build utils)
1185 (srfi srfi-1))
1186 #:phases
1187 (modify-phases %standard-phases
1188 (add-after 'unpack 'unpack-dist
1189 (lambda* (#:key import-path #:allow-other-keys)
1190 (with-directory-excursion (string-append "src/" import-path)
d6f890a4
TGR
1191 ;; Move all the dependencies into the src directory.
1192 (copy-recursively "_dist/src" "../../.."))))
5edfa6d1
AW
1193 (replace 'build
1194 (lambda* (#:key import-path #:allow-other-keys)
1195 (with-directory-excursion (string-append "src/" import-path)
d6f890a4 1196 (invoke "make" "build" "CC=gcc" "TAG_SQLITE3=libsqlite3"))))
5edfa6d1
AW
1197 (replace 'check
1198 (lambda* (#:key tests? import-path #:allow-other-keys)
1199 (when tests?
1200 (with-directory-excursion (string-append "src/" import-path)
d6f890a4 1201 (invoke "make" "check" "CC=gcc" "TAG_SQLITE3=libsqlite3")))))
5edfa6d1
AW
1202 (replace 'install
1203 (lambda* (#:key inputs outputs import-path #:allow-other-keys)
1204 (let* ((out (assoc-ref outputs "out"))
1205 (bin-dir
1206 (string-append out "/bin/"))
1207 (doc-dir
1208 (string-append out "/share/doc/lxd-" ,version))
1209 (completions-dir
1210 (string-append out "/share/bash-completion/completions")))
1211 (with-directory-excursion (string-append "src/" import-path)
d6f890a4 1212 ;; Wrap lxd with run-time dependencies.
5edfa6d1
AW
1213 (wrap-program (string-append bin-dir "lxd")
1214 `("PATH" ":" prefix
1215 ,(fold (lambda (input paths)
73761d80
LC
1216 ;; TODO: Use 'search-input-directory' rather
1217 ;; than look up inputs by name.
5edfa6d1
AW
1218 (let* ((in (assoc-ref inputs input))
1219 (bin (string-append in "/bin"))
1220 (sbin (string-append in "/sbin")))
1221 (append (filter file-exists?
1222 (list bin sbin)) paths)))
1223 '()
73761d80 1224 '("bash-minimal" "acl" "rsync" "tar" "xz" "btrfs-progs"
5edfa6d1 1225 "gzip" "dnsmasq" "squashfs-tools" "iproute2"
dbe221a8 1226 "criu" "iptables" "attr"))))
d6f890a4 1227 ;; Remove unwanted binaries.
5edfa6d1
AW
1228 (for-each (lambda (prog)
1229 (delete-file (string-append bin-dir prog)))
1230 '("deps" "macaroon-identity" "generate"))
d6f890a4 1231 ;; Install documentation.
5edfa6d1
AW
1232 (for-each (lambda (file)
1233 (install-file file doc-dir))
1234 (find-files "doc"))
d6f890a4 1235 ;; Install bash completion.
5edfa6d1 1236 (rename-file "scripts/bash/lxd-client" "scripts/bash/lxd")
d6f890a4 1237 (install-file "scripts/bash/lxd" completions-dir))))))))
5edfa6d1 1238 (native-inputs
d6f890a4 1239 (list ;; Test dependencies:
8394619b
LC
1240 ;; ("go-github-com-rogpeppe-godeps" ,go-github-com-rogpeppe-godeps)
1241 ;; ("go-github-com-tsenart-deadcode" ,go-github-com-tsenart-deadcode)
1242 ;; ("go-golang-org-x-lint" ,go-golang-org-x-lint)
1243 pkg-config))
5edfa6d1 1244 (inputs
73761d80
LC
1245 (list acl
1246 eudev
1247 libdqlite
1248 libraft
1249 libcap
1250 lxc
1251 ;; Run-time dependencies.
1252 attr
1253 bash-minimal
1254 rsync
1255 tar
1256 xz
1257 btrfs-progs
1258 gzip
1259 dnsmasq
1260 squashfs-tools
1261 iproute
1262 criu
1263 iptables))
5edfa6d1
AW
1264 (synopsis "Daemon based on liblxc offering a REST API to manage containers")
1265 (home-page "https://linuxcontainers.org/lxd/")
1266 (description "LXD is a next generation system container manager. It
1267offers a user experience similar to virtual machines but using Linux
1268containers instead. It's image based with pre-made images available for a
1269wide number of Linux distributions and is built around a very powerful, yet
1270pretty simple, REST API.")
1271 (license license:asl2.0)))
1272
309693e0
RW
1273(define-public libvirt
1274 (package
1275 (name "libvirt")
79ed9584 1276 (version "7.9.0")
41097b2d
TGR
1277 (source
1278 (origin
1279 (method url-fetch)
1280 (uri (string-append "https://libvirt.org/sources/libvirt-"
1281 version ".tar.xz"))
1282 (sha256
79ed9584 1283 (base32 "131fyxb05rrcr9ih4mhhjyw3cgsxh5l12vj4y109q9vlynsz5742"))
0d4ae86b
BW
1284 (patches (search-patches "libvirt-add-install-prefix.patch"))))
1285 (build-system meson-build-system)
309693e0 1286 (arguments
bd9eb384 1287 `(#:configure-flags
0d4ae86b
BW
1288 (list "-Ddriver_qemu=enabled"
1289 "-Dqemu_user=nobody"
1290 "-Dqemu_group=kvm"
1291 "-Dstorage_disk=enabled"
1292 "-Dstorage_dir=enabled"
1293 "-Dpolkit=enabled"
eb72b3d9
TGR
1294 ;; XXX The default, but required to make -Dsasl ‘stick’.
1295 ;; See <https://gitlab.com/libvirt/libvirt/-/issues/185>
1296 "-Ddriver_remote=enabled"
0d4ae86b
BW
1297 "-Dnls=enabled" ;translations
1298 (string-append "-Ddocdir=" (assoc-ref %outputs "out") "/share/doc/"
175047cd 1299 ,name "-" ,version)
0d4ae86b
BW
1300 "-Dbash_completion=enabled"
1301 (string-append "-Dinstall_prefix=" (assoc-ref %outputs "out"))
a4b93921 1302 "--sysconfdir=/etc"
309693e0
RW
1303 "--localstatedir=/var")
1304 #:phases
1305 (modify-phases %standard-phases
a362d9c6
TGR
1306 (add-after 'unpack 'skip-directory-confusion
1307 (lambda _
1308 ;; Don't try to install an (unused) /var outside of the store.
1309 (substitute* "scripts/meson-install-dirs.py"
1310 (("destdir = .*")
1311 "destdir = '/tmp'"))))
bd9eb384
TGR
1312 (add-before 'configure 'disable-broken-tests
1313 (lambda _
0d4ae86b
BW
1314 (let ((tests (list "commandtest" ; hangs idly
1315 "qemuxml2argvtest" ; fails
1316 "virnetsockettest"))) ; tries to network
1317 (substitute* "tests/meson.build"
1318 (((format #f ".*'name': '(~a)'.*" (string-join tests "|")))
a362d9c6 1319 ""))))))))
309693e0 1320 (inputs
063477ba 1321 `(("acl" ,acl)
bdc0a9e0 1322 ("attr" ,attr)
1099073c 1323 ("fuse" ,fuse)
063477ba 1324 ("libxml2" ,libxml2)
8981465b
RH
1325 ("eudev" ,eudev)
1326 ("libpciaccess" ,libpciaccess)
309693e0
RW
1327 ("gnutls" ,gnutls)
1328 ("dbus" ,dbus)
309693e0
RW
1329 ("libpcap" ,libpcap)
1330 ("libnl" ,libnl)
0d4ae86b 1331 ("libssh2" ,libssh2) ;optional
308af634 1332 ("libtirpc" ,libtirpc) ;for <rpc/rpc.h>
bb93042c 1333 ("libuuid" ,util-linux "lib")
308af634 1334 ("lvm2" ,lvm2) ;for libdevmapper
309693e0
RW
1335 ("curl" ,curl)
1336 ("openssl" ,openssl)
0d4ae86b 1337 ("readline" ,readline)
309693e0 1338 ("cyrus-sasl" ,cyrus-sasl)
309693e0 1339 ("libyajl" ,libyajl)
8fc7bd23
SB
1340 ("audit" ,audit)
1341 ("dmidecode" ,dmidecode)
1342 ("dnsmasq" ,dnsmasq)
1343 ("ebtables" ,ebtables)
ee5c4f70 1344 ("parted" ,parted)
8fc7bd23
SB
1345 ("iproute" ,iproute)
1346 ("iptables" ,iptables)))
309693e0 1347 (native-inputs
0d4ae86b
BW
1348 `(("bash-completion" ,bash-completion)
1349 ("gettext" ,gettext-minimal)
1350 ("xsltproc" ,libxslt)
b8fb94d5
TGR
1351 ("perl" ,perl)
1352 ("pkg-config" ,pkg-config)
1353 ("polkit" ,polkit)
0d4ae86b
BW
1354 ("python" ,python-wrapper)
1355 ("python-docutils" ,python-docutils) ;for rst2html
1356 ("rpcsvc-proto" ,rpcsvc-proto))) ;for rpcgen
2e508b6d 1357 (home-page "https://libvirt.org")
309693e0
RW
1358 (synopsis "Simple API for virtualization")
1359 (description "Libvirt is a C toolkit to interact with the virtualization
1360capabilities of recent versions of Linux. The library aims at providing long
1361term stable C API initially for the Xen paravirtualization but should be able
1362to integrate other virtualization mechanisms if needed.")
b23b9667 1363 (license license:lgpl2.1+)))
597ea122
RW
1364
1365(define-public libvirt-glib
1366 (package
1367 (name "libvirt-glib")
29383ecc 1368 (version "4.0.0")
597ea122
RW
1369 (source (origin
1370 (method url-fetch)
1371 (uri (string-append "ftp://libvirt.org/libvirt/glib/"
29383ecc 1372 "libvirt-glib-" version ".tar.xz"))
597ea122
RW
1373 (sha256
1374 (base32
29383ecc
PL
1375 "1gdcvqz88qkp402zra9csc6391f2xki1270x683n6ixakl3gf8w4"))))
1376 (build-system meson-build-system)
597ea122 1377 (inputs
8394619b
LC
1378 (list openssl cyrus-sasl lvm2 ; for libdevmapper
1379 libyajl))
597ea122 1380 (native-inputs
8394619b
LC
1381 (list pkg-config intltool
1382 `(,glib "bin") vala))
7e2c050a
TGR
1383 (propagated-inputs
1384 ;; ‘Required:’ by the installed .pc files.
8394619b 1385 (list glib libvirt libxml2 gobject-introspection))
b3fee5c1 1386 (home-page "https://libvirt.org")
597ea122
RW
1387 (synopsis "GLib wrapper around libvirt")
1388 (description "libvirt-glib wraps the libvirt library to provide a
1389high-level object-oriented API better suited for glib-based applications, via
1390three libraries:
1391
1392@enumerate
1393@item libvirt-glib - GLib main loop integration & misc helper APIs
1394@item libvirt-gconfig - GObjects for manipulating libvirt XML documents
1395@item libvirt-gobject - GObjects for managing libvirt objects
1396@end enumerate
1397")
b23b9667 1398 (license license:lgpl2.1+)))
7cd2032f
RW
1399
1400(define-public python-libvirt
1401 (package
1402 (name "python-libvirt")
9f8a4760 1403 (version "7.9.0")
cb94ae38
TGR
1404 (source
1405 (origin
1406 (method url-fetch)
cb94ae38
TGR
1407 (uri (string-append "https://libvirt.org/sources/python/libvirt-python-"
1408 version ".tar.gz"))
1409 (sha256
9f8a4760 1410 (base32 "0nakisj2ady5a41k4zc95k0kp749f4ppmxgr91b1h1dzbzxcydc5"))))
7cd2032f
RW
1411 (build-system python-build-system)
1412 (arguments
1413 `(#:phases
1414 (modify-phases %standard-phases
8ac0d4fb
TGR
1415 (replace 'check
1416 (lambda* (#:key inputs outputs tests? #:allow-other-keys)
1417 (when tests?
1418 ;; No reason to explicity invoke Python on a wrapped pytest.
1419 (substitute* "setup.py"
1420 (("sys\\.executable, pytest") "pytest"))
1421 (add-installed-pythonpath inputs outputs)
1422 (setenv "LIBVIRT_API_COVERAGE" "whynot")
1423 (invoke "python" "setup.py" "test")))))))
7cd2032f 1424 (inputs
8394619b 1425 (list libvirt))
482d9591 1426 (propagated-inputs
8394619b 1427 (list python-lxml))
7cd2032f 1428 (native-inputs
8394619b 1429 (list pkg-config python-pytest))
b3fee5c1 1430 (home-page "https://libvirt.org")
7cd2032f
RW
1431 (synopsis "Python bindings to libvirt")
1432 (description "This package provides Python bindings to the libvirt
1433virtualization library.")
b23b9667 1434 (license license:lgpl2.1+)))
7cd2032f 1435
2f82b53b
RW
1436(define-public virt-manager
1437 (package
1438 (name "virt-manager")
653faaeb 1439 (version "3.2.0")
2f82b53b
RW
1440 (source (origin
1441 (method url-fetch)
1442 (uri (string-append "https://virt-manager.org/download/sources"
1443 "/virt-manager/virt-manager-"
1444 version ".tar.gz"))
1445 (sha256
1446 (base32
653faaeb 1447 "11kvpzcmyir91qz0dsnk7748jbb4wr8mrc744w117qc91pcy6vrb"))))
2f82b53b
RW
1448 (build-system python-build-system)
1449 (arguments
af7014a1 1450 `(#:use-setuptools? #f ; uses custom distutils 'install' command
20f524a4
CB
1451 #:tests? #f ; TODO The tests currently fail
1452 ; RuntimeError: Loop condition wasn't
1453 ; met
f023685d
AP
1454 #:imported-modules ((guix build glib-or-gtk-build-system)
1455 ,@%python-build-system-modules)
2f82b53b
RW
1456 #:modules ((ice-9 match)
1457 (srfi srfi-26)
1458 (guix build python-build-system)
f023685d 1459 ((guix build glib-or-gtk-build-system) #:prefix glib-or-gtk:)
2f82b53b
RW
1460 (guix build utils))
1461 #:phases
1462 (modify-phases %standard-phases
1463 (add-after 'unpack 'fix-setup
1464 (lambda* (#:key outputs #:allow-other-keys)
845bf4f4 1465 (substitute* "virtinst/buildconfig.py"
2f82b53b
RW
1466 (("/usr") (assoc-ref outputs "out")))
1467 #t))
4ad8fbd1
AP
1468 (add-after 'unpack 'fix-default-uri
1469 (lambda* (#:key inputs #:allow-other-keys)
af7014a1 1470 ;; Xen is not available for now - so only patch qemu.
845bf4f4 1471 (substitute* "virtManager/createconn.py"
bc64d955
LC
1472 (("/usr(/bin/qemu-system-[a-zA-Z0-9_-]+)" _ suffix)
1473 (search-input-file inputs suffix)))
4ad8fbd1 1474 #t))
2f82b53b
RW
1475 (add-before 'wrap 'wrap-with-GI_TYPELIB_PATH
1476 (lambda* (#:key inputs outputs #:allow-other-keys)
1477 (let* ((bin (string-append (assoc-ref outputs "out") "/bin"))
1478 (bin-files (find-files bin ".*"))
1479 (paths (map (match-lambda
1480 ((output . directory)
1481 (let* ((girepodir (string-append
1482 directory
1483 "/lib/girepository-1.0")))
1484 (if (file-exists? girepodir)
1485 girepodir #f))))
1486 inputs)))
1487 (for-each (lambda (file)
1488 (format #t "wrapping ~a\n" file)
1489 (wrap-program file
1490 `("GI_TYPELIB_PATH" ":" prefix
1491 ,(filter identity paths))))
1492 bin-files))
f023685d 1493 #t))
20f524a4
CB
1494 (replace 'check
1495 (lambda* (#:key tests? #:allow-other-keys)
1496 (when tests?
1497 (setenv "HOME" "/tmp")
653faaeb 1498 (setenv "XDG_CACHE_HOME" "/tmp")
20f524a4
CB
1499 (system "Xvfb :1 &")
1500 (setenv "DISPLAY" ":1")
1501 ;; Dogtail requires that Assistive Technology support be enabled
1502 (setenv "GTK_MODULES" "gail:atk-bridge")
653faaeb 1503 (invoke "dbus-run-session" "--" "pytest" "--uitests"))
20f524a4 1504 #t))
f023685d
AP
1505 (add-after 'install 'glib-or-gtk-compile-schemas
1506 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
25de37e1 1507 (add-after 'wrap 'glib-or-gtk-wrap
f023685d 1508 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap)))))
2f82b53b 1509 (inputs
8394619b
LC
1510 (list dconf
1511 gtk+
1512 gtk-vnc
1513 gtksourceview
1514 libvirt
1515 libvirt-glib
1516 libosinfo
1517 vte
1518 python-libvirt
1519 python-requests
1520 python-pycairo
1521 python-pygobject
1522 python-libxml2
1523 spice-gtk))
2f82b53b
RW
1524 ;; virt-manager searches for qemu-img or kvm-img in the PATH.
1525 (propagated-inputs
8394619b 1526 (list qemu))
2f82b53b 1527 (native-inputs
af7014a1 1528 `(("glib" ,glib "bin") ; glib-compile-schemas
f468df9f 1529 ("gobject-introspection" ,gobject-introspection)
e6efcd58 1530 ("gtk+" ,gtk+ "bin") ; gtk-update-icon-cache
2f82b53b 1531 ("perl" ,perl) ; pod2man
20f524a4 1532 ("intltool" ,intltool)
653faaeb 1533 ("rst2man" ,python-docutils)
20f524a4 1534 ;; The following are required for running the tests
653faaeb 1535 ;; ("python-pytest" ,python-pytest)
20f524a4
CB
1536 ;; ("python-dogtail" ,python-dogtail)
1537 ;; ("xvfb" ,xorg-server-for-tests)
1538 ;; ("dbus" ,dbus)
1539 ;; ("at-spi2-core" ,at-spi2-core)
1540 ;; ("gsettings-desktop-schemas" ,gsettings-desktop-schemas)
1541 ))
2f82b53b
RW
1542 (home-page "https://virt-manager.org/")
1543 (synopsis "Manage virtual machines")
1544 (description
1545 "The virt-manager application is a desktop user interface for managing
1546virtual machines through libvirt. It primarily targets KVM VMs, but also
1547manages Xen and LXC (Linux containers). It presents a summary view of running
1548domains, their live performance and resource utilization statistics.")
b23b9667 1549 (license license:gpl2+)))
fe420383
RW
1550
1551(define-public criu
1552 (package
1553 (name "criu")
ee44a724 1554 (version "3.17")
3f90f835
TGR
1555 (source
1556 (origin
1557 (method git-fetch)
1558 (uri (git-reference
1559 (url "https://github.com/checkpoint-restore/criu")
1560 (commit (string-append "v" version))))
1561 (file-name (git-file-name name version))
1562 (sha256
ee44a724 1563 (base32 "1qql1xp2zkkd7z50vp0nylx3rqrp8xa3c6x25c886d5i1j9pak5x"))))
fe420383
RW
1564 (build-system gnu-build-system)
1565 (arguments
1566 `(#:test-target "test"
1567 #:tests? #f ; tests require mounting as root
1568 #:make-flags
1569 (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
ee44a724
TGR
1570 (string-append "LIBDIR=$(PREFIX)/lib")
1571 ;; Upstream mistakenly puts binaries in /var. Now, in practice no
1572 ;; plugins are built, but the build system still fails otherwise.
1573 (string-append "PLUGINDIR=$(LIBDIR)/criu")
2dffe476
LC
1574 (string-append "ASCIIDOC="
1575 (search-input-file %build-inputs
1576 "/bin/asciidoc"))
04542d5a 1577 (string-append "PYTHON=python3")
2dffe476 1578 (string-append "XMLTO="
ef509e93 1579 (search-input-file %build-inputs
2dffe476 1580 "/bin/xmlto")))
fe420383
RW
1581 #:phases
1582 (modify-phases %standard-phases
c07266de
TGR
1583 (delete 'configure) ; no configure script
1584 (add-after 'unpack 'fix-documentation
5d1601ea 1585 (lambda* (#:key inputs outputs #:allow-other-keys)
fe420383 1586 (substitute* "Documentation/Makefile"
5d1601ea 1587 (("-m custom.xsl")
1588 (string-append
1589 "-m custom.xsl --skip-validation -x "
1590 (assoc-ref inputs "docbook-xsl") "/xml/xsl/"
1591 ,(package-name docbook-xsl) "-"
1592 ,(package-version docbook-xsl)
b4d02219 1593 "/manpages/docbook.xsl")))))
580f33e1 1594 (add-after 'unpack 'hardcode-variables
ee44a724 1595 (lambda* (#:key inputs outputs #:allow-other-keys)
580f33e1
EF
1596 ;; Hardcode arm version detection
1597 (substitute* "Makefile"
ee44a724
TGR
1598 (("ARMV.*:=.*") "ARMV := 7\n"))
1599 ;; Hard-code the correct PLUGINDIR above.
1600 (substitute* "criu/include/plugin.h"
1601 (("/var") (string-append (assoc-ref outputs "out"))))
1602 ))
fe420383
RW
1603 (add-before 'build 'fix-symlink
1604 (lambda* (#:key inputs #:allow-other-keys)
1605 ;; The file 'images/google/protobuf/descriptor.proto' points to
1606 ;; /usr/include/..., which obviously does not exist.
1607 (let* ((file "google/protobuf/descriptor.proto")
1608 (target (string-append "images/" file))
425ccde6
LC
1609 (source (search-input-file
1610 inputs
1611 (string-append "include/" file))))
fe420383 1612 (delete-file target)
b4d02219 1613 (symlink source target))))
fe420383
RW
1614 (add-after 'install 'wrap
1615 (lambda* (#:key inputs outputs #:allow-other-keys)
1616 ;; Make sure 'crit' runs with the correct PYTHONPATH.
04542d5a
TGR
1617 (let* ((out (assoc-ref outputs "out"))
1618 (site (string-append out "/lib/python"
1619 ,(version-major+minor
1620 (package-version python))
1621 "/site-packages"))
bc5155b9 1622 (path (getenv "GUIX_PYTHONPATH")))
fe420383 1623 (wrap-program (string-append out "/bin/crit")
bc5155b9 1624 `("GUIX_PYTHONPATH" ":" prefix (,site ,path))))))
a47ce1e0
TGR
1625 (add-after 'install 'delete-static-libraries
1626 ;; Not building/installing these at all doesn't seem to be supported.
1627 (lambda* (#:key outputs #:allow-other-keys)
1628 (let ((out (assoc-ref outputs "out")))
1629 (for-each delete-file (find-files out "\\.a$"))))))))
fe420383
RW
1630 (inputs
1631 `(("protobuf" ,protobuf)
04542d5a
TGR
1632 ("python" ,python)
1633 ("python-protobuf" ,python-protobuf)
fe420383
RW
1634 ("iproute" ,iproute)
1635 ("libaio" ,libaio)
1636 ("libcap" ,libcap)
1637 ("libnet" ,libnet)
5d1601ea 1638 ("libnl" ,libnl)
bb223220
TGR
1639 ("libbsd" ,libbsd)
1640 ("nftables" ,nftables)))
fe420383 1641 (native-inputs
8394619b
LC
1642 (list pkg-config
1643 perl
8394619b
LC
1644 asciidoc
1645 xmlto
1646 docbook-xml
1647 docbook-xsl))
c2fb89ef
ZZ
1648 (propagated-inputs
1649 ;; included by 'rpc.pb-c.h'
1650 (list protobuf-c))
fe420383
RW
1651 (home-page "https://criu.org")
1652 (synopsis "Checkpoint and restore in user space")
1653 (description "Using this tool, you can freeze a running application (or
1654part of it) and checkpoint it to a hard drive as a collection of files. You
1655can then use the files to restore and run the application from the point it
1656was frozen at. The distinctive feature of the CRIU project is that it is
1657mainly implemented in user space.")
1658 ;; The project is licensed under GPLv2; files in the lib/ directory are
1659 ;; LGPLv2.1.
b23b9667 1660 (license (list license:gpl2 license:lgpl2.1))))
f46a3523 1661
5daac1a7
MC
1662(define-public python-qemu-qmp
1663 (package
1664 (name "python-qemu-qmp")
1665 (version "0.0.0a0")
1666 (source
1667 (origin
1668 (method url-fetch)
1669 (uri (pypi-uri "qemu.qmp" version))
1670 (sha256
1671 (base32 "1rpsbiwvngij6fjcc5cx1azcc4dxmm080crr31wc7jrm7i61p7c2"))))
1672 (build-system python-build-system)
1673 (arguments
1674 (list
1675 #:phases
1676 #~(modify-phases %standard-phases
1677 (replace 'check
1678 (lambda* (#:key tests? #:allow-other-keys)
1679 (when tests?
1680 ;; The Avocado test runner insists on writing stuff to HOME.
1681 (setenv "HOME" "/tmp")
1682 ;; The mypy tests fail (see:
1683 ;; https://gitlab.com/jsnow/qemu.qmp/-/issues/1).
1684 (delete-file "tests/mypy.sh")
1685 (invoke "avocado" "--show=all" "run" "tests")))))))
1686 (native-inputs
1687 (list python-avocado-framework
1688 python-setuptools-scm
1689 python-flake8
1690 python-isort
1691 python-pylint))
1692 (propagated-inputs
1693 (list python-pygments
1694 python-urwid
1695 python-urwid-readline))
1696 (home-page "https://gitlab.com/jsnow/qemu.qmp")
1697 (synopsis "QEMU Monitor Protocol Python library")
1698 (description "@code{emu.qmp} is a
1699@url{https://gitlab.com/qemu-project/qemu/-/blob/master/docs/interop/qmp-intro.txt,
1700QEMU Monitor Protocol (QMP)} library written in Python. It is used to send
1701QMP messages to running QEMU emulators. It can be used to communicate with
1702QEMU emulators, the QEMU Guest Agent (QGA), the QEMU Storage Daemon (QSD), or
1703any other utility or application that speaks QMP.")
1704 (license license:gpl2+)))
1705
f46a3523
RH
1706(define-public qmpbackup
1707 (package
1708 (name "qmpbackup")
8f49a084 1709 (version "0.23")
f46a3523 1710 (source (origin
7be834d5
EF
1711 (method git-fetch)
1712 (uri (git-reference
8f49a084
MC
1713 (url "https://github.com/abbbi/qmpbackup")
1714 (commit (string-append "v" version))))
7be834d5 1715 (file-name (git-file-name name version))
f46a3523
RH
1716 (sha256
1717 (base32
8f49a084 1718 "0x9v81z0b2qr2y6m46rfnl4kl5jnixsdrl1c790iwl6pq9kzzvzg"))))
f46a3523 1719 (build-system python-build-system)
8f49a084
MC
1720 ;; The test suite requires to download a 241 MiB QEMU image; skip it.
1721 (arguments (list #:tests? #f))
1722 (inputs (list python-qemu-qmp))
f46a3523
RH
1723 (home-page "https://github.com/abbbi/qmpbackup")
1724 (synopsis "Backup and restore QEMU machines")
8f49a084
MC
1725 (description "@command{qmpbackup} is designed to create and restore full
1726and incremental backups of running QEMU virtual machines via QMP, the QEMU
f46a3523 1727Machine Protocol.")
b23b9667 1728 (license license:gpl3+)))
fb9472a3 1729
c9d2d310 1730(define-public looking-glass-client
d997fcd3
OP
1731 (package
1732 (name "looking-glass-client")
1733 (version "B5")
1734 (source
1735 (origin
16a47f23 1736 (method git-fetch)
d997fcd3
OP
1737 (uri (git-reference
1738 (url "https://github.com/gnif/LookingGlass")
1739 (commit version)
1740 (recursive? #t)))
16a47f23
RH
1741 (file-name (git-file-name name version))
1742 (sha256
1743 (base32
d997fcd3
OP
1744 "09mn544x5hg1z31l92ksk7fi7yj9r8xdk0dcl9fk56ivcr452ylm"))))
1745 (build-system cmake-build-system)
1746 (inputs
1747 (list bash-minimal
1748 fontconfig
1749 freetype
1750 glu
1751 gmp
1752 libglvnd
1753 libiberty
1754 libx11
1755 libxcursor
1756 libxfixes
1757 libxi
1758 libxinerama
1759 libxkbcommon
1760 libxpresent
1761 libxrandr
1762 libxscrnsaver
1763 mesa
1764 openssl
1765 sdl2
1766 sdl2-ttf
1767 spice-protocol
1768 wayland
1769 wayland-protocols
1770 `(,zlib "static")))
1771 (native-inputs (list libconfig nettle pkg-config))
1772 (arguments
1773 `(#:tests? #f ;; No tests are available.
1774 #:make-flags '("CC=gcc")
1775 #:phases (modify-phases %standard-phases
1776 (add-before 'configure 'chdir-to-client
1777 (lambda* (#:key outputs #:allow-other-keys)
1778 (chdir "client")
1779 #t))
1780 (replace 'install
1781 (lambda* (#:key outputs #:allow-other-keys)
1782 (install-file "looking-glass-client"
1783 (string-append (assoc-ref outputs "out")
1784 "/bin"))
1785 #t))
1786 (add-after 'install 'wrapper
1787 (lambda* (#:key inputs outputs #:allow-other-keys)
1788 (wrap-program
1789 (string-append (assoc-ref outputs "out")
1790 "/bin/looking-glass-client")
1791 `("LD_LIBRARY_PATH" ":" prefix
1792 ,(map (lambda (name)
1793 (let ((input (assoc-ref inputs name)))
1794 (string-append input "/lib")))
1795 '("gmp"
1796 "libxi"
1797 "nettle"
1798 "mesa"
1799 "wayland"
1800 "fontconfig-minimal"
1801 "freetype"
1802 "libx11"
1803 "libxfixes"
1804 "libxscrnsaver"
1805 "libxinerama"))))
1806 #t)))))
1807 (home-page "https://looking-glass.io/")
1808 (synopsis "KVM Frame Relay (KVMFR) implementation")
1809 (description "Looking Glass allows the use of a KVM (Kernel-based Virtual
fb9472a3 1810Machine) configured for VGA PCI Pass-through without an attached physical
d997fcd3
OP
1811monitor, keyboard or mouse. It displays the VM's rendered contents on your
1812main monitor/GPU.")
1813 ;; This package requires SSE instructions.
1814 (supported-systems '("i686-linux" "x86_64-linux"))
1815 (license license:gpl2+)))
de7f03ce
SB
1816
1817(define-public runc
1818 (package
1819 (name "runc")
0cee62d4 1820 (version "1.1.1")
de7f03ce
SB
1821 (source (origin
1822 (method url-fetch)
1823 (uri (string-append
1824 "https://github.com/opencontainers/runc/releases/"
1825 "download/v" version "/runc.tar.xz"))
ce4593ec 1826 (file-name (string-append name "-" version ".tar.xz"))
de7f03ce
SB
1827 (sha256
1828 (base32
0cee62d4 1829 "0jx56x49dgkygdbrfb3pmxycy1n37arj97jra8n422dj36xz1hbm"))))
de7f03ce
SB
1830 (build-system go-build-system)
1831 (arguments
1832 '(#:import-path "github.com/opencontainers/runc"
1833 #:install-source? #f
03e45891
SB
1834 ;; XXX: 20/139 tests fail due to missing /var, cgroups and apparmor in
1835 ;; the build environment.
1836 #:tests? #f
de7f03ce
SB
1837 #:phases
1838 (modify-phases %standard-phases
de7f03ce
SB
1839 (replace 'build
1840 (lambda* (#:key import-path #:allow-other-keys)
e39e8d97 1841 (with-directory-excursion (string-append "src/" import-path)
86c39376
MC
1842 (invoke "make" "all" "man"))))
1843 (replace 'check
1844 (lambda* (#:key tests? #:allow-other-keys)
1845 (when tests?
1846 (invoke "make" "localunittest"))))
de7f03ce 1847 (replace 'install
e39e8d97
LC
1848 (lambda* (#:key import-path outputs #:allow-other-keys)
1849 (with-directory-excursion (string-append "src/" import-path)
1850 (let ((out (assoc-ref outputs "out")))
86c39376 1851 (invoke "make" "install" "install-bash" "install-man"
e39e8d97 1852 (string-append "PREFIX=" out)))))))))
de7f03ce 1853 (native-inputs
0cee62d4 1854 (list go-github-com-go-md2man pkg-config))
de7f03ce 1855 (inputs
8394619b 1856 (list libseccomp))
de7f03ce 1857 (synopsis "Open container initiative runtime")
86c39376 1858 (home-page "https://opencontainers.org/")
de7f03ce
SB
1859 (description
1860 "@command{runc} is a command line client for running applications
1861packaged according to the
1862@uref{https://github.com/opencontainers/runtime-spec/blob/master/spec.md, Open
1863Container Initiative (OCI) format} and is a compliant implementation of the
1864Open Container Initiative specification.")
b23b9667 1865 (license license:asl2.0)))
efdaf8de
SB
1866
1867(define-public umoci
1868 (package
1869 (name "umoci")
41d0b233 1870 (version "0.4.7")
3468737c
TGR
1871 (source
1872 (origin
1873 (method url-fetch)
1874 (uri (string-append
1875 "https://github.com/opencontainers/umoci/releases/download/v"
1876 version "/umoci.tar.xz"))
1877 (file-name (string-append "umoci-" version ".tar.xz"))
1878 (sha256
41d0b233 1879 (base32 "0fvljj9k4f83wbqzd8nbijz0p1zaq633f8yxyvl5sy3wjf03ffk9"))))
efdaf8de
SB
1880 (build-system go-build-system)
1881 (arguments
3468737c 1882 '(#:import-path "github.com/opencontainers/umoci"
efdaf8de
SB
1883 #:install-source? #f
1884 #:phases
1885 (modify-phases %standard-phases
1886 (replace 'unpack
1887 (lambda* (#:key source import-path #:allow-other-keys)
1888 ;; Unpack the tarball into 'umoci' instead of "runc-${version}".
1889 (let ((dest (string-append "src/" import-path)))
1890 (mkdir-p dest)
1891 (invoke "tar" "-C" (string-append "src/" import-path)
1892 "--strip-components=1"
1893 "-xvf" source))))
1894 (replace 'build
1895 (lambda* (#:key import-path #:allow-other-keys)
e39e8d97
LC
1896 (with-directory-excursion (string-append "src/" import-path)
1897 ;; TODO: build manpages with 'go-md2man'.
1898 (invoke "make" "SHELL=bash"))))
efdaf8de 1899 (replace 'install
e39e8d97 1900 (lambda* (#:key import-path outputs #:allow-other-keys)
efdaf8de
SB
1901 (let* ((out (assoc-ref outputs "out"))
1902 (bindir (string-append out "/bin")))
e39e8d97
LC
1903 (install-file (string-append "src/" import-path "/umoci")
1904 bindir)
efdaf8de
SB
1905 #t))))))
1906 (home-page "https://umo.ci/")
1907 (synopsis "Tool for modifying Open Container images")
1908 (description
1909 "@command{umoci} is a tool that allows for high-level modification of an
1910Open Container Initiative (OCI) image layout and its tagged images.")
b23b9667 1911 (license license:asl2.0)))
7714a069
SB
1912
1913(define-public skopeo
1914 (package
1915 (name "skopeo")
13c4a377 1916 (version "1.2.3")
7714a069
SB
1917 (source (origin
1918 (method git-fetch)
1919 (uri (git-reference
e65991a3 1920 (url "https://github.com/containers/skopeo")
7714a069
SB
1921 (commit (string-append "v" version))))
1922 (file-name (git-file-name name version))
1923 (sha256
1924 (base32
13c4a377 1925 "0n22sdif437ddg5ch0ipwim3fg0n6ihc9bfi52qkhy3r1grz04hs"))))
7714a069
SB
1926 (build-system go-build-system)
1927 (native-inputs
8394619b 1928 (list pkg-config go-github-com-go-md2man))
7714a069 1929 (inputs
8394619b
LC
1930 (list btrfs-progs
1931 eudev
1932 libassuan
1933 libselinux
1934 libostree
1935 lvm2
1936 glib
1937 gpgme))
7714a069 1938 (arguments
e65991a3 1939 '(#:import-path "github.com/containers/skopeo"
7714a069 1940 #:install-source? #f
e39e8d97 1941 #:tests? #f ; The tests require Docker
7714a069
SB
1942 #:phases
1943 (modify-phases %standard-phases
1944 (replace 'build
1945 (lambda* (#:key import-path #:allow-other-keys)
e39e8d97 1946 (with-directory-excursion (string-append "src/" import-path)
e39e8d97 1947 (invoke "make" "bin/skopeo"))))
b4578379
JL
1948 (add-after 'build 'build-docs
1949 (lambda* (#:key import-path #:allow-other-keys)
1950 (with-directory-excursion (string-append "src/" import-path)
1951 (invoke "make" "docs"))))
7714a069 1952 (replace 'install
e39e8d97
LC
1953 (lambda* (#:key import-path outputs #:allow-other-keys)
1954 (with-directory-excursion (string-append "src/" import-path)
1955 (let ((out (assoc-ref outputs "out")))
b4578379
JL
1956 (install-file "default-policy.json"
1957 (string-append out "/etc/containers"))
1958 (invoke "make" "install-binary" "install-completions" "install-docs"
e39e8d97 1959 (string-append "PREFIX=" out)))))))))
e65991a3 1960 (home-page "https://github.com/containers/skopeo")
7714a069
SB
1961 (synopsis "Interact with container images and container image registries")
1962 (description
1963 "@command{skopeo} is a command line utility providing various operations
1964with container images and container image registries. It can:
1965@enumerate
1966
1967@item Copy container images between various containers image stores,
1968converting them as necessary.
1969
1970@item Convert a Docker schema 2 or schema 1 container image to an OCI image.
1971
1972@item Inspect a repository on a container registry without needlessly pulling
1973the image.
1974
1975@item Sign and verify container images.
1976
1977@item Delete container images from a remote container registry.
1978
1979@end enumerate")
b23b9667 1980 (license license:asl2.0)))
5e95181b
EF
1981
1982(define-public python-vagrant
1983 (package
1984 (name "python-vagrant")
1985 (version "0.5.15")
1986 (source
1987 (origin
1988 (method url-fetch)
1989 (uri (pypi-uri "python-vagrant" version))
1990 (sha256
1991 (base32
1992 "1ikrh6canhcxg5y7pzmkcnnydikppv7s6sm9prfx90nk0ac8m6mg"))))
1993 (build-system python-build-system)
1994 (arguments
1995 '(#:tests? #f)) ; tests involve running vagrant.
1996 (home-page "https://github.com/todddeluca/python-vagrant")
1997 (synopsis "Python bindings for Vagrant")
1998 (description
1999 "Python-vagrant is a Python module that provides a thin wrapper around the
2000@code{vagrant} command line executable, allowing programmatic control of Vagrant
2001virtual machines.")
2002 (license license:expat)))
f6e55da0
JL
2003
2004(define-public bubblewrap
2005 (package
2006 (name "bubblewrap")
10ff74d3 2007 (version "0.6.1")
f6e55da0
JL
2008 (source (origin
2009 (method url-fetch)
546c9fa6 2010 (uri (string-append "https://github.com/containers/bubblewrap/"
f6e55da0
JL
2011 "releases/download/v" version "/bubblewrap-"
2012 version ".tar.xz"))
2013 (sha256
2014 (base32
10ff74d3 2015 "10ij62jg7p2scwdx0pm141ss7p2gjdkbbymb56y8miib2vfcf2cn"))
904a6567 2016 (patches (search-patches "bubblewrap-fix-locale-in-tests.patch"))))
f6e55da0
JL
2017 (build-system gnu-build-system)
2018 (arguments
2019 `(#:phases
2020 (modify-phases %standard-phases
2021 (add-after 'unpack 'fix-test
2022 (lambda* (#:key outputs #:allow-other-keys)
2023 ;; Tests try to access /var/tmp, which is not possible in our build
2024 ;; environment. Let's give them another directory.
2025 ;; /tmp gets overriden in some tests, so we need another directory.
2026 ;; the only possibility is the output directory.
2027 (let ((tmp-dir (string-append (assoc-ref outputs "out") "/tmp")))
2028 (mkdir-p tmp-dir)
2029 (substitute* "tests/test-run.sh"
2030 (("/var/tmp") tmp-dir)
2031 ;; Tests create a temporary python script, so fix its shebang.
904a6567 2032 (("/usr/bin/env python3") (which "python3"))
2033 ;; Tests call /usr/bin/env, so fix its path.
2034 (("/usr/bin/env") (which "env"))
f6e55da0
JL
2035 ;; Some tests try to access /usr, but that doesn't exist.
2036 ;; Give them /gnu instead.
2037 (("/usr") "/gnu")
2d03201a
MB
2038 (("--ro-bind /bin /bin") "--ro-bind /gnu /bin")
2039 (("--ro-bind /sbin /sbin") "--ro-bind /gnu /sbin")
2040 (("--ro-bind /lib /lib") "--ro-bind /gnu /lib")
f6e55da0
JL
2041 ((" */bin/bash") (which "bash"))
2042 (("/bin/sh") (which "sh"))
904a6567 2043 (("findmnt") (which "findmnt")))
2044 (substitute* "tests/libtest.sh"
2045 (("/var/tmp") tmp-dir)
2046 (("/usr") "/gnu")
2047 (("--ro-bind /bin /bin") "--ro-bind /gnu /bin")
2048 (("--ro-bind /sbin /sbin") "--ro-bind /gnu /sbin")
2049 (("--ro-bind /lib /lib") "--ro-bind /gnu /lib")))
f6e55da0
JL
2050 #t))
2051 ;; Remove the directory we gave to tests to have a clean package.
2052 (add-after 'check 'remove-tmp-dir
2053 (lambda* (#:key outputs #:allow-other-keys)
2054 (delete-file-recursively (string-append (assoc-ref outputs "out") "/tmp"))
2055 #t)))))
904a6567 2056 (inputs (list libcap))
2057 (native-inputs (list python-wrapper util-linux))
546c9fa6 2058 (home-page "https://github.com/containers/bubblewrap")
f6e55da0
JL
2059 (synopsis "Unprivileged sandboxing tool")
2060 (description "Bubblewrap is aimed at running applications in a sandbox,
7ecd1761
TGR
2061restricting their access to parts of the operating system or user data such as
2062the home directory. Bubblewrap always creates a new mount namespace, and the
2063user can specify exactly what parts of the file system should be made visible
ef1f1ca7 2064in the sandbox. These directories are mounted with the @code{nodev} option
7ecd1761 2065by default and can be made read-only.")
f6e55da0 2066 (license license:lgpl2.0+)))
17043677 2067
2068(define-public bochs
2069 (package
2070 (name "bochs")
321d1bab 2071 (version "2.7")
17043677 2072 (source
2073 (origin
2074 (method url-fetch)
2075 (uri (string-append "https://sourceforge.net/projects/bochs/files/bochs/"
2076 version "/bochs-" version ".tar.gz"))
2077 (sha256
321d1bab 2078 (base32 "0ymiwnfqg5npq2dk9ngidbbfn3qw8z6i491finhcaan7zldsn450"))))
17043677 2079 (build-system gnu-build-system)
2080 (arguments
f17bd3c6 2081 `(#:tests? #f)) ; no tests exist
17043677 2082 (inputs
8394619b 2083 (list libxrandr))
17043677 2084 (home-page "http://bochs.sourceforge.net/")
2085 (synopsis "Emulator for x86 PC")
2086 (description
2087 "Bochs is an emulator which can emulate Intel x86 CPU, common I/O
2088devices, and a custom BIOS. It can also be compiled to emulate many different
2089x86 CPUs, from early 386 to the most recent x86-64 Intel and AMD processors.
2090Bochs can run most Operating Systems inside the emulation including Linux,
2091DOS or Microsoft Windows.")
2092 (license license:lgpl2.0+)))
35e8900d 2093
35e8900d
DM
2094(define-public xen
2095 (package
2096 (name "xen")
76352791 2097 (version "4.14.1") ; please update the mini-os input as well
35e8900d
DM
2098 (source (origin
2099 (method git-fetch)
2100 (uri (git-reference
fa6b5f50 2101 (url "https://xenbits.xen.org/git-http/xen.git")
35e8900d
DM
2102 (commit (string-append "RELEASE-" version))))
2103 (file-name (git-file-name name version))
2104 (sha256
2105 (base32
809b0660 2106 "1r90rvypw76ya9clqw5p02gm1k8hxz73f7gr95ca778nnzvb7xjw"))))
35e8900d
DM
2107 (build-system gnu-build-system)
2108 (arguments
2109 `(#:configure-flags
2110 (list "--enable-rpath"
2111 "--disable-qemu-traditional" ; It tries to do "git clone"
2112 "--disable-rombios" ; would try to "git clone" via etherboot.
35e8900d
DM
2113 ;; TODO: Re-enable stubdom (it's "more secure" to use it).
2114 "--disable-stubdom" ; tries to "git clone" old patched newlib.
2115 (string-append "--with-initddir="
2116 (assoc-ref %outputs "out")
2117 "/etc/init.d")
2118 (string-append "--with-system-qemu="
2119 (assoc-ref %build-inputs "qemu")
2120 "/bin/qemu-system-i386")
2121 (string-append "--with-system-seabios="
2122 (assoc-ref %build-inputs "seabios")
2123 "/share/firmware/bios.bin")
2124 (string-append "--with-system-ovmf="
2125 (assoc-ref %build-inputs "ovmf")
2126 "/share/firmware/ovmf_ia32.bin"))
2127 #:make-flags (list "-j" "1"
2128 "XEN_BUILD_DATE=Thu Jan 1 01:00:01 CET 1970"
2129 "XEN_BUILD_TIME=01:00:01"
2130 "XEN_BUILD_HOST="
2131 "ETHERBOOT_NICS="
2132 "SMBIOS_REL_DATE=01/01/1970"
2133 "VGABIOS_REL_DATE=01 Jan 1970"
2134 ; QEMU_TRADITIONAL_LOC
2135 ; QEMU_UPSTREAM_LOC
2136 "SYSCONFIG_DIR=/tmp/etc/default"
2137 (string-append "BASH_COMPLETION_DIR="
2138 (assoc-ref %outputs "out")
2139 "/etc/bash_completion.d")
2140 (string-append "BOOT_DIR="
2141 (assoc-ref %outputs "out")
2142 "/boot")
2143 (string-append "DEBUG_DIR="
2144 (assoc-ref %outputs "out")
2145 "/lib/debug")
2146 (string-append "EFI_DIR="
2147 (assoc-ref %outputs "out")
2148 "/lib/efi") ; TODO lib64 ?
2149 "MINIOS_UPSTREAM_URL="
2150 ;(string-append "DISTDIR="
2151 ; (assoc-ref %outputs "out"))
2152)
2153 #:test-target "test"
2154 #:phases
2155 (modify-phases %standard-phases
2156 (add-after 'unpack 'unpack-mini-os
2157 (lambda* (#:key inputs #:allow-other-keys)
2158 (copy-recursively (assoc-ref inputs "mini-os") "extras/mini-os")
2159 #t))
2160 (add-after 'unpack-mini-os 'patch
2161 (lambda* (#:key inputs outputs #:allow-other-keys)
2162 (substitute* "tools/firmware/Rules.mk"
2163 (("override XEN_TARGET_ARCH = x86_32")
2164 (string-append "override XEN_TARGET_ARCH = x86_32
2165override CC = " (assoc-ref inputs "cross-gcc") "/bin/i686-linux-gnu-gcc"))
2166 (("^CFLAGS =$")
2167 (string-append "CFLAGS=-I" (assoc-ref inputs "cross-libc")
2168 "/include\n")))
2169 (substitute* "config/x86_32.mk"
2170 (("CFLAGS += -m32 -march=i686")
2171 (string-append "CFLAGS += -march=i686 -I"
2172 (assoc-ref inputs "cross-libc")
2173 "/include")))
35e8900d
DM
2174 ;; /var is not in /gnu/store , so don't try to create it.
2175 (substitute* '("tools/Makefile"
2176 "tools/xenstore/Makefile"
2177 "tools/xenpaging/Makefile")
2178 (("\\$\\(INSTALL_DIR\\) .*XEN_(DUMP|LOG|RUN|LIB|PAGING)_DIR.*")
2179 "\n")
2180 (("\\$\\(INSTALL_DIR\\) .*XEN_(RUN|LIB)_STORED.*")
2181 "\n"))
2182 ;; Prevent xen from creating /etc .
2183 (substitute* "tools/examples/Makefile"
2184 ((" install-readmes") "")
2185 ((" install-configs") ""))
2186 ;; Set rpath.
2187 (substitute* "tools/pygrub/setup.py"
2188 (("library_dirs =")
2189 ; TODO: extra_link_args = ['-Wl,-rpath=/opt/foo'],
2190 (string-append "runtime_library_dirs = ['"
2191 (assoc-ref outputs "out")
2192 "/lib'],\nlibrary_dirs =")))
462f3b06
LC
2193
2194 ;; This needs to be quoted:
2195 ;; <https://lists.gnu.org/archive/html/guix-devel/2022-03/msg00113.html>.
2196 (substitute* "xen/arch/x86/xen.lds.S"
2197 ((".note.gnu.build-id")
2198 "\".note.gnu.build-id\""))))
35e8900d
DM
2199 (add-before 'configure 'patch-xen-script-directory
2200 (lambda* (#:key outputs #:allow-other-keys)
2201 (substitute* '("configure"
2202 "tools/configure"
2203 "docs/configure")
2204 (("XEN_SCRIPT_DIR=.*")
2205 (string-append "XEN_SCRIPT_DIR="
2206 (assoc-ref outputs "out")
2207 "/etc/xen/scripts")))
2208 #t))
2209 (add-before 'configure 'set-environment-up
2210 (lambda* (#:key make-flags #:allow-other-keys)
2211 (define (cross? x)
2212 (string-contains x "cross-i686-linux"))
2213 (define (filter-environment! filter-predicate
2214 environment-variable-names)
2215 (for-each
2216 (lambda (env-name)
2217 (let* ((env-value (getenv env-name))
2218 (search-path (search-path-as-string->list env-value))
2219 (new-search-path (filter filter-predicate
2220 search-path))
2221 (new-env-value (list->search-path-as-string
2222 new-search-path ":")))
2223 (setenv env-name new-env-value)))
2224 environment-variable-names))
1a8a6b7c
TGR
2225 (setenv "CROSS_C_INCLUDE_PATH" (getenv "C_INCLUDE_PATH"))
2226 (setenv "CROSS_CPLUS_INCLUDE_PATH" (getenv "CPLUS_INCLUDE_PATH"))
35e8900d
DM
2227 (setenv "CROSS_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
2228 (filter-environment! cross?
1a8a6b7c 2229 '("CROSS_C_INCLUDE_PATH" "CROSS_CPLUS_INCLUDE_PATH"
35e8900d
DM
2230 "CROSS_LIBRARY_PATH"))
2231 (filter-environment! (lambda (e) (not (cross? e)))
1a8a6b7c 2232 '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"
35e8900d
DM
2233 "LIBRARY_PATH"))
2234 ;; Guix tries to be helpful and automatically adds
2235 ;; mini-os-git-checkout/include to the include path,
2236 ;; but actually we don't want it to be there (yet).
2237 (filter-environment! (lambda (e)
2238 (not
2239 (string-contains e
2240 "mini-os-git-checkout")))
1a8a6b7c 2241 '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"
35e8900d
DM
2242 "LIBRARY_PATH"))
2243 (setenv "EFI_VENDOR" "guix")
2244 #t))
2245 (replace 'build
2246 (lambda* (#:key make-flags #:allow-other-keys)
2247 (apply invoke "make" "world" make-flags))))))
2248 (inputs
2249 `(("acpica" ,acpica) ; TODO: patch iasl invocation.
2250 ("bridge-utils" ,bridge-utils) ; TODO: patch invocations.
2251 ("glib" ,glib)
2252 ("iproute" ,iproute) ; TODO: patch invocations.
2253 ("libaio" ,libaio)
2254 ("libx11" ,libx11)
2255 ("libyajl" ,libyajl)
2256 ("ncurses" ,ncurses)
2257 ("openssl" ,openssl)
2258 ("ovmf" ,ovmf)
2259 ("pixman" ,pixman)
2260 ("qemu" ,qemu-minimal)
2261 ("seabios" ,seabios)
bb93042c 2262 ("util-linux" ,util-linux "lib") ; uuid
35e8900d
DM
2263 ; TODO: ocaml-findlib, ocaml-nox.
2264 ("xz" ,xz) ; for liblzma
2265 ("zlib" ,zlib)))
2266 (native-inputs
2267 `(("dev86" ,dev86)
2268 ("bison" ,bison)
c69959f0 2269 ("cmake" ,cmake-minimal)
35e8900d
DM
2270 ("figlet" ,figlet)
2271 ("flex" ,flex)
2272 ("gettext" ,gettext-minimal)
2273 ("libnl" ,libnl)
2274 ("mini-os"
2275 ,(origin
2276 (method git-fetch)
2277 (uri (git-reference
fa6b5f50 2278 (url "https://xenbits.xen.org/git-http/mini-os.git")
76352791
TGR
2279 ;; This corresponds to (string-append "xen-RELEASE-" version))
2280 ;; at time of packaging, but upstream has unfortunately modified
2281 ;; existing tags in the past.
2282 (commit "0b4b7897e08b967a09bed2028a79fabff82342dd")))
35e8900d 2283 (sha256
76352791 2284 (base32 "1i8pcl19n60i2m9vlg79q3nknpj209c9ic5x10wxaicx45kc107f"))
35e8900d
DM
2285 (file-name "mini-os-git-checkout")))
2286 ("perl" ,perl)
2287 ; TODO: markdown
2288 ("pkg-config" ,pkg-config)
2289 ("python" ,python-2)
2290 ("wget" ,wget)
2291 ("cross-gcc" ,(cross-gcc "i686-linux-gnu"
2292 #:xbinutils (cross-binutils "i686-linux-gnu")
2293 #:libc (cross-libc "i686-linux-gnu")))
2294 ("cross-libc" ,(cross-libc "i686-linux-gnu")) ; header files
2295 ("cross-libc-static" ,(cross-libc "i686-linux-gnu") "static")))
2296 (home-page "https://xenproject.org/")
2297 (synopsis "Xen Virtual Machine Monitor")
2298 (description "This package provides the Xen Virtual Machine Monitor
2299which is a hypervisor.")
2300 ;; TODO: Some files are licensed differently. List those.
2301 (license license:gpl2)
2302 (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux"))))
e9126381
BW
2303
2304(define-public osinfo-db-tools
2305 (package
2306 (name "osinfo-db-tools")
d335c898 2307 (version "1.9.0")
e9126381
BW
2308 (source (origin
2309 (method url-fetch)
2310 (uri (string-append "https://releases.pagure.org/libosinfo/osinfo-db-tools-"
2311 version ".tar.xz"))
2312
2313 (sha256
2314 (base32
d335c898 2315 "1h23a8nzdxjyvw44dwh903563n3b1z5skx8g0b1p1v5cif3iqpr5"))))
e9126381
BW
2316 (build-system meson-build-system)
2317 (inputs
e3196755 2318 (list libsoup-minimal-2 libxml2 libxslt json-glib libarchive))
e9126381 2319 (native-inputs
e3196755
LC
2320 (list perl
2321 gobject-introspection
2322 gettext-minimal
2323 pkg-config
2324 ;; Tests
2325 python
2326 python-pytest
2327 python-requests))
e9126381
BW
2328 (home-page "https://gitlab.com/libosinfo/osinfo-db-tools")
2329 (synopsis "Tools for managing the osinfo database")
2330 (description "This package contains a set of tools to assist
2331administrators and developers in managing the database.")
2332 (license license:lgpl2.0+)))
a838fa28
BW
2333
2334(define-public osinfo-db
2335 (package
2336 (name "osinfo-db")
ff44eff5 2337 (version "20220516")
a838fa28
BW
2338 (source (origin
2339 (method url-fetch)
2340 (uri (string-append "https://releases.pagure.org/libosinfo/osinfo-db-"
2341 version ".tar.xz"))
2342 (sha256
2343 (base32
ff44eff5 2344 "0vfsdk3c6n6y04c5rf92m31zvl969kaniyx2fqywbp69mzc6j3yn"))))
a838fa28
BW
2345 (build-system trivial-build-system)
2346 (arguments
2347 `(#:modules ((guix build utils))
2348 #:builder
2349 (begin
2350 (use-modules (guix build utils))
2351 (let* ((out (assoc-ref %outputs "out"))
2352 (osinfo-dir (string-append out "/share/osinfo"))
2353 (source (assoc-ref %build-inputs "source"))
2354 (osinfo-db-import
2355 (string-append (assoc-ref %build-inputs "osinfo-db-tools")
2356 "/bin/osinfo-db-import")))
2357 (mkdir-p osinfo-dir)
814872d2 2358 (invoke osinfo-db-import "--dir" osinfo-dir source)))))
a838fa28 2359 (native-inputs
8394619b 2360 (list intltool osinfo-db-tools))
a838fa28
BW
2361 (home-page "https://gitlab.com/libosinfo/osinfo-db")
2362 (synopsis "Database of information about operating systems")
2363 (description "Osinfo-db provides the database files for use with the
2364libosinfo library. It provides information about guest operating systems for
2365use with virtualization provisioning tools")
2366 (license license:lgpl2.0+)))
dd8e4411
BG
2367
2368(define-public python-transient
2369 (package
2370 (name "python-transient")
1db54324 2371 (version "0.12")
dd8e4411
BG
2372 (source
2373 (origin
2374 (method url-fetch)
2375 (uri (pypi-uri "transient" version))
2376 (sha256
2377 (base32
1db54324 2378 "148yiqrmcscsi6787y0f27i1y9cf0gcw3mqfv5frhpmsmv62mv5z"))))
dd8e4411
BG
2379 (build-system python-build-system)
2380 (arguments
2381 `(#:tests? #f ; Requires behave
2382 #:phases (modify-phases %standard-phases
2383 (add-after 'unpack 'fix-dependencies
2384 (lambda _
2385 (substitute* "setup.py"
2386 (("==")
2387 ">="))
2388 #t)))))
2389 (propagated-inputs
8394619b
LC
2390 (list python-beautifultable
2391 python-click
2392 python-importlib-resources
2393 python-lark-parser
2394 python-marshmallow
2395 python-progressbar2
2396 python-requests
2397 python-toml))
dd8e4411 2398 (native-inputs
8394619b 2399 (list python-black python-mypy python-pyhamcrest python-twine))
dd8e4411
BG
2400 (home-page
2401 "https://github.com/ALSchwalm/transient")
2402 (synopsis
2403 "QEMU Wrapper written in Python")
2404 (description
2405 "@code{transient} is a wrapper for QEMU allowing the creation of virtual
2406machines with shared folder, ssh, and disk creation support.")
2407 (license license:expat)))
668d52a8
AI
2408
2409(define-public riscv-pk
2410 (package
2411 (name "riscv-pk")
2412 (version "1.0.0")
2413 (source
2414 (origin
2415 (method git-fetch)
2416 (uri (git-reference
2417 (url "https://github.com/riscv-software-src/riscv-pk")
2418 (commit (string-append "v" version))))
2419 (file-name (git-file-name name version))
2420 (sha256
2421 (base32
2422 "1cc0rz4q3a1zw8756b8yysw8lb5g4xbjajh5lvqbjix41hbdx6xz"))))
2423 (build-system gnu-build-system)
2424 (arguments
2425 (list #:out-of-source? #t
2426 ;; riscv-pk can only be built for riscv64.
2427 #:target "riscv64-linux-gnu"
2428 #:make-flags #~(list (string-append "INSTALLDIR=" #$output))
2429 ;; Add flags to keep symbols fromhost and tohost. These symbols are
2430 ;; required for the correct functioning of pk.
2431 #:strip-flags #~(list "--strip-unneeded"
2432 "--keep-symbol=fromhost"
2433 "--keep-symbol=tohost"
2434 "--enable-deterministic-archives")))
2435 (home-page "https://github.com/riscv-software-src/riscv-pk")
2436 (synopsis "RISC-V Proxy Kernel")
2437 (description "The RISC-V Proxy Kernel, @command{pk}, is a lightweight
2438application execution environment that can host statically-linked RISC-V ELF
2439binaries. It is designed to support tethered RISC-V implementations with
2440limited I/O capability and thus handles I/O-related system calls by proxying
2441them to a host computer.
2442
2443This package also contains the Berkeley Boot Loader, @command{bbl}, which is a
2444supervisor execution environment for tethered RISC-V systems. It is designed
2445to host the RISC-V Linux port.")
2446 (license license:bsd-3)))