xemu: darwin support

This commit is contained in:
Matteo Pacini
2025-10-09 00:18:29 +01:00
parent 4ec54e9efb
commit c5daa64fcc

View File

@@ -28,6 +28,9 @@
which, which,
wrapGAppsHook3, wrapGAppsHook3,
cacert, cacert,
darwin,
apple-sdk_12,
desktopToDarwinBundle,
}: }:
stdenv.mkDerivation (finalAttrs: { stdenv.mkDerivation (finalAttrs: {
@@ -66,6 +69,10 @@ stdenv.mkDerivation (finalAttrs: {
which which
wrapGAppsHook3 wrapGAppsHook3
] ]
++ lib.optionals stdenv.hostPlatform.isDarwin [
darwin.sigtool
desktopToDarwinBundle
]
++ (with python3Packages; [ ++ (with python3Packages; [
python python
pyyaml pyyaml
@@ -79,22 +86,34 @@ stdenv.mkDerivation (finalAttrs: {
glib glib
gtk3 gtk3
curl curl
libdrm
libepoxy libepoxy
libpcap libpcap
libsamplerate libsamplerate
libslirp libslirp
libgbm
openssl openssl
vte
vulkan-headers vulkan-headers
vulkan-loader vulkan-loader
]
++ lib.optionals stdenv.hostPlatform.isLinux [
libdrm
libgbm
vte
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
apple-sdk_12
]; ];
configureFlags = [ configureFlags = [
"--disable-strip" "--disable-strip"
"--target-list=i386-softmmu" "--target-list=i386-softmmu"
"--disable-werror" "--disable-werror"
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
# As seen in the official build script ($src/build.sh)
"--disable-cocoa"
]
++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
"--enable-hvf"
]; ];
buildFlags = [ "qemu-system-i386" ]; buildFlags = [ "qemu-system-i386" ];
@@ -117,6 +136,11 @@ stdenv.mkDerivation (finalAttrs: {
preConfigure = '' preConfigure = ''
configureFlagsArray+=("--extra-cflags=-DXBOX=1 -Wno-error=redundant-decls") configureFlagsArray+=("--extra-cflags=-DXBOX=1 -Wno-error=redundant-decls")
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
configureFlagsArray+=("-Wno-implicit-function-declaration")
''
+ ''
# When the data below can't be obtained through git, the build process tries # When the data below can't be obtained through git, the build process tries
# to run `XEMU_COMMIT=$(cat XEMU_COMMIT)` (and similar) # to run `XEMU_COMMIT=$(cat XEMU_COMMIT)` (and similar)
echo '${finalAttrs.version}' > XEMU_VERSION echo '${finalAttrs.version}' > XEMU_VERSION
@@ -127,6 +151,15 @@ stdenv.mkDerivation (finalAttrs: {
substituteInPlace ./build.ninja --replace /usr/bin/env $(which env) substituteInPlace ./build.ninja --replace /usr/bin/env $(which env)
''; '';
postBuild =
lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) ''
# Needed for HVF acceleration
codesign --entitlements $src/accel/hvf/entitlements.plist -f -s - qemu-system-i386-unsigned
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
mv qemu-system-i386-unsigned qemu-system-i386
'';
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
@@ -155,6 +188,6 @@ stdenv.mkDerivation (finalAttrs: {
license = lib.licenses.gpl2Plus; license = lib.licenses.gpl2Plus;
mainProgram = "xemu"; mainProgram = "xemu";
maintainers = with lib.maintainers; [ marcin-serwin ]; maintainers = with lib.maintainers; [ marcin-serwin ];
platforms = lib.platforms.linux; platforms = lib.platforms.linux ++ lib.platforms.darwin;
}; };
}) })