summaryrefslogtreecommitdiff
path: root/gnu/packages/virtualization.scm
diff options
context:
space:
mode:
authorEfraim Flashner <efraim@flashner.co.il>2026-03-04 17:44:22 +0200
committerEfraim Flashner <efraim@flashner.co.il>2026-03-30 10:36:19 +0300
commit7095f1b42e5e4951a10c7a62caeb9d5578385a48 (patch)
tree791e0cd9ed2a38cafd04b29b0dc0506b5accb45d /gnu/packages/virtualization.scm
parent3691bb640d33150d2ff3f8194e6f157325a8d5e4 (diff)
gnu: qemu: Prepare to build with rust.
* gnu/packages/virtualization.scm (qemu)[source]: Adjust snippet to remove bundled rust crates. [arguments]: Adjust configure-flags to build with rust when rust is in the build environment. Add a phase when rust is available to make the build system use the packaged rust crates. [native-inputs]: When building with rust add rust, rust-bindgen-cli, cargo-inputs qemu, and the cross-compiler for rust when needed. * gnu/packages/rust-crates.scm (qemu): New entry. Change-Id: Ib2f6fbd870740a674f6424e1e2800ca5dfa40aa7 Signed-off-by: John Kehayias <john@guixotic.coop>
Diffstat (limited to 'gnu/packages/virtualization.scm')
-rw-r--r--gnu/packages/virtualization.scm117
1 files changed, 81 insertions, 36 deletions
diff --git a/gnu/packages/virtualization.scm b/gnu/packages/virtualization.scm
index 270565bb8ea..858a3fe92db 100644
--- a/gnu/packages/virtualization.scm
+++ b/gnu/packages/virtualization.scm
@@ -161,6 +161,8 @@
161 #:use-module (gnu packages ruby) 161 #:use-module (gnu packages ruby)
162 #:use-module (gnu packages ruby-check) 162 #:use-module (gnu packages ruby-check)
163 #:use-module (gnu packages ruby-xyz) 163 #:use-module (gnu packages ruby-xyz)
164 #:use-module (gnu packages rust)
165 #:use-module (gnu packages rust-apps)
164 #:use-module (gnu packages rsync) 166 #:use-module (gnu packages rsync)
165 #:use-module (gnu packages sdl) 167 #:use-module (gnu packages sdl)
166 #:use-module (gnu packages selinux) 168 #:use-module (gnu packages selinux)
@@ -217,6 +219,9 @@
217 (modules '((guix build utils))) 219 (modules '((guix build utils)))
218 (snippet 220 (snippet
219 '(begin 221 '(begin
222 ;; Delete the bundled rust crates.
223 (delete-file-recursively "subprojects/packagecache")
224 (mkdir-p "subprojects/packagecache")
220 ;; TODO: Scrub all firmwares from this directory! 225 ;; TODO: Scrub all firmwares from this directory!
221 (with-directory-excursion "pc-bios" 226 (with-directory-excursion "pc-bios"
222 ;; Delete firmwares provided by SeaBIOS. 227 ;; Delete firmwares provided by SeaBIOS.
@@ -261,28 +266,34 @@
261 "share/qemu/pxe-virtio.rom")) 266 "share/qemu/pxe-virtio.rom"))
262 #~((string-append #$output "/share/qemu")))) 267 #~((string-append #$output "/share/qemu"))))
263 (out #$output)) 268 (out #$output))
264 (list (string-append "--cc=" gcc) 269 (cons* (string-append "--cc=" gcc)
265 ;; Some architectures insist on using HOST_CC. 270 ;; Some architectures insist on using HOST_CC.
266 (string-append "--host-cc=" gcc) 271 (string-append "--host-cc=" gcc)
267 (string-append "--prefix=" out) 272 (string-append "--prefix=" out)
268 "--sysconfdir=/etc" 273 "--sysconfdir=/etc"
269 "--enable-fdt=system" 274 "--enable-fdt=system"
270 (string-append "--firmwarepath=" out "/share/qemu:" 275 (string-append "--firmwarepath=" out "/share/qemu:"
271 (dirname seabios) ":" 276 (dirname seabios) ":"
272 (dirname ipxe) ":" 277 (dirname ipxe) ":"
273 (dirname openbios) ":" 278 (dirname openbios) ":"
274 (dirname opensbi)) 279 (dirname opensbi))
275 (string-append "--smbd=" out "/libexec/samba-wrapper") 280 (string-append "--smbd=" out "/libexec/samba-wrapper")
276 "--disable-debug-info" ;for space considerations 281 "--disable-debug-info" ;for space considerations
277 ;; The binaries need to be linked against -lrt. 282 ;; The binaries need to be linked against -lrt.
278 (string-append "--extra-ldflags=-lrt"))) 283 (string-append "--extra-ldflags=-lrt")
284 #$@(if (this-package-native-input "rust")
285 #~((list "--enable-rust"))
286 #~((list)))))
279 ;; Make build and test output verbose to facilitate investigation upon failure. 287 ;; Make build and test output verbose to facilitate investigation upon failure.
280 #:make-flags #~'("V=1") 288 #:make-flags #~'("V=1")
281 #:modules `((srfi srfi-1) 289 #:modules `((srfi srfi-1)
282 (srfi srfi-26) 290 (srfi srfi-26)
283 (ice-9 ftw) 291 (ice-9 ftw)
284 (ice-9 match) 292 (ice-9 match)
293 ((guix build cargo-build-system) #:prefix cargo:)
285 ,@%default-gnu-modules) 294 ,@%default-gnu-modules)
295 #:imported-modules `(,@%cargo-build-system-modules
296 ,@%default-gnu-imported-modules)
286 #:phases 297 #:phases
287 #~(modify-phases %standard-phases 298 #~(modify-phases %standard-phases
288 ;; Since we removed the bundled firmwares above, many tests 299 ;; Since we removed the bundled firmwares above, many tests
@@ -325,6 +336,29 @@
325 "\"~a\",~%" file)) 336 "\"~a\",~%" file))
326 allowed-differences) 337 allowed-differences)
327 (close-port allowed-differences-whitelist)))) 338 (close-port allowed-differences-whitelist))))
339 #$@(if (this-package-native-input "rust")
340 #~((add-after 'unpack 'prepare-rust-crates
341 (lambda args
342 (apply (assoc-ref cargo:%standard-phases
343 'prepare-rust-crates)
344 args)
345 ;; Use /tmp/rust-crates as the source.
346 (substitute* (find-files "subprojects" "-rs\\.wrap$")
347 (("source_url = (.*)" _ url)
348 (let ((split-url (string-split url #\/)))
349 (string-append
350 "source_url = file:///tmp/rust-crates/rust-"
351 (list-ref split-url 6) "-"
352 (list-ref split-url 7) ".tar.gz\n"))))
353 ;; "Download" the packages.
354 (for-each
355 (lambda (wrapper)
356 (invoke "meson" "subprojects" "download"
357 (string-drop-right wrapper 5)))
358 (scandir "subprojects"
359 (lambda (file)
360 (string-suffix? "-rs.wrap" file)))))))
361 #~())
328 ;; If the ipxe firmware isn't available, remove it from the list 362 ;; If the ipxe firmware isn't available, remove it from the list
329 ;; of files expected to be available and remove some of the tests. 363 ;; of files expected to be available and remove some of the tests.
330 #$@(if (not (this-package-input "ipxe-qemu")) 364 #$@(if (not (this-package-input "ipxe-qemu"))
@@ -587,27 +621,38 @@ exec smbd $@")))
587 zlib 621 zlib
588 `(,zstd "lib")))) 622 `(,zstd "lib"))))
589 (native-inputs 623 (native-inputs
590 ;; Note: acpica is here only to pretty-print firmware differences with IASL 624 (append
591 ;; (see the replace-firmwares phase above). 625 ;; The rust code doesn't seem to be in use yet.
592 (list acpica 626 (if #f ;(supported-package? rust)
593 bison 627 (append
594 flex 628 (cons* rust
595 gettext-minimal 629 rust-bindgen-cli
596 `(,glib "bin") ;gtester, etc. 630 (cargo-inputs 'qemu))
597 meson 631 (or (and=> (%current-target-system)
598 ninja 632 (compose list make-rust-sysroot))
599 perl 633 '()))
600 pkg-config 634 '())
601 python-wrapper 635 ;; Note: acpica is here only to pretty-print firmware differences with
602 python-sphinx 636 ;; IASL (see the replace-firmwares phase above).
603 python-sphinx-rtd-theme 637 (list acpica
604 python-tomli 638 bison
605 texinfo 639 flex
606 ;; The following static libraries are required to build 640 gettext-minimal
607 ;; the static output of QEMU. 641 `(,glib "bin") ;gtester, etc.
608 `(,glib "static") 642 meson
609 `(,pcre2 "static") 643 ninja
610 `(,zlib "static"))) 644 perl
645 pkg-config
646 python-wrapper
647 python-sphinx
648 python-sphinx-rtd-theme
649 python-tomli
650 texinfo
651 ;; The following static libraries are required to build
652 ;; the static output of QEMU.
653 `(,glib "static")
654 `(,pcre2 "static")
655 `(,zlib "static"))))
611 (home-page "https://www.qemu.org") 656 (home-page "https://www.qemu.org")
612 (synopsis "Machine emulator and virtualizer") 657 (synopsis "Machine emulator and virtualizer")
613 (description 658 (description