Unverified Commit 26821cee authored by Matteo Pacini's avatar Matteo Pacini Committed by GitHub
Browse files

xemu: darwin support, add myself as maintainer (#450201)

parents 004e1e03 55ff5b22
Loading
Loading
Loading
Loading
+41 −5
Original line number Diff line number Diff line
@@ -28,6 +28,9 @@
  which,
  wrapGAppsHook3,
  cacert,
  darwin,
  apple-sdk_12,
  desktopToDarwinBundle,
}:

stdenv.mkDerivation (finalAttrs: {
@@ -66,6 +69,10 @@ stdenv.mkDerivation (finalAttrs: {
    which
    wrapGAppsHook3
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    darwin.sigtool
    desktopToDarwinBundle
  ]
  ++ (with python3Packages; [
    python
    pyyaml
@@ -79,22 +86,34 @@ stdenv.mkDerivation (finalAttrs: {
    glib
    gtk3
    curl
    libdrm
    libepoxy
    libpcap
    libsamplerate
    libslirp
    libgbm
    openssl
    vte
    vulkan-headers
    vulkan-loader
  ]
  ++ lib.optionals stdenv.hostPlatform.isLinux [
    libdrm
    libgbm
    vte
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    apple-sdk_12
  ];

  configureFlags = [
    "--disable-strip"
    "--target-list=i386-softmmu"
    "--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" ];
@@ -117,6 +136,11 @@ stdenv.mkDerivation (finalAttrs: {

  preConfigure = ''
    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
    # to run `XEMU_COMMIT=$(cat XEMU_COMMIT)` (and similar)
    echo '${finalAttrs.version}' > XEMU_VERSION
@@ -127,6 +151,15 @@ stdenv.mkDerivation (finalAttrs: {
    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 = ''
    runHook preInstall

@@ -154,7 +187,10 @@ stdenv.mkDerivation (finalAttrs: {
    changelog = "https://github.com/xemu-project/xemu/releases/tag/v${finalAttrs.version}";
    license = lib.licenses.gpl2Plus;
    mainProgram = "xemu";
    maintainers = with lib.maintainers; [ marcin-serwin ];
    platforms = lib.platforms.linux;
    maintainers = with lib.maintainers; [
      marcin-serwin
      matteopacini
    ];
    platforms = lib.platforms.linux ++ lib.platforms.darwin;
  };
})