virtualization.scm 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2015, 2016, 2017, 2018 Mark H Weaver <mhw@netris.org>
  4. ;;; Copyright © 2016, 2017, 2018. 2019 Efraim Flashner <efraim@flashner.co.il>
  5. ;;; Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
  6. ;;; Copyright © 2017 Alex Vong <alexvong1995@gmail.com>
  7. ;;; Copyright © 2017 Andy Patterson <ajpatter@uwaterloo.ca>
  8. ;;; Copyright © 2017, 2018, 2019 Rutger Helling <rhelling@mykolab.com>
  9. ;;; Copyright © 2017, 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
  10. ;;; Copyright © 2018 Danny Milosavljevic <dannym@scratchpost.org>
  11. ;;; Copyright © 2018 Sou Bunnbu <iyzsong@member.fsf.org>
  12. ;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
  13. ;;; Copyright © 2019 Guy Fleury Iteriteka <hoonandon@gmail.com>
  14. ;;;
  15. ;;; This file is part of GNU Guix.
  16. ;;;
  17. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  18. ;;; under the terms of the GNU General Public License as published by
  19. ;;; the Free Software Foundation; either version 3 of the License, or (at
  20. ;;; your option) any later version.
  21. ;;;
  22. ;;; GNU Guix is distributed in the hope that it will be useful, but
  23. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  24. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. ;;; GNU General Public License for more details.
  26. ;;;
  27. ;;; You should have received a copy of the GNU General Public License
  28. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  29. (define-module (gnu packages virtualization)
  30. #:use-module (gnu packages)
  31. #:use-module (gnu packages admin)
  32. #:use-module (gnu packages assembly)
  33. #:use-module (gnu packages attr)
  34. #:use-module (gnu packages autotools)
  35. #:use-module (gnu packages bison)
  36. #:use-module (gnu packages check)
  37. #:use-module (gnu packages cmake)
  38. #:use-module (gnu packages compression)
  39. #:use-module (gnu packages cross-base)
  40. #:use-module (gnu packages curl)
  41. #:use-module (gnu packages cyrus-sasl)
  42. #:use-module (gnu packages disk)
  43. #:use-module (gnu packages dns)
  44. #:use-module (gnu packages docbook)
  45. #:use-module (gnu packages documentation)
  46. #:use-module (gnu packages figlet)
  47. #:use-module (gnu packages firmware)
  48. #:use-module (gnu packages flex)
  49. #:use-module (gnu packages fontutils)
  50. #:use-module (gnu packages freedesktop)
  51. #:use-module (gnu packages gettext)
  52. #:use-module (gnu packages gl)
  53. #:use-module (gnu packages glib)
  54. #:use-module (gnu packages gnome)
  55. #:use-module (gnu packages gnupg)
  56. #:use-module (gnu packages golang)
  57. #:use-module (gnu packages gtk)
  58. #:use-module (gnu packages image)
  59. #:use-module (gnu packages libusb)
  60. #:use-module (gnu packages linux)
  61. #:use-module (gnu packages ncurses)
  62. #:use-module (gnu packages nettle)
  63. #:use-module (gnu packages networking)
  64. #:use-module (gnu packages package-management)
  65. #:use-module (gnu packages perl)
  66. #:use-module (gnu packages pkg-config)
  67. #:use-module (gnu packages polkit)
  68. #:use-module (gnu packages protobuf)
  69. #:use-module (gnu packages python)
  70. #:use-module (gnu packages python-web)
  71. #:use-module (gnu packages python-xyz)
  72. #:use-module (gnu packages pulseaudio)
  73. #:use-module (gnu packages selinux)
  74. #:use-module (gnu packages sdl)
  75. #:use-module (gnu packages spice)
  76. #:use-module (gnu packages texinfo)
  77. #:use-module (gnu packages textutils)
  78. #:use-module (gnu packages tls)
  79. #:use-module (gnu packages web)
  80. #:use-module (gnu packages wget)
  81. #:use-module (gnu packages xdisorg)
  82. #:use-module (gnu packages xml)
  83. #:use-module (gnu packages xorg)
  84. #:use-module (guix build-system cmake)
  85. #:use-module (guix build-system gnu)
  86. #:use-module (guix build-system go)
  87. #:use-module (guix build-system python)
  88. #:use-module (guix download)
  89. #:use-module (guix git-download)
  90. #:use-module ((guix licenses) #:prefix license:)
  91. #:use-module (guix packages)
  92. #:use-module (guix utils)
  93. #:use-module (srfi srfi-1))
  94. (define (qemu-patch commit file-name sha256)
  95. "Return an origin for COMMIT."
  96. (origin
  97. (method url-fetch)
  98. (uri (string-append
  99. "http://git.qemu.org/?p=qemu.git;a=commitdiff_plain;h="
  100. commit))
  101. (sha256 sha256)
  102. (file-name file-name)))
  103. (define-public qemu
  104. (package
  105. (name "qemu")
  106. (version "3.1.0")
  107. (source (origin
  108. (method url-fetch)
  109. (uri (string-append "https://download.qemu.org/qemu-"
  110. version ".tar.xz"))
  111. (patches (search-patches "qemu-CVE-2018-16872.patch"
  112. "qemu-CVE-2019-6778.patch"))
  113. (sha256
  114. (base32
  115. "1z5bd5nfyjvhfi1s95labc82y4hjdjjkdabw931362ls0zghh1ba"))))
  116. (build-system gnu-build-system)
  117. (arguments
  118. '(;; Running tests in parallel can occasionally lead to failures, like:
  119. ;; boot_sector_test: assertion failed (signature == SIGNATURE): (0x00000000 == 0x0000dead)
  120. #:parallel-tests? #f
  121. #:configure-flags (list "--enable-usb-redir" "--enable-opengl"
  122. (string-append "--smbd="
  123. (assoc-ref %outputs "out")
  124. "/libexec/samba-wrapper")
  125. "--audio-drv-list=alsa,pa,sdl")
  126. #:phases
  127. (modify-phases %standard-phases
  128. (replace 'configure
  129. (lambda* (#:key inputs outputs (configure-flags '())
  130. #:allow-other-keys)
  131. ;; The `configure' script doesn't understand some of the
  132. ;; GNU options. Thus, add a new phase that's compatible.
  133. (let ((out (assoc-ref outputs "out")))
  134. (setenv "SHELL" (which "bash"))
  135. ;; While we're at it, patch for tests.
  136. (substitute* "tests/libqtest.c"
  137. (("/bin/sh") (which "sh")))
  138. ;; The binaries need to be linked against -lrt.
  139. (setenv "LDFLAGS" "-lrt")
  140. (apply invoke
  141. `("./configure"
  142. ,(string-append "--cc=" (which "gcc"))
  143. ;; Some architectures insist on using HOST_CC
  144. ,(string-append "--host-cc=" (which "gcc"))
  145. "--disable-debug-info" ; save build space
  146. "--enable-virtfs" ; just to be sure
  147. ,(string-append "--prefix=" out)
  148. ,(string-append "--sysconfdir=/etc")
  149. ,@configure-flags)))))
  150. (add-after 'install 'install-info
  151. (lambda* (#:key inputs outputs #:allow-other-keys)
  152. ;; Install the Info manual, unless Texinfo is missing.
  153. (when (assoc-ref inputs "texinfo")
  154. (let* ((out (assoc-ref outputs "out"))
  155. (dir (string-append out "/share/info")))
  156. (invoke "make" "info")
  157. (for-each (lambda (info)
  158. (install-file info dir))
  159. (find-files "." "\\.info"))))
  160. #t))
  161. ;; Create a wrapper for Samba. This allows QEMU to use Samba without
  162. ;; pulling it in as an input. Note that you need to explicitly install
  163. ;; Samba in your Guix profile for Samba support.
  164. (add-after 'install-info 'create-samba-wrapper
  165. (lambda* (#:key inputs outputs #:allow-other-keys)
  166. (let* ((out (assoc-ref %outputs "out"))
  167. (libexec (string-append out "/libexec")))
  168. (call-with-output-file "samba-wrapper"
  169. (lambda (port)
  170. (format port "#!/bin/sh
  171. exec smbd $@")))
  172. (chmod "samba-wrapper" #o755)
  173. (install-file "samba-wrapper" libexec))
  174. #t))
  175. (add-before 'check 'make-gtester-verbose
  176. (lambda _
  177. ;; Make GTester verbose to facilitate investigation upon failure.
  178. (setenv "V" "1") #t))
  179. (add-before 'check 'disable-test-qga
  180. (lambda _
  181. (substitute* "tests/Makefile.include"
  182. ;; Comment out the test-qga test, which needs /sys and
  183. ;; fails within the build environment.
  184. (("check-unit-.* tests/test-qga" all)
  185. (string-append "# " all)))
  186. #t)))))
  187. (inputs ; TODO: Add optional inputs.
  188. `(("alsa-lib" ,alsa-lib)
  189. ("attr" ,attr)
  190. ("glib" ,glib)
  191. ("gtk+" ,gtk+)
  192. ("libaio" ,libaio)
  193. ("libattr" ,attr)
  194. ("libcap" ,libcap) ; virtfs support requires libcap & libattr
  195. ("libdrm" ,libdrm)
  196. ("libepoxy" ,libepoxy)
  197. ("libjpeg" ,libjpeg-turbo)
  198. ("libpng" ,libpng)
  199. ("libseccomp" ,libseccomp)
  200. ("libusb" ,libusb) ;USB pass-through support
  201. ("mesa" ,mesa)
  202. ("ncurses" ,ncurses)
  203. ;; ("pciutils" ,pciutils)
  204. ("pixman" ,pixman)
  205. ("pulseaudio" ,pulseaudio)
  206. ("sdl2" ,sdl2)
  207. ("spice" ,spice)
  208. ("usbredir" ,usbredir)
  209. ("util-linux" ,util-linux)
  210. ;; ("vde2" ,vde2)
  211. ("virglrenderer" ,virglrenderer)
  212. ("zlib" ,zlib)))
  213. (native-inputs `(("gettext" ,gettext-minimal)
  214. ("glib:bin" ,glib "bin") ; gtester, etc.
  215. ("perl" ,perl)
  216. ("flex" ,flex)
  217. ("bison" ,bison)
  218. ("pkg-config" ,pkg-config)
  219. ("python-wrapper" ,python-wrapper)
  220. ("texinfo" ,texinfo)))
  221. (home-page "https://www.qemu.org")
  222. (synopsis "Machine emulator and virtualizer")
  223. (description
  224. "QEMU is a generic machine emulator and virtualizer.
  225. When used as a machine emulator, QEMU can run OSes and programs made for one
  226. machine (e.g. an ARM board) on a different machine---e.g., your own PC. By
  227. using dynamic translation, it achieves very good performance.
  228. When used as a virtualizer, QEMU achieves near native performances by
  229. executing the guest code directly on the host CPU. QEMU supports
  230. virtualization when executing under the Xen hypervisor or using
  231. the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86,
  232. server and embedded PowerPC, and S390 guests.")
  233. ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
  234. (license license:gpl2)
  235. ;; Several tests fail on MIPS; see <http://hydra.gnu.org/build/117914>.
  236. (supported-systems (delete "mips64el-linux" %supported-systems))))
  237. (define-public qemu-minimal
  238. ;; QEMU without GUI support.
  239. (package (inherit qemu)
  240. (name "qemu-minimal")
  241. (synopsis "Machine emulator and virtualizer (without GUI)")
  242. (arguments
  243. (substitute-keyword-arguments (package-arguments qemu)
  244. ((#:configure-flags _ '(list))
  245. ;; Restrict to the targets supported by Guix.
  246. ''("--target-list=i386-softmmu,x86_64-softmmu,mips64el-softmmu,arm-softmmu,aarch64-softmmu"))))
  247. ;; Remove dependencies on optional libraries, notably GUI libraries.
  248. (native-inputs (fold alist-delete (package-native-inputs qemu)
  249. '("gettext")))
  250. (inputs (fold alist-delete (package-inputs qemu)
  251. '("libusb" "mesa" "sdl2" "spice" "virglrenderer" "gtk+"
  252. "usbredir" "libdrm" "libepoxy" "pulseaudio")))))
  253. ;; The GRUB test suite fails with later versions of Qemu, so we
  254. ;; keep it at 2.10 for now. See
  255. ;; <https://lists.gnu.org/archive/html/bug-grub/2018-02/msg00004.html>.
  256. ;; This package is hidden since we do not backport updates to it.
  257. (define-public qemu-minimal-2.10
  258. (hidden-package
  259. (package
  260. (inherit qemu-minimal)
  261. (version "2.10.2")
  262. (source (origin
  263. (method url-fetch)
  264. (uri (string-append "https://download.qemu.org/qemu-"
  265. version ".tar.xz"))
  266. (sha256
  267. (base32
  268. "17w21spvaxaidi2am5lpsln8yjpyp2zi3s3gc6nsxj5arlgamzgw"))
  269. (patches
  270. (search-patches "qemu-glibc-2.27.patch"))))
  271. ;; qemu-minimal-2.10 needs Python 2. Remove below once no longer necessary.
  272. (native-inputs `(("python-2" ,python-2)
  273. ,@(fold alist-delete (package-native-inputs qemu)
  274. '("python-wrapper")))))))
  275. (define-public libosinfo
  276. (package
  277. (name "libosinfo")
  278. (version "1.0.0")
  279. (source
  280. (origin
  281. (method url-fetch)
  282. (uri (string-append "https://releases.pagure.org/libosinfo/libosinfo-"
  283. version ".tar.gz"))
  284. (sha256
  285. (base32
  286. "0srrs2m6irqd4f867g8ls6jp2dq3ql0l9d0fh80d55sivvn2bd7p"))))
  287. (build-system gnu-build-system)
  288. (arguments
  289. `(#:configure-flags
  290. (list (string-append "--with-usb-ids-path="
  291. (assoc-ref %build-inputs "usb.ids"))
  292. (string-append "--with-pci-ids-path="
  293. (assoc-ref %build-inputs "pci.ids")))
  294. #:phases
  295. (modify-phases %standard-phases
  296. ;; This odd test fails for unknown reasons.
  297. (add-after 'unpack 'disable-broken-test
  298. (lambda _
  299. (substitute* "test/Makefile.in"
  300. (("test-isodetect\\$\\(EXEEXT\\)") ""))
  301. #t)))))
  302. (inputs
  303. `(("libsoup" ,libsoup)
  304. ("libxml2" ,libxml2)
  305. ("libxslt" ,libxslt)
  306. ("gobject-introspection" ,gobject-introspection)))
  307. (native-inputs
  308. `(("check" ,check)
  309. ("glib" ,glib "bin") ; glib-mkenums, etc.
  310. ("gtk-doc" ,gtk-doc)
  311. ("vala" ,vala)
  312. ("intltool" ,intltool)
  313. ("pkg-config" ,pkg-config)
  314. ("pci.ids"
  315. ,(origin
  316. (method url-fetch)
  317. (uri "https://github.com/pciutils/pciids/raw/ad02084f0bc143e3c15e31a6152a3dfb1d7a3156/pci.ids")
  318. (sha256
  319. (base32
  320. "0kfhpj5rnh24hz2714qhfmxk281vwc2w50sm73ggw5d15af7zfsw"))))
  321. ("usb.ids"
  322. ,(origin
  323. (method url-fetch)
  324. (uri "https://svn.code.sf.net/p/linux-usb/repo/trunk/htdocs/usb.ids?r=2681")
  325. (file-name "usb.ids")
  326. (sha256
  327. (base32
  328. "1m6yhvz5k8aqzxgk7xj3jkk8frl1hbv0h3vgj4wbnvnx79qnvz3r"))))))
  329. (home-page "https://libosinfo.org/")
  330. (synopsis "Operating system information database")
  331. (description "libosinfo is a GObject based library API for managing
  332. information about operating systems, hypervisors and the (virtual) hardware
  333. devices they can support. It includes a database containing device metadata
  334. and provides APIs to match/identify optimal devices for deploying an operating
  335. system on a hypervisor. Via GObject Introspection, the API is available in
  336. all common programming languages. Vala bindings are also provided.")
  337. ;; The library files are released under LGPLv2.1 or later; the source
  338. ;; files in the "tools" directory are released under GPLv2+.
  339. (license (list license:lgpl2.1+ license:gpl2+))))
  340. (define-public lxc
  341. (package
  342. (name "lxc")
  343. (version "3.0.2")
  344. (source (origin
  345. (method url-fetch)
  346. (uri (string-append
  347. "https://linuxcontainers.org/downloads/lxc/lxc-"
  348. version ".tar.gz"))
  349. (sha256
  350. (base32
  351. "0p1gy553cm4mhwxi85fl6qiwz61rjmvysm8c8pd20qh62xxi3dva"))))
  352. (build-system gnu-build-system)
  353. (native-inputs
  354. `(("pkg-config" ,pkg-config)))
  355. (inputs
  356. `(("gnutls" ,gnutls)
  357. ("libcap" ,libcap)
  358. ("libseccomp" ,libseccomp)
  359. ("libselinux" ,libselinux)))
  360. (arguments
  361. '(#:configure-flags
  362. '("--sysconfdir=/etc"
  363. "--localstatedir=/var")
  364. #:phases
  365. (modify-phases %standard-phases
  366. (replace 'install
  367. (lambda* (#:key outputs #:allow-other-keys)
  368. (let* ((out (assoc-ref outputs "out"))
  369. (bashcompdir (string-append out "/etc/bash_completion.d")))
  370. (invoke "make" "install"
  371. (string-append "bashcompdir=" bashcompdir)
  372. ;; Don't install files into /var and /etc.
  373. "LXCPATH=/tmp/var/lib/lxc"
  374. "localstatedir=/tmp/var"
  375. "sysconfdir=/tmp/etc"
  376. "sysconfigdir=/tmp/etc/default")))))))
  377. (synopsis "Linux container tools")
  378. (home-page "https://linuxcontainers.org/")
  379. (description
  380. "LXC is a userspace interface for the Linux kernel containment features.
  381. Through a powerful API and simple tools, it lets Linux users easily create and
  382. manage system or application containers.")
  383. (license license:lgpl2.1+)))
  384. (define-public libvirt
  385. (package
  386. (name "libvirt")
  387. (version "4.10.0")
  388. (source (origin
  389. (method url-fetch)
  390. (uri (string-append "https://libvirt.org/sources/libvirt-"
  391. version ".tar.xz"))
  392. (sha256
  393. (base32
  394. "0v17zzyyb25nn9l18v5244myg7590dp6ppwgi8xysipifc0q77bz"))))
  395. (build-system gnu-build-system)
  396. (arguments
  397. `(;; FAIL: virshtest
  398. ;; FAIL: virfirewalltest
  399. ;; FAIL: virkmodtest
  400. ;; FAIL: virnetsockettest
  401. ;; FAIL: networkxml2firewalltest
  402. ;; FAIL: nwfilterebiptablestest
  403. ;; FAIL: nwfilterxml2firewalltest
  404. ;; Time-out while running commandtest.
  405. #:tests? #f
  406. #:configure-flags
  407. (list "--with-polkit"
  408. "--sysconfdir=/etc"
  409. "--localstatedir=/var")
  410. #:phases
  411. (modify-phases %standard-phases
  412. (add-after 'unpack 'fix-tests
  413. (lambda _
  414. (substitute* '("tests/commandtest.c"
  415. "gnulib/tests/test-posix_spawn1.c"
  416. "gnulib/tests/test-posix_spawn2.c")
  417. (("/bin/sh") (which "sh")))
  418. #t))
  419. (replace 'install
  420. ;; Since the sysconfdir and localstatedir should be /etc and /var
  421. ;; at runtime, we must prevent writing to them at installation
  422. ;; time.
  423. (lambda _
  424. (invoke "make" "install"
  425. "sysconfdir=/tmp/etc"
  426. "localstatedir=/tmp/var")))
  427. (add-after 'install 'wrap-libvirtd
  428. (lambda* (#:key inputs outputs #:allow-other-keys)
  429. (let ((out (assoc-ref outputs "out")))
  430. (wrap-program (string-append out "/sbin/libvirtd")
  431. `("PATH" = (,(string-append (assoc-ref inputs "iproute")
  432. "/sbin")
  433. ,(string-append (assoc-ref inputs "qemu")
  434. "/bin"))))
  435. #t))))))
  436. (inputs
  437. `(("libxml2" ,libxml2)
  438. ("eudev" ,eudev)
  439. ("libpciaccess" ,libpciaccess)
  440. ("gnutls" ,gnutls)
  441. ("dbus" ,dbus)
  442. ("qemu" ,qemu)
  443. ("libpcap" ,libpcap)
  444. ("libnl" ,libnl)
  445. ("libuuid" ,util-linux)
  446. ("lvm2" ,lvm2) ; for libdevmapper
  447. ("curl" ,curl)
  448. ("openssl" ,openssl)
  449. ("cyrus-sasl" ,cyrus-sasl)
  450. ("libyajl" ,libyajl)
  451. ("audit" ,audit)
  452. ("dmidecode" ,dmidecode)
  453. ("dnsmasq" ,dnsmasq)
  454. ("ebtables" ,ebtables)
  455. ("iproute" ,iproute)
  456. ("iptables" ,iptables)))
  457. (native-inputs
  458. `(("xsltproc" ,libxslt)
  459. ("perl" ,perl)
  460. ("pkg-config" ,pkg-config)
  461. ("polkit" ,polkit)
  462. ("python" ,python)))
  463. (home-page "https://libvirt.org")
  464. (synopsis "Simple API for virtualization")
  465. (description "Libvirt is a C toolkit to interact with the virtualization
  466. capabilities of recent versions of Linux. The library aims at providing long
  467. term stable C API initially for the Xen paravirtualization but should be able
  468. to integrate other virtualization mechanisms if needed.")
  469. (license license:lgpl2.1+)))
  470. (define-public libvirt-glib
  471. (package
  472. (name "libvirt-glib")
  473. (version "1.0.0")
  474. (source (origin
  475. (method url-fetch)
  476. (uri (string-append "ftp://libvirt.org/libvirt/glib/"
  477. "libvirt-glib-" version ".tar.gz"))
  478. (sha256
  479. (base32
  480. "0iwa5sdbii52pjpdm5j37f67sdmf0kpcky4liwhy1nf43k85i4fa"))))
  481. (build-system gnu-build-system)
  482. (arguments
  483. `(#:phases
  484. (modify-phases %standard-phases
  485. (add-after 'unpack 'fix-tests
  486. (lambda _
  487. (substitute* "tests/test-events.c"
  488. (("/bin/true") (which "true")))
  489. #t)))))
  490. (inputs
  491. `(("libxml2" ,libxml2)
  492. ("libvirt" ,libvirt)
  493. ("gobject-introspection" ,gobject-introspection)
  494. ("glib" ,glib)
  495. ("openssl" ,openssl)
  496. ("cyrus-sasl" ,cyrus-sasl)
  497. ("lvm2" ,lvm2) ; for libdevmapper
  498. ("libyajl" ,libyajl)))
  499. (native-inputs
  500. `(("pkg-config" ,pkg-config)
  501. ("intltool" ,intltool)
  502. ("glib" ,glib "bin")
  503. ("vala" ,vala)))
  504. (home-page "https://libvirt.org")
  505. (synopsis "GLib wrapper around libvirt")
  506. (description "libvirt-glib wraps the libvirt library to provide a
  507. high-level object-oriented API better suited for glib-based applications, via
  508. three libraries:
  509. @enumerate
  510. @item libvirt-glib - GLib main loop integration & misc helper APIs
  511. @item libvirt-gconfig - GObjects for manipulating libvirt XML documents
  512. @item libvirt-gobject - GObjects for managing libvirt objects
  513. @end enumerate
  514. ")
  515. (license license:lgpl2.1+)))
  516. (define-public python-libvirt
  517. (package
  518. (name "python-libvirt")
  519. (version "4.10.0")
  520. (source (origin
  521. (method url-fetch)
  522. (uri (pypi-uri "libvirt-python" version))
  523. (sha256
  524. (base32
  525. "11fipj9naihgc9afc8bz5hi05xa1shp4qcy170sa18p3sl4zljb9"))))
  526. (build-system python-build-system)
  527. (arguments
  528. `(#:phases
  529. (modify-phases %standard-phases
  530. (add-after 'unpack 'patch-nosetests-path
  531. (lambda* (#:key inputs #:allow-other-keys)
  532. (substitute* "setup.py"
  533. (("\"/usr/bin/nosetests\"")
  534. (string-append "\"" (which "nosetests") "\""))
  535. (("self\\.spawn\\(\\[sys\\.executable, nose\\]\\)")
  536. (format #f "self.spawn([\"~a\", nose])" (which "bash"))))
  537. #t)))))
  538. (inputs
  539. `(("libvirt" ,libvirt)))
  540. (propagated-inputs
  541. `(("python-lxml" ,python-lxml)))
  542. (native-inputs
  543. `(("pkg-config" ,pkg-config)
  544. ("python-nose" ,python-nose)))
  545. (home-page "https://libvirt.org")
  546. (synopsis "Python bindings to libvirt")
  547. (description "This package provides Python bindings to the libvirt
  548. virtualization library.")
  549. (license license:lgpl2.1+)))
  550. (define-public python2-libvirt
  551. (package-with-python2 python-libvirt))
  552. (define-public virt-manager
  553. (package
  554. (name "virt-manager")
  555. (version "2.1.0")
  556. (source (origin
  557. (method url-fetch)
  558. (uri (string-append "https://virt-manager.org/download/sources"
  559. "/virt-manager/virt-manager-"
  560. version ".tar.gz"))
  561. (sha256
  562. (base32
  563. "1m038kyngmxlgz91c7z8g73lb2wy0ajyah871a3g3wb5cnd0dsil"))))
  564. (build-system python-build-system)
  565. (arguments
  566. `(#:use-setuptools? #f ; uses custom distutils 'install' command
  567. ;; Some of the tests seem to require network access to install virtual
  568. ;; machines.
  569. #:tests? #f
  570. #:imported-modules ((guix build glib-or-gtk-build-system)
  571. ,@%python-build-system-modules)
  572. #:modules ((ice-9 match)
  573. (srfi srfi-26)
  574. (guix build python-build-system)
  575. ((guix build glib-or-gtk-build-system) #:prefix glib-or-gtk:)
  576. (guix build utils))
  577. #:phases
  578. (modify-phases %standard-phases
  579. (add-after 'unpack 'fix-setup
  580. (lambda* (#:key outputs #:allow-other-keys)
  581. (substitute* "virtcli/cliconfig.py"
  582. (("/usr") (assoc-ref outputs "out")))
  583. #t))
  584. (add-after 'unpack 'fix-default-uri
  585. (lambda* (#:key inputs #:allow-other-keys)
  586. ;; Xen is not available for now - so only patch qemu.
  587. (substitute* "virtManager/connect.py"
  588. (("/usr(/bin/qemu-system)" _ suffix)
  589. (string-append (assoc-ref inputs "qemu") suffix)))
  590. #t))
  591. (add-before 'wrap 'wrap-with-GI_TYPELIB_PATH
  592. (lambda* (#:key inputs outputs #:allow-other-keys)
  593. (let* ((bin (string-append (assoc-ref outputs "out") "/bin"))
  594. (bin-files (find-files bin ".*"))
  595. (paths (map (match-lambda
  596. ((output . directory)
  597. (let* ((girepodir (string-append
  598. directory
  599. "/lib/girepository-1.0")))
  600. (if (file-exists? girepodir)
  601. girepodir #f))))
  602. inputs)))
  603. (for-each (lambda (file)
  604. (format #t "wrapping ~a\n" file)
  605. (wrap-program file
  606. `("GI_TYPELIB_PATH" ":" prefix
  607. ,(filter identity paths))))
  608. bin-files))
  609. #t))
  610. (add-after 'install 'glib-or-gtk-compile-schemas
  611. (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
  612. (add-after 'install 'glib-or-gtk-wrap
  613. (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap)))))
  614. (inputs
  615. `(("dconf" ,dconf)
  616. ("gtk+" ,gtk+)
  617. ("gtk-vnc" ,gtk-vnc)
  618. ("libvirt" ,libvirt)
  619. ("libvirt-glib" ,libvirt-glib)
  620. ("libosinfo" ,libosinfo)
  621. ("vte" ,vte)
  622. ("gobject-introspection" ,gobject-introspection)
  623. ("python-libvirt" ,python-libvirt)
  624. ("python-requests" ,python-requests)
  625. ("python-ipaddress" ,python-ipaddress)
  626. ("python-pycairo" ,python-pycairo)
  627. ("python-pygobject" ,python-pygobject)
  628. ("python-libxml2" ,python-libxml2)
  629. ("spice-gtk" ,spice-gtk)))
  630. ;; virt-manager searches for qemu-img or kvm-img in the PATH.
  631. (propagated-inputs
  632. `(("qemu" ,qemu)))
  633. (native-inputs
  634. `(("glib" ,glib "bin") ; glib-compile-schemas
  635. ("gtk+" ,gtk+ "bin") ; gtk-update-icon-cache
  636. ("perl" ,perl) ; pod2man
  637. ("intltool" ,intltool)))
  638. (home-page "https://virt-manager.org/")
  639. (synopsis "Manage virtual machines")
  640. (description
  641. "The virt-manager application is a desktop user interface for managing
  642. virtual machines through libvirt. It primarily targets KVM VMs, but also
  643. manages Xen and LXC (Linux containers). It presents a summary view of running
  644. domains, their live performance and resource utilization statistics.")
  645. (license license:gpl2+)))
  646. (define-public criu
  647. (package
  648. (name "criu")
  649. (version "3.11")
  650. (source (origin
  651. (method url-fetch)
  652. (uri (string-append "http://download.openvz.org/criu/criu-"
  653. version ".tar.bz2"))
  654. (sha256
  655. (base32
  656. "03nimyn3wy5mlw30gq7bvlzvvprqjv8f25240yj5arzlld8mhsw8"))))
  657. (build-system gnu-build-system)
  658. (arguments
  659. `(#:test-target "test"
  660. #:tests? #f ; tests require mounting as root
  661. #:make-flags
  662. (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
  663. (string-append "LIBDIR=" (assoc-ref %outputs "out")
  664. "/lib"))
  665. #:phases
  666. (modify-phases %standard-phases
  667. (replace 'configure
  668. (lambda* (#:key inputs #:allow-other-keys)
  669. ;; The includes for libnl are located in a sub-directory.
  670. (setenv "C_INCLUDE_PATH"
  671. (string-append (assoc-ref inputs "libnl")
  672. "/include/libnl3:"
  673. (getenv "C_INCLUDE_PATH")))
  674. ;; Prevent xmlto from failing the install phase.
  675. (substitute* "Documentation/Makefile"
  676. (("XMLTO.*:=.*")
  677. (string-append "XMLTO:="
  678. (assoc-ref inputs "xmlto")
  679. "/bin/xmlto"
  680. " --skip-validation "
  681. " -x "
  682. (assoc-ref inputs "docbook-xsl")
  683. "/xml/xsl/docbook-xsl-"
  684. ,(package-version docbook-xsl)
  685. "/manpages/docbook.xsl"))
  686. (("\\$\\(XMLTO\\);")
  687. (string-append (assoc-ref inputs "xmlto")
  688. "/bin/xmlto;")))
  689. #t))
  690. (add-after 'unpack 'hardcode-variables
  691. (lambda* (#:key inputs #:allow-other-keys)
  692. ;; Hardcode arm version detection
  693. (substitute* "Makefile"
  694. (("ARMV.*:=.*") "ARMV := 7\n"))
  695. ;; We are currently using python-2
  696. (substitute* "crit/Makefile"
  697. (("\\$\\(PYTHON\\)") "python2"))
  698. (substitute* "lib/Makefile"
  699. (("\\$\\(PYTHON\\)")
  700. (string-append (assoc-ref inputs "python")
  701. "/bin/python")))
  702. #t))
  703. (add-before 'build 'fix-symlink
  704. (lambda* (#:key inputs #:allow-other-keys)
  705. ;; The file 'images/google/protobuf/descriptor.proto' points to
  706. ;; /usr/include/..., which obviously does not exist.
  707. (let* ((file "google/protobuf/descriptor.proto")
  708. (target (string-append "images/" file))
  709. (source (string-append (assoc-ref inputs "protobuf")
  710. "/include/" file)))
  711. (delete-file target)
  712. (symlink source target)
  713. #t)))
  714. (add-after 'install 'wrap
  715. (lambda* (#:key inputs outputs #:allow-other-keys)
  716. ;; Make sure 'crit' runs with the correct PYTHONPATH.
  717. (let* ((out (assoc-ref outputs "out"))
  718. (path (string-append out
  719. "/lib/python"
  720. (string-take (string-take-right
  721. (assoc-ref inputs "python") 5) 3)
  722. "/site-packages:"
  723. (getenv "PYTHONPATH"))))
  724. (wrap-program (string-append out "/bin/crit")
  725. `("PYTHONPATH" ":" prefix (,path))))
  726. #t)))))
  727. (inputs
  728. `(("protobuf" ,protobuf)
  729. ("python" ,python-2)
  730. ("python2-protobuf" ,python2-protobuf)
  731. ("python2-ipaddr" ,python2-ipaddr)
  732. ("iproute" ,iproute)
  733. ("libaio" ,libaio)
  734. ("libcap" ,libcap)
  735. ("libnet" ,libnet)
  736. ("libnl" ,libnl)))
  737. (native-inputs
  738. `(("pkg-config" ,pkg-config)
  739. ("perl" ,perl)
  740. ("protobuf-c" ,protobuf-c)
  741. ("asciidoc" ,asciidoc)
  742. ("xmlto" ,xmlto)
  743. ("docbook-xml" ,docbook-xml)
  744. ("docbook-xsl" ,docbook-xsl)))
  745. (home-page "https://criu.org")
  746. (synopsis "Checkpoint and restore in user space")
  747. (description "Using this tool, you can freeze a running application (or
  748. part of it) and checkpoint it to a hard drive as a collection of files. You
  749. can then use the files to restore and run the application from the point it
  750. was frozen at. The distinctive feature of the CRIU project is that it is
  751. mainly implemented in user space.")
  752. ;; The project is licensed under GPLv2; files in the lib/ directory are
  753. ;; LGPLv2.1.
  754. (license (list license:gpl2 license:lgpl2.1))))
  755. (define-public qmpbackup
  756. (package
  757. (name "qmpbackup")
  758. (version "0.2")
  759. (source (origin
  760. (method url-fetch)
  761. (uri (string-append "https://github.com/abbbi/qmpbackup/archive/"
  762. version ".tar.gz"))
  763. (sha256
  764. (base32
  765. "10k9mnb1yrg4gw1rvz4kw4dxc4aajl8gnjrpm3axqkg63qmxj3qn"))
  766. (file-name (string-append name "-" version ".tar.gz"))))
  767. (build-system python-build-system)
  768. (arguments
  769. `(#:python ,python-2))
  770. (home-page "https://github.com/abbbi/qmpbackup")
  771. (synopsis "Backup and restore QEMU machines")
  772. (description "qmpbackup is designed to create and restore full and
  773. incremental backups of running QEMU virtual machines via QMP, the QEMU
  774. Machine Protocol.")
  775. (license license:gpl3+)))
  776. (define-public lookingglass
  777. (let ((commit "41f4166aedeba65892f6db4de4de467aec9a2052"))
  778. (package
  779. (name "lookingglass")
  780. (version (string-append "a12-" (string-take commit 7)))
  781. (source
  782. (origin
  783. (method git-fetch)
  784. (uri (git-reference (url "https://github.com/gnif/LookingGlass")
  785. (commit commit)))
  786. (file-name (git-file-name name version))
  787. (sha256
  788. (base32
  789. "1sjxf4zy7h0zprla3s6dfwsxhmkrwhlhj07svf5bk5ij20bs0dc2"))))
  790. (build-system cmake-build-system)
  791. (inputs `(("fontconfig" ,fontconfig)
  792. ("glu" ,glu)
  793. ("mesa" ,mesa)
  794. ("openssl" ,openssl)
  795. ("sdl2" ,sdl2)
  796. ("sdl2-ttf" ,sdl2-ttf)
  797. ("spice-protocol" ,spice-protocol)
  798. ("wayland" ,wayland)))
  799. (native-inputs `(("libconfig" ,libconfig)
  800. ("nettle" ,nettle)
  801. ("pkg-config" ,pkg-config)))
  802. (arguments
  803. `(#:tests? #f ;; No tests are available.
  804. #:make-flags '("CC=gcc")
  805. #:phases (modify-phases %standard-phases
  806. (add-before 'configure 'chdir-to-client
  807. (lambda* (#:key outputs #:allow-other-keys)
  808. (chdir "client")
  809. #t))
  810. (replace 'install
  811. (lambda* (#:key outputs #:allow-other-keys)
  812. (install-file "looking-glass-client"
  813. (string-append (assoc-ref outputs "out")
  814. "/bin"))
  815. #t))
  816. )))
  817. (home-page "https://looking-glass.hostfission.com")
  818. (synopsis "KVM Frame Relay (KVMFR) implementation")
  819. (description "Looking Glass allows the use of a KVM (Kernel-based Virtual
  820. Machine) configured for VGA PCI Pass-through without an attached physical
  821. monitor, keyboard or mouse. It displays the VM's rendered contents on your main
  822. monitor/GPU.")
  823. ;; This package requires SSE instructions.
  824. (supported-systems '("i686-linux" "x86_64-linux"))
  825. (license license:gpl2+))))
  826. (define-public runc
  827. (package
  828. (name "runc")
  829. (version "1.0.0-rc6")
  830. (source (origin
  831. (method url-fetch)
  832. (uri (string-append
  833. "https://github.com/opencontainers/runc/releases/"
  834. "download/v" version "/runc.tar.xz"))
  835. (file-name (string-append name "-" version ".tar.xz"))
  836. (patches (search-patches "runc-CVE-2019-5736.patch"))
  837. (sha256
  838. (base32
  839. "1c7832dq70slkjh8qp2civ1wxhhdd2hrx84pq7db1mmqc9fdr3cc"))))
  840. (build-system go-build-system)
  841. (arguments
  842. '(#:import-path "github.com/opencontainers/runc"
  843. #:install-source? #f
  844. ;; XXX: 20/139 tests fail due to missing /var, cgroups and apparmor in
  845. ;; the build environment.
  846. #:tests? #f
  847. #:phases
  848. (modify-phases %standard-phases
  849. (replace 'unpack
  850. (lambda* (#:key source import-path #:allow-other-keys)
  851. ;; Unpack the tarball into 'runc' instead of 'runc-1.0.0-rc5'.
  852. (let ((dest (string-append "src/" import-path)))
  853. (mkdir-p dest)
  854. (invoke "tar" "-C" (string-append "src/" import-path)
  855. "--strip-components=1"
  856. "-xvf" source))))
  857. (replace 'build
  858. (lambda* (#:key import-path #:allow-other-keys)
  859. (chdir (string-append "src/" import-path))
  860. ;; XXX: requires 'go-md2man'.
  861. ;; (invoke "make" "man")
  862. (invoke "make")))
  863. ;; (replace 'check
  864. ;; (lambda _
  865. ;; (invoke "make" "localunittest")))
  866. (replace 'install
  867. (lambda* (#:key outputs #:allow-other-keys)
  868. (let ((out (assoc-ref outputs "out")))
  869. (invoke "make" "install" "install-bash"
  870. (string-append "PREFIX=" out))))))))
  871. (native-inputs
  872. `(("pkg-config" ,pkg-config)))
  873. (inputs
  874. `(("libseccomp" ,libseccomp)))
  875. (synopsis "Open container initiative runtime")
  876. (home-page "https://www.opencontainers.org/")
  877. (description
  878. "@command{runc} is a command line client for running applications
  879. packaged according to the
  880. @uref{https://github.com/opencontainers/runtime-spec/blob/master/spec.md, Open
  881. Container Initiative (OCI) format} and is a compliant implementation of the
  882. Open Container Initiative specification.")
  883. (license license:asl2.0)))
  884. (define-public umoci
  885. (package
  886. (name "umoci")
  887. (version "0.4.4")
  888. (source (origin
  889. (method url-fetch)
  890. (uri (string-append
  891. "https://github.com/openSUSE/umoci/releases/download/v"
  892. version "/umoci.tar.xz"))
  893. (file-name (string-append "umoci-" version ".tar.xz"))
  894. (sha256
  895. (base32
  896. "1wchmha5k2f370jfijmx9fqp0cp99zfa9ajmfbq3j24qc8p5k8lk"))))
  897. (build-system go-build-system)
  898. (arguments
  899. '(#:import-path "github.com/openSUSE/umoci"
  900. #:install-source? #f
  901. #:phases
  902. (modify-phases %standard-phases
  903. (replace 'unpack
  904. (lambda* (#:key source import-path #:allow-other-keys)
  905. ;; Unpack the tarball into 'umoci' instead of "runc-${version}".
  906. (let ((dest (string-append "src/" import-path)))
  907. (mkdir-p dest)
  908. (invoke "tar" "-C" (string-append "src/" import-path)
  909. "--strip-components=1"
  910. "-xvf" source))))
  911. (replace 'build
  912. (lambda* (#:key import-path #:allow-other-keys)
  913. (chdir (string-append "src/" import-path))
  914. ;; TODO: build manpages with 'go-md2man'.
  915. (invoke "make" "SHELL=bash")))
  916. (replace 'install
  917. (lambda* (#:key outputs #:allow-other-keys)
  918. (let* ((out (assoc-ref outputs "out"))
  919. (bindir (string-append out "/bin")))
  920. (install-file "umoci" bindir)
  921. #t))))))
  922. (home-page "https://umo.ci/")
  923. (synopsis "Tool for modifying Open Container images")
  924. (description
  925. "@command{umoci} is a tool that allows for high-level modification of an
  926. Open Container Initiative (OCI) image layout and its tagged images.")
  927. (license license:asl2.0)))
  928. (define-public skopeo
  929. (package
  930. (name "skopeo")
  931. (version "0.1.28")
  932. (source (origin
  933. (method git-fetch)
  934. (uri (git-reference
  935. (url "https://github.com/projectatomic/skopeo")
  936. (commit (string-append "v" version))))
  937. (file-name (git-file-name name version))
  938. (sha256
  939. (base32
  940. "068nwrr3nr27alravcq1sxyhdd5jjr24213vdgn1dqva3885gbi0"))))
  941. (build-system go-build-system)
  942. (native-inputs
  943. `(("pkg-config" ,pkg-config)))
  944. (inputs
  945. `(("btrfs-progs" ,btrfs-progs)
  946. ("eudev" ,eudev)
  947. ("libassuan" ,libassuan)
  948. ("libselinux" ,libselinux)
  949. ("libostree" ,libostree)
  950. ("lvm2" ,lvm2)
  951. ("glib" ,glib)
  952. ("gpgme" ,gpgme)))
  953. (arguments
  954. '(#:import-path "github.com/projectatomic/skopeo"
  955. #:install-source? #f
  956. #:phases
  957. (modify-phases %standard-phases
  958. (replace 'build
  959. (lambda* (#:key import-path #:allow-other-keys)
  960. (chdir (string-append "src/" import-path))
  961. ;; TODO: build manpages with 'go-md2man'.
  962. (invoke "make" "binary-local")))
  963. (replace 'install
  964. (lambda* (#:key outputs #:allow-other-keys)
  965. (let ((out (assoc-ref outputs "out")))
  966. (invoke "make" "install-binary" "install-completions"
  967. (string-append "PREFIX=" out))))))))
  968. (home-page "https://github.com/projectatomic/skopeo")
  969. (synopsis "Interact with container images and container image registries")
  970. (description
  971. "@command{skopeo} is a command line utility providing various operations
  972. with container images and container image registries. It can:
  973. @enumerate
  974. @item Copy container images between various containers image stores,
  975. converting them as necessary.
  976. @item Convert a Docker schema 2 or schema 1 container image to an OCI image.
  977. @item Inspect a repository on a container registry without needlessly pulling
  978. the image.
  979. @item Sign and verify container images.
  980. @item Delete container images from a remote container registry.
  981. @end enumerate")
  982. (license license:asl2.0)))
  983. (define-public python-vagrant
  984. (package
  985. (name "python-vagrant")
  986. (version "0.5.15")
  987. (source
  988. (origin
  989. (method url-fetch)
  990. (uri (pypi-uri "python-vagrant" version))
  991. (sha256
  992. (base32
  993. "1ikrh6canhcxg5y7pzmkcnnydikppv7s6sm9prfx90nk0ac8m6mg"))))
  994. (build-system python-build-system)
  995. (arguments
  996. '(#:tests? #f)) ; tests involve running vagrant.
  997. (home-page "https://github.com/todddeluca/python-vagrant")
  998. (synopsis "Python bindings for Vagrant")
  999. (description
  1000. "Python-vagrant is a Python module that provides a thin wrapper around the
  1001. @code{vagrant} command line executable, allowing programmatic control of Vagrant
  1002. virtual machines.")
  1003. (license license:expat)))
  1004. (define-public bubblewrap
  1005. (package
  1006. (name "bubblewrap")
  1007. (version "0.3.1")
  1008. (source (origin
  1009. (method url-fetch)
  1010. (uri (string-append "https://github.com/projectatomic/bubblewrap/"
  1011. "releases/download/v" version "/bubblewrap-"
  1012. version ".tar.xz"))
  1013. (sha256
  1014. (base32
  1015. "1y2bdlxnlr84xcbf31lzirc292c5ak9bd2wvcvh4ppsliih6pjny"))))
  1016. (build-system gnu-build-system)
  1017. (arguments
  1018. `(#:phases
  1019. (modify-phases %standard-phases
  1020. (add-after 'unpack 'fix-test
  1021. (lambda* (#:key outputs #:allow-other-keys)
  1022. ;; Tests try to access /var/tmp, which is not possible in our build
  1023. ;; environment. Let's give them another directory.
  1024. ;; /tmp gets overriden in some tests, so we need another directory.
  1025. ;; the only possibility is the output directory.
  1026. (let ((tmp-dir (string-append (assoc-ref outputs "out") "/tmp")))
  1027. (mkdir-p tmp-dir)
  1028. (substitute* "tests/test-run.sh"
  1029. (("/var/tmp") tmp-dir)
  1030. ;; Tests create a temporary python script, so fix its shebang.
  1031. (("/usr/bin/env python") (which "python"))
  1032. ;; Some tests try to access /usr, but that doesn't exist.
  1033. ;; Give them /gnu instead.
  1034. (("/usr") "/gnu")
  1035. ((" */bin/bash") (which "bash"))
  1036. (("/bin/sh") (which "sh"))
  1037. (("findmnt") (which "findmnt"))))
  1038. #t))
  1039. ;; Remove the directory we gave to tests to have a clean package.
  1040. (add-after 'check 'remove-tmp-dir
  1041. (lambda* (#:key outputs #:allow-other-keys)
  1042. (delete-file-recursively (string-append (assoc-ref outputs "out") "/tmp"))
  1043. #t)))))
  1044. (inputs
  1045. `(("libcap" ,libcap)))
  1046. (native-inputs
  1047. `(("python-2" ,python-2)
  1048. ("util-linux" ,util-linux)))
  1049. (home-page "https://github.com/projectatomic/bubblewrap")
  1050. (synopsis "Unprivileged sandboxing tool")
  1051. (description "Bubblewrap is aimed at running applications in a sandbox,
  1052. where it has restricted access to parts of the operating system or user data
  1053. such as the home directory. Bubblewrap always creates a new mount namespace,
  1054. and the user can specify exactly what parts of the filesystem should be visible
  1055. in the sandbox. Any such directories specified is mounted nodev by default,
  1056. and can be made readonly.")
  1057. (license license:lgpl2.0+)))
  1058. (define-public bochs
  1059. (package
  1060. (name "bochs")
  1061. (version "2.6.9")
  1062. (source
  1063. (origin
  1064. (method url-fetch)
  1065. (uri (string-append "https://sourceforge.net/projects/bochs/files/bochs/"
  1066. version "/bochs-" version ".tar.gz"))
  1067. (sha256
  1068. (base32
  1069. "1379cq4cnfprhw8mgh60i0q9j8fz8d7n3d5fnn2g9fdiv5znfnzf"))))
  1070. (build-system gnu-build-system)
  1071. (arguments
  1072. `(#:tests? #f)) ; No tests exist
  1073. (inputs
  1074. `(("libxrandr" ,libxrandr)))
  1075. (home-page "http://bochs.sourceforge.net/")
  1076. (synopsis "Emulator for x86 PC")
  1077. (description
  1078. "Bochs is an emulator which can emulate Intel x86 CPU, common I/O
  1079. devices, and a custom BIOS. It can also be compiled to emulate many different
  1080. x86 CPUs, from early 386 to the most recent x86-64 Intel and AMD processors.
  1081. Bochs can run most Operating Systems inside the emulation including Linux,
  1082. DOS or Microsoft Windows.")
  1083. (license license:lgpl2.0+)))
  1084. (define-public xen
  1085. (package
  1086. (name "xen")
  1087. (version "4.11.1")
  1088. (source (origin
  1089. (method git-fetch)
  1090. (uri (git-reference
  1091. (url "git://xenbits.xenproject.org/xen.git")
  1092. (commit (string-append "RELEASE-" version))))
  1093. (file-name (git-file-name name version))
  1094. (sha256
  1095. (base32
  1096. "1wv1hyfii14vi9lfjmnv07h2gpm3b7kvh2p55f4yy2b40simksgk"))))
  1097. (build-system gnu-build-system)
  1098. (arguments
  1099. `(#:configure-flags
  1100. (list "--enable-rpath"
  1101. "--disable-qemu-traditional" ; It tries to do "git clone"
  1102. "--disable-rombios" ; would try to "git clone" via etherboot.
  1103. ;; TODO: Re-enable stubdom (it's "more secure" to use it).
  1104. "--disable-stubdom" ; tries to "git clone" old patched newlib.
  1105. (string-append "--with-initddir="
  1106. (assoc-ref %outputs "out")
  1107. "/etc/init.d")
  1108. (string-append "--with-system-qemu="
  1109. (assoc-ref %build-inputs "qemu")
  1110. "/bin/qemu-system-i386")
  1111. (string-append "--with-system-seabios="
  1112. (assoc-ref %build-inputs "seabios")
  1113. "/share/firmware/bios.bin")
  1114. (string-append "--with-system-ovmf="
  1115. (assoc-ref %build-inputs "ovmf")
  1116. "/share/firmware/ovmf_ia32.bin"))
  1117. #:make-flags (list "-j" "1"
  1118. "XEN_BUILD_DATE=Thu Jan 1 01:00:01 CET 1970"
  1119. "XEN_BUILD_TIME=01:00:01"
  1120. "XEN_BUILD_HOST="
  1121. "ETHERBOOT_NICS="
  1122. "SMBIOS_REL_DATE=01/01/1970"
  1123. "VGABIOS_REL_DATE=01 Jan 1970"
  1124. ; QEMU_TRADITIONAL_LOC
  1125. ; QEMU_UPSTREAM_LOC
  1126. "SYSCONFIG_DIR=/tmp/etc/default"
  1127. (string-append "BASH_COMPLETION_DIR="
  1128. (assoc-ref %outputs "out")
  1129. "/etc/bash_completion.d")
  1130. (string-append "BOOT_DIR="
  1131. (assoc-ref %outputs "out")
  1132. "/boot")
  1133. (string-append "DEBUG_DIR="
  1134. (assoc-ref %outputs "out")
  1135. "/lib/debug")
  1136. (string-append "EFI_DIR="
  1137. (assoc-ref %outputs "out")
  1138. "/lib/efi") ; TODO lib64 ?
  1139. "MINIOS_UPSTREAM_URL="
  1140. ;(string-append "DISTDIR="
  1141. ; (assoc-ref %outputs "out"))
  1142. )
  1143. #:test-target "test"
  1144. #:phases
  1145. (modify-phases %standard-phases
  1146. (add-after 'unpack 'unpack-mini-os
  1147. (lambda* (#:key inputs #:allow-other-keys)
  1148. (copy-recursively (assoc-ref inputs "mini-os") "extras/mini-os")
  1149. #t))
  1150. (add-after 'unpack-mini-os 'patch
  1151. (lambda* (#:key inputs outputs #:allow-other-keys)
  1152. (substitute* "tools/firmware/Rules.mk"
  1153. (("override XEN_TARGET_ARCH = x86_32")
  1154. (string-append "override XEN_TARGET_ARCH = x86_32
  1155. override CC = " (assoc-ref inputs "cross-gcc") "/bin/i686-linux-gnu-gcc"))
  1156. (("^CFLAGS =$")
  1157. (string-append "CFLAGS=-I" (assoc-ref inputs "cross-libc")
  1158. "/include\n")))
  1159. (substitute* "config/x86_32.mk"
  1160. (("CFLAGS += -m32 -march=i686")
  1161. (string-append "CFLAGS += -march=i686 -I"
  1162. (assoc-ref inputs "cross-libc")
  1163. "/include")))
  1164. ;; /var is not in /gnu/store , so don't try to create it.
  1165. (substitute* '("tools/Makefile"
  1166. "tools/xenstore/Makefile"
  1167. "tools/xenpaging/Makefile")
  1168. (("\\$\\(INSTALL_DIR\\) .*XEN_(DUMP|LOG|RUN|LIB|PAGING)_DIR.*")
  1169. "\n")
  1170. (("\\$\\(INSTALL_DIR\\) .*XEN_(RUN|LIB)_STORED.*")
  1171. "\n"))
  1172. ;; Prevent xen from creating /etc .
  1173. (substitute* "tools/examples/Makefile"
  1174. ((" install-readmes") "")
  1175. ((" install-configs") ""))
  1176. ;; Set rpath.
  1177. (substitute* "tools/pygrub/setup.py"
  1178. (("library_dirs =")
  1179. ; TODO: extra_link_args = ['-Wl,-rpath=/opt/foo'],
  1180. (string-append "runtime_library_dirs = ['"
  1181. (assoc-ref outputs "out")
  1182. "/lib'],\nlibrary_dirs =")))
  1183. #t))
  1184. (add-before 'configure 'patch-xen-script-directory
  1185. (lambda* (#:key outputs #:allow-other-keys)
  1186. (substitute* '("configure"
  1187. "tools/configure"
  1188. "docs/configure")
  1189. (("XEN_SCRIPT_DIR=.*")
  1190. (string-append "XEN_SCRIPT_DIR="
  1191. (assoc-ref outputs "out")
  1192. "/etc/xen/scripts")))
  1193. #t))
  1194. (add-before 'configure 'set-environment-up
  1195. (lambda* (#:key make-flags #:allow-other-keys)
  1196. (define (cross? x)
  1197. (string-contains x "cross-i686-linux"))
  1198. (define (filter-environment! filter-predicate
  1199. environment-variable-names)
  1200. (for-each
  1201. (lambda (env-name)
  1202. (let* ((env-value (getenv env-name))
  1203. (search-path (search-path-as-string->list env-value))
  1204. (new-search-path (filter filter-predicate
  1205. search-path))
  1206. (new-env-value (list->search-path-as-string
  1207. new-search-path ":")))
  1208. (setenv env-name new-env-value)))
  1209. environment-variable-names))
  1210. (setenv "CROSS_C_INCLUDE_PATH" (getenv "C_INCLUDE_PATH"))
  1211. (setenv "CROSS_CPLUS_INCLUDE_PATH" (getenv "CPLUS_INCLUDE_PATH"))
  1212. (setenv "CROSS_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
  1213. (filter-environment! cross?
  1214. '("CROSS_C_INCLUDE_PATH" "CROSS_CPLUS_INCLUDE_PATH"
  1215. "CROSS_LIBRARY_PATH"))
  1216. (filter-environment! (lambda (e) (not (cross? e)))
  1217. '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"
  1218. "LIBRARY_PATH"))
  1219. ;; Guix tries to be helpful and automatically adds
  1220. ;; mini-os-git-checkout/include to the include path,
  1221. ;; but actually we don't want it to be there (yet).
  1222. (filter-environment! (lambda (e)
  1223. (not
  1224. (string-contains e
  1225. "mini-os-git-checkout")))
  1226. '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"
  1227. "LIBRARY_PATH"))
  1228. (setenv "EFI_VENDOR" "guix")
  1229. #t))
  1230. (replace 'build
  1231. (lambda* (#:key make-flags #:allow-other-keys)
  1232. (apply invoke "make" "world" make-flags))))))
  1233. (inputs
  1234. `(("acpica" ,acpica) ; TODO: patch iasl invocation.
  1235. ("bridge-utils" ,bridge-utils) ; TODO: patch invocations.
  1236. ("glib" ,glib)
  1237. ("iproute" ,iproute) ; TODO: patch invocations.
  1238. ("libaio" ,libaio)
  1239. ("libx11" ,libx11)
  1240. ("libyajl" ,libyajl)
  1241. ("ncurses" ,ncurses)
  1242. ("openssl" ,openssl)
  1243. ("ovmf" ,ovmf)
  1244. ("pixman" ,pixman)
  1245. ("qemu" ,qemu-minimal)
  1246. ("seabios" ,seabios)
  1247. ("util-linux" ,util-linux) ; uuid
  1248. ; TODO: ocaml-findlib, ocaml-nox.
  1249. ("xz" ,xz) ; for liblzma
  1250. ("zlib" ,zlib)))
  1251. (native-inputs
  1252. `(("dev86" ,dev86)
  1253. ("bison" ,bison)
  1254. ("cmake" ,cmake)
  1255. ("figlet" ,figlet)
  1256. ("flex" ,flex)
  1257. ("gettext" ,gettext-minimal)
  1258. ("libnl" ,libnl)
  1259. ("mini-os"
  1260. ,(origin
  1261. (method git-fetch)
  1262. (uri (git-reference
  1263. (url "http://xenbits.xen.org/git-http/mini-os.git")
  1264. (commit (string-append "xen-RELEASE-" version))))
  1265. (sha256
  1266. (base32
  1267. "1i8pcl19n60i2m9vlg79q3nknpj209c9ic5x10wxaicx45kc107f"))
  1268. (file-name "mini-os-git-checkout")))
  1269. ("perl" ,perl)
  1270. ; TODO: markdown
  1271. ("pkg-config" ,pkg-config)
  1272. ("python" ,python-2)
  1273. ("wget" ,wget)
  1274. ("cross-gcc" ,(cross-gcc "i686-linux-gnu"
  1275. #:xbinutils (cross-binutils "i686-linux-gnu")
  1276. #:libc (cross-libc "i686-linux-gnu")))
  1277. ("cross-libc" ,(cross-libc "i686-linux-gnu")) ; header files
  1278. ("cross-libc-static" ,(cross-libc "i686-linux-gnu") "static")))
  1279. (home-page "https://xenproject.org/")
  1280. (synopsis "Xen Virtual Machine Monitor")
  1281. (description "This package provides the Xen Virtual Machine Monitor
  1282. which is a hypervisor.")
  1283. ;; TODO: Some files are licensed differently. List those.
  1284. (license license:gpl2)
  1285. (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux"))))