@@ -1,37 +1,40 @@
{ lib , stdenv , fetchurl , fetchpatch , python3Packages , zlib , pkg-config , glib , buildPackages
, pixman , vde2 , alsa-lib , texinfo , flex
, pixman , vde2 , alsa-lib , flex , pcre2
, bison , lzo , snappy , libaio , libtasn1 , gnutls , nettle , curl , dtc , ninja , meson
, sigtool
, makeWrapper , removeReferencesTo
, attr , libcap , libcap_ng , socat , libslirp
, CoreServices , Cocoa , Hypervisor , rez , setfile , vmnet
, guestAgentSupport ? ( with stdenv . hostPlatform ; isLinux || isNetBSD || isOpenBSD || isSunOS || isWindows ) && ! toolsOnly
, numaSupport ? stdenv . isLinux && ! stdenv . isAarch32 && ! toolsOnly , numactl
, seccompSupport ? stdenv . isLinux && ! toolsOnly , libseccomp
, alsaSupport ? lib . hasSuffix " l i n u x " stdenv . hostPlatform . system && ! nixosTestRunner && ! toolsOnly
, pulseSupport ? ! stdenv . isDarwin && ! nixosTestRunner && ! toolsOnly , libpulseaudio
, pipewireSupport ? ! stdenv . isDarwin && ! nixosTestRunner && ! toolsOnly , pipewire
, sdlSupport ? ! stdenv . isDarwin && ! nixosTestRunner && ! toolsOnly , SDL2 , SDL2_image
, jackSupport ? ! stdenv . isDarwin && ! nixosTestRunner && ! toolsOnly , libjack2
, gtkSupport ? ! stdenv . isDarwin && ! xenSupport && ! nixosTestRunner && ! toolsOnly , gtk3 , gettext , vte , wrapGAppsHook3
, vncSupport ? ! nixosTestRunner && ! toolsOnly , libjpeg , libpng
, smartcardSupport ? ! nixosTestRunner && ! toolsOnly , libcacard
, spiceSupport ? true && ! nixosTestRunner && ! toolsOnly , spice , spice-protocol
, ncursesSupport ? ! nixosTestRunner && ! toolsOnly , ncurses
, guestAgentSupport ? ( with stdenv . hostPlatform ; isLinux || isNetBSD || isOpenBSD || isSunOS || isWindows ) && ! minimal
, numaSupport ? stdenv . isLinux && ! stdenv . isAarch32 && ! minimal , numactl
, seccompSupport ? stdenv . isLinux && ! minimal , libseccomp
, alsaSupport ? lib . hasSuffix " l i n u x " stdenv . hostPlatform . system && ! nixosTestRunner && ! minimal
, pulseSupport ? ! stdenv . isDarwin && ! nixosTestRunner && ! minimal , libpulseaudio
, pipewireSupport ? ! stdenv . isDarwin && ! nixosTestRunner && ! minimal , pipewire
, sdlSupport ? ! stdenv . isDarwin && ! nixosTestRunner && ! minimal , SDL2 , SDL2_image
, jackSupport ? ! stdenv . isDarwin && ! nixosTestRunner && ! minimal , libjack2
, gtkSupport ? ! stdenv . isDarwin && ! xenSupport && ! nixosTestRunner && ! minimal , gtk3 , gettext , vte , wrapGAppsHook3
, vncSupport ? ! nixosTestRunner && ! minimal , libjpeg , libpng
, smartcardSupport ? ! nixosTestRunner && ! minimal , libcacard
, spiceSupport ? true && ! nixosTestRunner && ! minimal , spice , spice-protocol
, ncursesSupport ? ! nixosTestRunner && ! minimal , ncurses
, usbredirSupport ? spiceSupport , usbredir
, xenSupport ? false , xen
, cephSupport ? false , ceph
, glusterfsSupport ? false , glusterfs , libuuid
, openGLSupport ? sdlSupport , mesa , libepoxy , libdrm
, rutabagaSupport ? openGLSupport && ! toolsOnly && lib . meta . availableOn stdenv . hostPlatform rutabaga_gfx , rutabaga_gfx
, rutabagaSupport ? openGLSupport && ! minimal && lib . meta . availableOn stdenv . hostPlatform rutabaga_gfx , rutabaga_gfx
, virglSupport ? openGLSupport , virglrenderer
, libiscsiSupport ? ! toolsOnly , libiscsi
, libiscsiSupport ? ! minimal , libiscsi
, smbdSupport ? false , samba
, tpmSupport ? ! toolsOnly
, uringSupport ? stdenv . isLinux , liburing
, canokeySupport ? ! toolsOnly , canokey-qemu
, capstoneSupport ? ! toolsOnly , capstone
, enableDocs ? true
, tpmSupport ? ! minimal
, uringSupport ? stdenv . isLinux && ! userOnly , liburing
, canokeySupport ? ! minimal , canokey-qemu
, capstoneSupport ? ! minimal , capstone
, pluginsSupport ? ! stdenv . hostPlatform . isStatic
, enableDocs ? ! minimal || toolsOnly
, enableTools ? ! minimal || toolsOnly
, enableBlobs ? ! minimal || toolsOnly
, hostCpuOnly ? false
, hostCpuTargets ? ( if toolsOnly
then [ ]
@@ -41,6 +44,8 @@
else null )
, nixosTestRunner ? false
, toolsOnly ? false
, userOnly ? false
, minimal ? toolsOnly || userOnly
, gitUpdater
, qemu-utils # for tests attribute
}:
@@ -54,7 +59,8 @@ stdenv.mkDerivation (finalAttrs: {
+ lib . optionalString xenSupport " - x e n "
+ lib . optionalString hostCpuOnly " - h o s t - c p u - o n l y "
+ lib . optionalString nixosTestRunner " - f o r - v m - t e s t s "
+ lib . optionalString toolsOnly " - u t i l s " ;
+ lib . optionalString toolsOnly " - u t i l s "
+ lib . optionalString userOnly " - u s e r " ;
version = " 9 . 0 . 2 " ;
src = fetchurl {
@@ -67,17 +73,21 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [
makeWrapper removeReferencesTo
pkg-config flex bison dtc meson ninja
pkg-config flex bison meson ninja
# Don't change this to python3 and python3.pkgs.*, breaks cross-compilation
python3Packages . python python3Packages . sphinx python3Packages . sphinx-rtd-theme
python3Packages . python
]
++ lib . optionals gtkSupport [ wrapGAppsHook3 ]
++ lib . optionals enableDocs [ python3Packages . sphinx python3Packages . sphinx-rtd-theme ]
++ lib . optionals hexagonSupport [ glib ]
++ lib . optionals stdenv . isDarwin [ sigtool ] ;
++ lib . optionals stdenv . isDarwin [ sigtool ]
++ lib . optionals ( ! userOnly ) [ dtc ]
# workaround, remove once this patch lands: https://lore.kernel.org/qemu-devel/20240805104921.4035256-1-hi@alyssa.is/
++ lib . optionals ( hexagonSupport && stdenv . hostPlatform . isStatic ) [ pcre2 ] ;
buildInputs = [ dtc zlib glib pixman
vde2 texinfo lzo snappy libtasn1
buildInputs = [ zlib glib pixman
vde2 lzo snappy libtasn1
gnutls nettle curl libslirp
]
++ lib . optionals ncursesSupport [ ncurses ]
@@ -94,7 +104,8 @@ stdenv.mkDerivation (finalAttrs: {
++ lib . optionals smartcardSupport [ libcacard ]
++ lib . optionals spiceSupport [ spice-protocol spice ]
++ lib . optionals usbredirSupport [ usbredir ]
++ lib . optionals stdenv . isLinux [ libaio libcap_ng libcap attr ]
++ lib . optionals stdenv . isLinux [ libcap_ng libcap attr ]
++ lib . optionals ( stdenv . isLinux && ! userOnly ) [ libaio ]
++ lib . optionals xenSupport [ xen ]
++ lib . optionals cephSupport [ ceph ]
++ lib . optionals glusterfsSupport [ glusterfs libuuid ]
@@ -105,9 +116,11 @@ stdenv.mkDerivation (finalAttrs: {
++ lib . optionals smbdSupport [ samba ]
++ lib . optionals uringSupport [ liburing ]
++ lib . optionals canokeySupport [ canokey-qemu ]
++ lib . optionals capstoneSupport [ capstone ] ;
++ lib . optionals capstoneSupport [ capstone ]
++ lib . optionals ( ! userOnly ) [ dtc ] ;
dontUseMesonConfigure = true ; # meson's configurePhase isn't compatible with qemu build
dontAddStaticConfigureFlags = true ;
outputs = [ " o u t " ] ++ lib . optional guestAgentSupport " g a " ;
# On aarch64-linux we would shoot over the Hydra's 2G output limit.
@@ -158,7 +171,7 @@ stdenv.mkDerivation (finalAttrs: {
configureFlags = [
" - - d i s a b l e - s t r i p " # We'll strip ourselves after separating debug info.
( lib . enableFeature enableDocs " d o c s " )
" - - e n a b l e - t o o l s "
( lib . enableFeature enableTools " t o o l s " )
" - - l o c a l s t a t e d i r = / v a r "
" - - s y s c o n f d i r = / e t c "
" - - c r o s s - p r e f i x = ${ stdenv . cc . targetPrefix } "
@@ -170,7 +183,7 @@ stdenv.mkDerivation (finalAttrs: {
++ lib . optional usbredirSupport " - - e n a b l e - u s b - r e d i r "
++ lib . optional ( hostCpuTargets != null ) " - - t a r g e t - l i s t = ${ lib . concatStringsSep " , " hostCpuTargets } "
++ lib . optionals stdenv . isDarwin [ " - - e n a b l e - c o c o a " " - - e n a b l e - h v f " ]
++ lib . optional stdenv . isLinux " - - e n a b l e - l i n u x - a i o "
++ lib . optional ( stdenv . isLinux && ! userOnly ) " - - e n a b l e - l i n u x - a i o "
++ lib . optional gtkSupport " - - e n a b l e - g t k "
++ lib . optional xenSupport " - - e n a b l e - x e n "
++ lib . optional cephSupport " - - e n a b l e - r b d "
@@ -182,7 +195,11 @@ stdenv.mkDerivation (finalAttrs: {
++ lib . optional smbdSupport " - - s m b d = ${ samba } / b i n / s m b d "
++ lib . optional uringSupport " - - e n a b l e - l i n u x - i o - u r i n g "
++ lib . optional canokeySupport " - - e n a b l e - c a n o k e y "
++ lib . optional capstoneSupport " - - e n a b l e - c a p s t o n e " ;
++ lib . optional capstoneSupport " - - e n a b l e - c a p s t o n e "
++ lib . optional ( ! pluginsSupport ) " - - d i s a b l e - p l u g i n s "
++ lib . optional ( ! enableBlobs ) " - - d i s a b l e - i n s t a l l - b l o b s "
++ lib . optional userOnly " - - d i s a b l e - s y s t e m "
++ lib . optional stdenv . hostPlatform . isStatic " - - s t a t i c " ;
dontWrapGApps = true ;
@@ -206,6 +223,11 @@ stdenv.mkDerivation (finalAttrs: {
f o r f i n $o u t / b i n / q e m u - s y s t e m - * ; d o
w r a p G A p p $f
d o n e
'' + lib . optionalString stdenv . hostPlatform . isStatic ''
# H A C K : O t h e r w i s e t h e r e s u l t w i l l h a v e t h e e n t i r e b u i l d I n p u t s c l o s u r e
# i n j e c t e d b y t h e p k g s S t a t i c s t d e n v
# < h t t p s : / / g i t h u b . c o m / N i x O S / n i x p k g s / i s s u e s / 8 3 6 6 7 >
r m - f $o u t / n i x - s u p p o r t / p r o p a g a t e d - b u i l d - i n p u t s
'' ;
preBuild = " c d b u i l d " ;
@@ -249,7 +271,7 @@ stdenv.mkDerivation (finalAttrs: {
'' ;
# Add a ‘ qemu-kvm’ wrapper for compatibility/convenience.
postInstall = lib . optionalString ( ! toolsOnly ) ''
postInstall = lib . optionalString ( ! minimal ) ''
l n - s $o u t / b i n / q e m u - s y s t e m - ${ stdenv . hostPlatform . qemuArch } $o u t / b i n / q e m u - k v m
'' ;
@@ -278,7 +300,13 @@ stdenv.mkDerivation (finalAttrs: {
platforms = platforms . unix ;
}
# toolsOnly: Does not have qemu-kvm and there's no main support tool
// lib . optionalAttrs ( ! toolsOnly ) {
# userOnly: There's one qemu-<arch> for every architecture
// lib . optionalAttrs ( ! toolsOnly && ! userOnly ) {
mainProgram = " q e m u - k v m " ;
}
# userOnly: https://qemu.readthedocs.io/en/v9.0.2/user/main.html
// lib . optionalAttrs userOnly {
platforms = with platforms ; ( linux ++ freebsd ++ openbsd ++ netbsd ) ;
description = " Q E M U U s e r s p a c e e m u l a t o r - l a u n c h e x e c u t a b l e s c o m p i l e d f o r o n e C P U o n a n o t h e r C P U " ;
} ;
} )