2024-08-31 11:08:55 +01:00
|
|
|
|
{ lib, stdenv, fetchurl, fetchpatch, python3Packages, zlib, pkg-config, glib, overrideSDK, buildPackages
|
2024-08-03 14:32:46 +01:00
|
|
|
|
, pixman, vde2, alsa-lib, flex, pcre2
|
2023-11-15 13:30:28 +00:00
|
|
|
|
, bison, lzo, snappy, libaio, libtasn1, gnutls, nettle, curl, dtc, ninja, meson
|
|
|
|
|
, sigtool
|
2023-09-06 17:37:33 +01:00
|
|
|
|
, makeWrapper, removeReferencesTo
|
2022-12-14 20:20:33 +00:00
|
|
|
|
, attr, libcap, libcap_ng, socat, libslirp
|
2024-08-31 11:08:55 +01:00
|
|
|
|
, CoreServices, Cocoa, Hypervisor, Kernel, rez, setfile, vmnet
|
2024-08-04 12:25:46 +01:00
|
|
|
|
, guestAgentSupport ? (with stdenv.hostPlatform; isLinux || isNetBSD || isOpenBSD || isSunOS || isWindows) && !minimal
|
|
|
|
|
, numaSupport ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAarch32 && !minimal, numactl
|
|
|
|
|
, seccompSupport ? stdenv.hostPlatform.isLinux && !minimal, libseccomp
|
|
|
|
|
, alsaSupport ? lib.hasSuffix "linux" stdenv.hostPlatform.system && !nixosTestRunner && !minimal
|
|
|
|
|
, pulseSupport ? !stdenv.hostPlatform.isDarwin && !nixosTestRunner && !minimal, libpulseaudio
|
|
|
|
|
, pipewireSupport ? !stdenv.hostPlatform.isDarwin && !nixosTestRunner && !minimal, pipewire
|
|
|
|
|
, sdlSupport ? !stdenv.hostPlatform.isDarwin && !nixosTestRunner && !minimal, SDL2, SDL2_image
|
|
|
|
|
, jackSupport ? !stdenv.hostPlatform.isDarwin && !nixosTestRunner && !minimal, libjack2
|
|
|
|
|
, gtkSupport ? !stdenv.hostPlatform.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
|
2016-09-05 19:37:03 +01:00
|
|
|
|
, usbredirSupport ? spiceSupport, usbredir
|
2016-11-02 16:06:48 +00:00
|
|
|
|
, xenSupport ? false, xen
|
2019-02-06 18:53:23 +00:00
|
|
|
|
, cephSupport ? false, ceph
|
2021-05-05 21:05:21 +01:00
|
|
|
|
, glusterfsSupport ? false, glusterfs, libuuid
|
2021-11-11 04:35:34 +00:00
|
|
|
|
, openGLSupport ? sdlSupport, mesa, libepoxy, libdrm
|
2024-08-04 12:25:46 +01:00
|
|
|
|
, rutabagaSupport ? openGLSupport && !minimal && lib.meta.availableOn stdenv.hostPlatform rutabaga_gfx, rutabaga_gfx
|
2018-03-25 22:33:23 +01:00
|
|
|
|
, virglSupport ? openGLSupport, virglrenderer
|
2024-08-04 12:25:46 +01:00
|
|
|
|
, libiscsiSupport ? !minimal, libiscsi
|
2018-06-10 23:18:31 +01:00
|
|
|
|
, smbdSupport ? false, samba
|
2024-08-04 12:25:46 +01:00
|
|
|
|
, tpmSupport ? !minimal
|
|
|
|
|
, uringSupport ? stdenv.hostPlatform.isLinux && !userOnly, liburing
|
|
|
|
|
, canokeySupport ? !minimal, canokey-qemu
|
|
|
|
|
, capstoneSupport ? !minimal, capstone
|
2023-05-27 18:11:48 +01:00
|
|
|
|
, pluginsSupport ? !stdenv.hostPlatform.isStatic
|
2024-08-04 12:25:46 +01:00
|
|
|
|
, enableDocs ? !minimal || toolsOnly
|
|
|
|
|
, enableTools ? !minimal || toolsOnly
|
|
|
|
|
, enableBlobs ? !minimal || toolsOnly
|
2017-11-24 12:34:04 +00:00
|
|
|
|
, hostCpuOnly ? false
|
2023-10-21 17:42:57 +01:00
|
|
|
|
, hostCpuTargets ? (if toolsOnly
|
|
|
|
|
then [ ]
|
2024-10-06 16:19:14 +01:00
|
|
|
|
else if xenSupport
|
|
|
|
|
then [ "i386-softmmu" ]
|
2023-10-21 17:42:57 +01:00
|
|
|
|
else if hostCpuOnly
|
2021-01-11 07:54:33 +00:00
|
|
|
|
then (lib.optional stdenv.hostPlatform.isx86_64 "i386-softmmu"
|
2018-11-13 22:54:08 +00:00
|
|
|
|
++ ["${stdenv.hostPlatform.qemuArch}-softmmu"])
|
|
|
|
|
else null)
|
2016-11-17 16:06:17 +00:00
|
|
|
|
, nixosTestRunner ? false
|
2023-10-21 17:42:57 +01:00
|
|
|
|
, toolsOnly ? false
|
2024-08-04 12:25:46 +01:00
|
|
|
|
, userOnly ? false
|
|
|
|
|
, minimal ? toolsOnly || userOnly
|
2023-08-12 07:46:48 +01:00
|
|
|
|
, gitUpdater
|
2023-10-21 22:54:54 +01:00
|
|
|
|
, qemu-utils # for tests attribute
|
2013-07-04 16:44:44 +01:00
|
|
|
|
}:
|
2013-02-08 01:44:02 +00:00
|
|
|
|
|
2024-10-06 16:19:14 +01:00
|
|
|
|
assert lib.assertMsg (xenSupport -> hostCpuTargets == [ "i386-softmmu" ]) "Xen should not use any other QEMU architecture other than i386.";
|
|
|
|
|
|
2023-03-16 21:18:56 +00:00
|
|
|
|
let
|
|
|
|
|
hexagonSupport = hostCpuTargets == null || lib.elem "hexagon" hostCpuTargets;
|
2024-08-31 11:08:55 +01:00
|
|
|
|
|
|
|
|
|
buildPlatformStdenv =
|
|
|
|
|
if stdenv.buildPlatform.isDarwin then
|
|
|
|
|
overrideSDK buildPackages.stdenv {
|
|
|
|
|
# Keep these values in sync with `all-packages.nix`.
|
|
|
|
|
darwinSdkVersion = "12.3";
|
|
|
|
|
darwinMinVersion = "12.0";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
buildPackages.stdenv;
|
2023-03-16 21:18:56 +00:00
|
|
|
|
in
|
|
|
|
|
|
2023-08-24 08:48:17 +01:00
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2019-11-05 15:20:59 +00:00
|
|
|
|
pname = "qemu"
|
2021-01-15 05:42:41 +00:00
|
|
|
|
+ lib.optionalString xenSupport "-xen"
|
|
|
|
|
+ lib.optionalString hostCpuOnly "-host-cpu-only"
|
2023-10-21 17:42:57 +01:00
|
|
|
|
+ lib.optionalString nixosTestRunner "-for-vm-tests"
|
2024-08-04 12:25:46 +01:00
|
|
|
|
+ lib.optionalString toolsOnly "-utils"
|
|
|
|
|
+ lib.optionalString userOnly "-user";
|
2024-10-22 06:31:39 +01:00
|
|
|
|
version = "9.1.1";
|
2013-02-08 01:44:02 +00:00
|
|
|
|
|
|
|
|
|
src = fetchurl {
|
2023-08-24 08:48:17 +01:00
|
|
|
|
url = "https://download.qemu.org/qemu-${finalAttrs.version}.tar.xz";
|
2024-10-22 06:31:39 +01:00
|
|
|
|
hash = "sha256-fcD52lSR/0SVAPMxAGOja2GfI27kVwb9CEbrN9S7qIk=";
|
2013-02-08 01:44:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-08-31 11:08:55 +01:00
|
|
|
|
depsBuildBuild = [ buildPlatformStdenv.cc ]
|
2023-03-16 21:18:56 +00:00
|
|
|
|
++ lib.optionals hexagonSupport [ pkg-config ];
|
2021-11-28 09:40:29 +00:00
|
|
|
|
|
2023-02-09 13:18:40 +00:00
|
|
|
|
nativeBuildInputs = [
|
|
|
|
|
makeWrapper removeReferencesTo
|
2024-08-03 14:31:23 +01:00
|
|
|
|
pkg-config flex bison meson ninja
|
2023-02-09 13:18:40 +00:00
|
|
|
|
|
|
|
|
|
# Don't change this to python3 and python3.pkgs.*, breaks cross-compilation
|
2023-05-27 18:11:48 +01:00
|
|
|
|
python3Packages.python
|
2023-02-09 13:18:40 +00:00
|
|
|
|
]
|
2024-04-26 21:24:03 +01:00
|
|
|
|
++ lib.optionals gtkSupport [ wrapGAppsHook3 ]
|
2023-05-27 18:11:48 +01:00
|
|
|
|
++ lib.optionals enableDocs [ python3Packages.sphinx python3Packages.sphinx-rtd-theme ]
|
2023-03-16 21:18:56 +00:00
|
|
|
|
++ lib.optionals hexagonSupport [ glib ]
|
2024-08-03 14:31:23 +01:00
|
|
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [ sigtool ]
|
2024-08-31 11:08:55 +01:00
|
|
|
|
++ lib.optionals (!userOnly) [ dtc ];
|
2021-08-04 19:54:48 +01:00
|
|
|
|
|
2024-08-16 00:57:41 +01:00
|
|
|
|
buildInputs = [ glib zlib ]
|
|
|
|
|
++ lib.optionals (!minimal) [ dtc pixman vde2 lzo snappy libtasn1 gnutls nettle libslirp ]
|
|
|
|
|
++ lib.optionals (!userOnly) [ curl ]
|
2021-08-04 19:54:48 +01:00
|
|
|
|
++ lib.optionals ncursesSupport [ ncurses ]
|
2024-08-31 11:08:55 +01:00
|
|
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [ CoreServices Cocoa Hypervisor Kernel rez setfile vmnet ]
|
2021-08-04 19:54:48 +01:00
|
|
|
|
++ lib.optionals seccompSupport [ libseccomp ]
|
|
|
|
|
++ lib.optionals numaSupport [ numactl ]
|
2021-11-18 13:16:09 +00:00
|
|
|
|
++ lib.optionals alsaSupport [ alsa-lib ]
|
2021-08-04 19:54:48 +01:00
|
|
|
|
++ lib.optionals pulseSupport [ libpulseaudio ]
|
2023-09-06 17:37:33 +01:00
|
|
|
|
++ lib.optionals pipewireSupport [ pipewire ]
|
2021-08-04 19:54:48 +01:00
|
|
|
|
++ lib.optionals sdlSupport [ SDL2 SDL2_image ]
|
2021-12-18 20:42:57 +00:00
|
|
|
|
++ lib.optionals jackSupport [ libjack2 ]
|
2021-08-04 19:54:48 +01:00
|
|
|
|
++ lib.optionals gtkSupport [ gtk3 gettext vte ]
|
|
|
|
|
++ lib.optionals vncSupport [ libjpeg libpng ]
|
|
|
|
|
++ lib.optionals smartcardSupport [ libcacard ]
|
|
|
|
|
++ lib.optionals spiceSupport [ spice-protocol spice ]
|
|
|
|
|
++ lib.optionals usbredirSupport [ usbredir ]
|
2024-08-16 00:57:41 +01:00
|
|
|
|
++ lib.optionals (stdenv.hostPlatform.isLinux && !userOnly) [ libcap_ng libcap attr libaio ]
|
2021-08-04 19:54:48 +01:00
|
|
|
|
++ lib.optionals xenSupport [ xen ]
|
|
|
|
|
++ lib.optionals cephSupport [ ceph ]
|
|
|
|
|
++ lib.optionals glusterfsSupport [ glusterfs libuuid ]
|
2021-11-11 04:35:34 +00:00
|
|
|
|
++ lib.optionals openGLSupport [ mesa libepoxy libdrm ]
|
2024-01-06 17:43:14 +00:00
|
|
|
|
++ lib.optionals rutabagaSupport [ rutabaga_gfx ]
|
2021-08-04 19:54:48 +01:00
|
|
|
|
++ lib.optionals virglSupport [ virglrenderer ]
|
|
|
|
|
++ lib.optionals libiscsiSupport [ libiscsi ]
|
2021-11-14 22:12:02 +00:00
|
|
|
|
++ lib.optionals smbdSupport [ samba ]
|
2022-10-03 16:44:04 +01:00
|
|
|
|
++ lib.optionals uringSupport [ liburing ]
|
2023-05-17 22:55:04 +01:00
|
|
|
|
++ lib.optionals canokeySupport [ canokey-qemu ]
|
2024-08-16 00:57:41 +01:00
|
|
|
|
++ lib.optionals capstoneSupport [ capstone ];
|
2013-02-08 01:44:02 +00:00
|
|
|
|
|
2020-12-15 18:25:55 +00:00
|
|
|
|
dontUseMesonConfigure = true; # meson's configurePhase isn't compatible with qemu build
|
2024-08-03 14:32:46 +01:00
|
|
|
|
dontAddStaticConfigureFlags = true;
|
2013-02-08 01:44:02 +00:00
|
|
|
|
|
2022-03-22 13:21:21 +00:00
|
|
|
|
outputs = [ "out" ] ++ lib.optional guestAgentSupport "ga";
|
2021-12-26 11:45:05 +00:00
|
|
|
|
# On aarch64-linux we would shoot over the Hydra's 2G output limit.
|
|
|
|
|
separateDebugInfo = !(stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux);
|
2018-04-20 10:05:50 +01:00
|
|
|
|
|
2018-08-10 19:59:53 +01:00
|
|
|
|
patches = [
|
|
|
|
|
./fix-qemu-ga.patch
|
2022-03-22 13:21:21 +00:00
|
|
|
|
|
2022-05-21 10:24:16 +01:00
|
|
|
|
# Workaround for upstream issue with nested virtualisation: https://gitlab.com/qemu-project/qemu/-/issues/1008
|
|
|
|
|
(fetchpatch {
|
|
|
|
|
url = "https://gitlab.com/qemu-project/qemu/-/commit/3e4546d5bd38a1e98d4bd2de48631abf0398a3a2.diff";
|
|
|
|
|
sha256 = "sha256-oC+bRjEHixv1QEFO9XAm4HHOwoiT+NkhknKGPydnZ5E=";
|
|
|
|
|
revert = true;
|
|
|
|
|
})
|
2024-10-14 14:08:05 +01:00
|
|
|
|
|
|
|
|
|
# musl changes https://gitlab.com/qemu-project/qemu/-/issues/2215
|
|
|
|
|
(fetchpatch {
|
|
|
|
|
url = "https://gitlab.com/qemu-project/qemu/-/commit/ac1bbe8ca46c550b3ad99c85744119a3ace7b4f4.diff";
|
|
|
|
|
sha256 = "sha256-wSlf8+7WHk2Z4I5cLFa37MRroQucPIuFzzyWnG9IpeY=";
|
|
|
|
|
})
|
|
|
|
|
(fetchpatch {
|
|
|
|
|
url = "https://gitlab.com/qemu-project/qemu/-/commit/99174ce39e86ec6aea7bb7ce326b16e3eed9e3da.diff";
|
|
|
|
|
sha256 = "sha256-Cpt01d1ARoCTuJuC66no4doPgL+4/ZqnJTWwjU2MxnY=";
|
|
|
|
|
})
|
2022-02-28 16:14:16 +00:00
|
|
|
|
]
|
2022-06-08 17:07:15 +01:00
|
|
|
|
++ lib.optional nixosTestRunner ./force-uid0-on-9p.patch;
|
2017-02-22 08:06:49 +00:00
|
|
|
|
|
2021-02-10 20:48:54 +00:00
|
|
|
|
postPatch = ''
|
2021-05-21 07:52:56 +01:00
|
|
|
|
# Otherwise tries to ensure /var/run exists.
|
2022-12-14 20:20:33 +00:00
|
|
|
|
sed -i "/install_emptydir(get_option('localstatedir') \/ 'run')/d" \
|
2021-02-10 20:48:54 +00:00
|
|
|
|
qga/meson.build
|
|
|
|
|
'';
|
|
|
|
|
|
2017-07-21 17:39:50 +01:00
|
|
|
|
preConfigure = ''
|
|
|
|
|
unset CPP # intereferes with dependency calculation
|
2020-12-15 18:25:55 +00:00
|
|
|
|
# this script isn't marked as executable b/c it's indirectly used by meson. Needed to patch its shebang
|
2023-04-06 11:18:49 +01:00
|
|
|
|
chmod +x ./scripts/shaderinclude.py
|
2020-12-15 18:25:55 +00:00
|
|
|
|
patchShebangs .
|
2021-02-08 21:42:05 +00:00
|
|
|
|
# avoid conflicts with libc++ include for <version>
|
|
|
|
|
mv VERSION QEMU_VERSION
|
2021-05-01 01:22:19 +01:00
|
|
|
|
substituteInPlace configure \
|
|
|
|
|
--replace '$source_path/VERSION' '$source_path/QEMU_VERSION'
|
2021-02-08 21:42:05 +00:00
|
|
|
|
substituteInPlace meson.build \
|
|
|
|
|
--replace "'VERSION'" "'QEMU_VERSION'"
|
2017-07-21 17:39:50 +01:00
|
|
|
|
'';
|
|
|
|
|
|
2021-08-04 19:54:48 +01:00
|
|
|
|
configureFlags = [
|
2021-11-21 20:26:51 +00:00
|
|
|
|
"--disable-strip" # We'll strip ourselves after separating debug info.
|
2023-04-21 19:04:48 +01:00
|
|
|
|
(lib.enableFeature enableDocs "docs")
|
2023-05-27 18:11:48 +01:00
|
|
|
|
(lib.enableFeature enableTools "tools")
|
2021-08-04 19:54:48 +01:00
|
|
|
|
"--localstatedir=/var"
|
|
|
|
|
"--sysconfdir=/etc"
|
2021-11-28 09:40:29 +00:00
|
|
|
|
"--cross-prefix=${stdenv.cc.targetPrefix}"
|
2022-03-22 13:21:21 +00:00
|
|
|
|
(lib.enableFeature guestAgentSupport "guest-agent")
|
2021-08-04 19:54:48 +01:00
|
|
|
|
] ++ lib.optional numaSupport "--enable-numa"
|
|
|
|
|
++ lib.optional seccompSupport "--enable-seccomp"
|
|
|
|
|
++ lib.optional smartcardSupport "--enable-smartcard"
|
|
|
|
|
++ lib.optional spiceSupport "--enable-spice"
|
|
|
|
|
++ lib.optional usbredirSupport "--enable-usb-redir"
|
|
|
|
|
++ lib.optional (hostCpuTargets != null) "--target-list=${lib.concatStringsSep "," hostCpuTargets}"
|
2022-10-17 00:29:54 +01:00
|
|
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [ "--enable-cocoa" "--enable-hvf" ]
|
2024-08-03 14:31:23 +01:00
|
|
|
|
++ lib.optional (stdenv.hostPlatform.isLinux && !userOnly) "--enable-linux-aio"
|
2021-08-04 19:54:48 +01:00
|
|
|
|
++ lib.optional gtkSupport "--enable-gtk"
|
|
|
|
|
++ lib.optional xenSupport "--enable-xen"
|
|
|
|
|
++ lib.optional cephSupport "--enable-rbd"
|
|
|
|
|
++ lib.optional glusterfsSupport "--enable-glusterfs"
|
|
|
|
|
++ lib.optional openGLSupport "--enable-opengl"
|
|
|
|
|
++ lib.optional virglSupport "--enable-virglrenderer"
|
|
|
|
|
++ lib.optional tpmSupport "--enable-tpm"
|
|
|
|
|
++ lib.optional libiscsiSupport "--enable-libiscsi"
|
2021-11-14 22:12:02 +00:00
|
|
|
|
++ lib.optional smbdSupport "--smbd=${samba}/bin/smbd"
|
2022-10-03 16:44:04 +01:00
|
|
|
|
++ lib.optional uringSupport "--enable-linux-io-uring"
|
2023-05-17 22:55:04 +01:00
|
|
|
|
++ lib.optional canokeySupport "--enable-canokey"
|
2023-05-27 18:11:48 +01:00
|
|
|
|
++ lib.optional capstoneSupport "--enable-capstone"
|
2023-05-27 18:11:49 +01:00
|
|
|
|
++ lib.optional (!pluginsSupport) "--disable-plugins"
|
2024-08-04 12:25:46 +01:00
|
|
|
|
++ lib.optional (!enableBlobs) "--disable-install-blobs"
|
2024-08-03 14:32:46 +01:00
|
|
|
|
++ lib.optional userOnly "--disable-system"
|
|
|
|
|
++ lib.optional stdenv.hostPlatform.isStatic "--static";
|
2015-06-01 19:55:53 +01:00
|
|
|
|
|
2020-06-01 21:56:37 +01:00
|
|
|
|
dontWrapGApps = true;
|
2018-04-25 04:20:18 +01:00
|
|
|
|
|
2021-10-01 06:42:17 +01:00
|
|
|
|
# QEMU attaches entitlements with codesign and strip removes those,
|
|
|
|
|
# voiding the entitlements and making it non-operational.
|
|
|
|
|
# The alternative is to re-sign with entitlements after stripping:
|
|
|
|
|
# * https://github.com/qemu/qemu/blob/v6.1.0/scripts/entitlement.sh#L25
|
|
|
|
|
dontStrip = stdenv.hostPlatform.isDarwin;
|
|
|
|
|
|
2020-06-01 21:56:37 +01:00
|
|
|
|
postFixup = ''
|
2020-07-22 06:38:23 +01:00
|
|
|
|
# the .desktop is both invalid and pointless
|
2021-03-01 17:32:39 +00:00
|
|
|
|
rm -f $out/share/applications/qemu.desktop
|
2022-03-22 13:21:21 +00:00
|
|
|
|
'' + lib.optionalString guestAgentSupport ''
|
2022-04-09 18:29:04 +01:00
|
|
|
|
# move qemu-ga (guest agent) to separate output
|
2020-07-22 06:38:23 +01:00
|
|
|
|
mkdir -p $ga/bin
|
2022-04-09 18:29:04 +01:00
|
|
|
|
mv $out/bin/qemu-ga $ga/bin/
|
|
|
|
|
ln -s $ga/bin/qemu-ga $out/bin
|
2022-03-02 10:00:10 +00:00
|
|
|
|
remove-references-to -t $out $ga/bin/qemu-ga
|
2021-08-04 19:54:48 +01:00
|
|
|
|
'' + lib.optionalString gtkSupport ''
|
2020-07-22 06:38:23 +01:00
|
|
|
|
# wrap GTK Binaries
|
|
|
|
|
for f in $out/bin/qemu-system-*; do
|
|
|
|
|
wrapGApp $f
|
|
|
|
|
done
|
2024-06-05 15:27:57 +01:00
|
|
|
|
'' + lib.optionalString stdenv.hostPlatform.isStatic ''
|
|
|
|
|
# HACK: Otherwise the result will have the entire buildInputs closure
|
|
|
|
|
# injected by the pkgsStatic stdenv
|
|
|
|
|
# <https://github.com/NixOS/nixpkgs/issues/83667>
|
|
|
|
|
rm -f $out/nix-support/propagated-build-inputs
|
2020-07-22 06:38:23 +01:00
|
|
|
|
'';
|
2020-12-15 18:25:55 +00:00
|
|
|
|
preBuild = "cd build";
|
2016-04-08 00:45:53 +01:00
|
|
|
|
|
2021-12-03 21:35:35 +00:00
|
|
|
|
# tests can still timeout on slower systems
|
2023-08-24 08:48:17 +01:00
|
|
|
|
doCheck = false;
|
2023-01-21 12:00:00 +00:00
|
|
|
|
nativeCheckInputs = [ socat ];
|
2021-12-03 21:35:35 +00:00
|
|
|
|
preCheck = ''
|
|
|
|
|
# time limits are a little meagre for a build machine that's
|
|
|
|
|
# potentially under load.
|
|
|
|
|
substituteInPlace ../tests/unit/meson.build \
|
|
|
|
|
--replace 'timeout: slow_tests' 'timeout: 50 * slow_tests'
|
|
|
|
|
substituteInPlace ../tests/qtest/meson.build \
|
|
|
|
|
--replace 'timeout: slow_qtests' 'timeout: 50 * slow_qtests'
|
|
|
|
|
substituteInPlace ../tests/fp/meson.build \
|
|
|
|
|
--replace 'timeout: 90)' 'timeout: 300)'
|
|
|
|
|
|
|
|
|
|
# point tests towards correct binaries
|
|
|
|
|
substituteInPlace ../tests/unit/test-qga.c \
|
2023-08-24 11:33:52 +01:00
|
|
|
|
--replace '/bin/bash' "$(type -P bash)" \
|
2021-12-03 21:35:35 +00:00
|
|
|
|
--replace '/bin/echo' "$(type -P echo)"
|
|
|
|
|
substituteInPlace ../tests/unit/test-io-channel-command.c \
|
|
|
|
|
--replace '/bin/socat' "$(type -P socat)"
|
|
|
|
|
|
|
|
|
|
# combined with a long package name, some temp socket paths
|
|
|
|
|
# can end up exceeding max socket name len
|
|
|
|
|
substituteInPlace ../tests/qtest/bios-tables-test.c \
|
|
|
|
|
--replace 'qemu-test_acpi_%s_tcg_%s' '%s_%s'
|
|
|
|
|
|
|
|
|
|
# get-fsinfo attempts to access block devices, disallowed by sandbox
|
|
|
|
|
sed -i -e '/\/qga\/get-fsinfo/d' -e '/\/qga\/blacklist/d' \
|
|
|
|
|
../tests/unit/test-qga.c
|
2024-05-07 21:37:17 +01:00
|
|
|
|
|
|
|
|
|
# xattrs are not allowed in the sandbox
|
|
|
|
|
substituteInPlace ../tests/qtest/virtio-9p-test.c \
|
|
|
|
|
--replace-fail mapped-xattr mapped-file
|
2021-12-03 21:35:35 +00:00
|
|
|
|
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
|
|
|
|
|
# skip test that stalls on darwin, perhaps due to subtle differences
|
|
|
|
|
# in fifo behaviour
|
|
|
|
|
substituteInPlace ../tests/unit/meson.build \
|
|
|
|
|
--replace "'test-io-channel-command'" "#'test-io-channel-command'"
|
|
|
|
|
'';
|
|
|
|
|
|
2017-12-06 18:06:33 +00:00
|
|
|
|
# Add a ‘qemu-kvm’ wrapper for compatibility/convenience.
|
2024-08-04 12:25:46 +01:00
|
|
|
|
postInstall = lib.optionalString (!minimal) ''
|
2022-02-01 13:14:42 +00:00
|
|
|
|
ln -s $out/bin/qemu-system-${stdenv.hostPlatform.qemuArch} $out/bin/qemu-kvm
|
2018-11-13 22:54:08 +00:00
|
|
|
|
'';
|
2013-07-31 13:31:04 +01:00
|
|
|
|
|
2017-12-07 21:26:42 +00:00
|
|
|
|
passthru = {
|
|
|
|
|
qemu-system-i386 = "bin/qemu-system-i386";
|
2023-10-21 17:42:57 +01:00
|
|
|
|
tests = lib.optionalAttrs (!toolsOnly) {
|
2023-08-24 08:48:17 +01:00
|
|
|
|
qemu-tests = finalAttrs.finalPackage.overrideAttrs (_: { doCheck = true; });
|
2023-10-21 22:54:54 +01:00
|
|
|
|
qemu-utils-builds = qemu-utils;
|
2021-12-03 21:35:35 +00:00
|
|
|
|
};
|
2023-08-12 07:46:48 +01:00
|
|
|
|
updateScript = gitUpdater {
|
|
|
|
|
# No nicer place to find latest release.
|
|
|
|
|
url = "https://gitlab.com/qemu-project/qemu.git";
|
|
|
|
|
rev-prefix = "v";
|
|
|
|
|
ignoredVersions = "(alpha|beta|rc).*";
|
|
|
|
|
};
|
2017-12-07 21:26:42 +00:00
|
|
|
|
};
|
|
|
|
|
|
2021-04-26 01:49:20 +01:00
|
|
|
|
# Builds in ~3h with 2 cores, and ~20m with a big-parallel builder.
|
|
|
|
|
requiredSystemFeatures = [ "big-parallel" ];
|
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
|
meta = with lib; {
|
2023-10-30 20:41:44 +00:00
|
|
|
|
homepage = "https://www.qemu.org/";
|
|
|
|
|
description = "Generic and open source machine emulator and virtualizer";
|
2014-02-20 20:02:55 +00:00
|
|
|
|
license = licenses.gpl2Plus;
|
2024-08-25 19:07:22 +01:00
|
|
|
|
maintainers = with maintainers; [ qyliss ] ++ lib.optionals xenSupport xen.meta.maintainers;
|
2021-05-01 01:22:19 +01:00
|
|
|
|
platforms = platforms.unix;
|
2023-10-21 17:42:57 +01:00
|
|
|
|
}
|
|
|
|
|
# toolsOnly: Does not have qemu-kvm and there's no main support tool
|
2024-08-04 12:25:46 +01:00
|
|
|
|
# userOnly: There's one qemu-<arch> for every architecture
|
|
|
|
|
// lib.optionalAttrs (!toolsOnly && !userOnly) {
|
2023-10-21 17:42:57 +01:00
|
|
|
|
mainProgram = "qemu-kvm";
|
2024-08-04 12:25:46 +01:00
|
|
|
|
}
|
|
|
|
|
# userOnly: https://qemu.readthedocs.io/en/v9.0.2/user/main.html
|
|
|
|
|
// lib.optionalAttrs userOnly {
|
|
|
|
|
platforms = with platforms; (linux ++ freebsd ++ openbsd ++ netbsd);
|
|
|
|
|
description = "QEMU User space emulator - launch executables compiled for one CPU on another CPU";
|
2013-02-08 01:44:02 +00:00
|
|
|
|
};
|
2023-08-24 08:48:17 +01:00
|
|
|
|
})
|