Unverified Commit 65544975 authored by Anderson Torres's avatar Anderson Torres Committed by GitHub
Browse files

Merge pull request #216913 from atorres1985-contrib/xemu

xemu: cosmetic rewrite
parents 2c6a017a 31b278f6
Loading
Loading
Loading
Loading
+61 −51
Original line number Diff line number Diff line
{ stdenv
{ lib
, stdenv
, fetchFromGitHub
, lib
, makeDesktopItem
, SDL2
, SDL2_image
, copyDesktopItems
, pkg-config
, python3
, ninja
, meson
, which
, perl
, wrapGAppsHook
, gettext
, glib
, gtk3
, libpcap
, openssl
, libGLU
, libdrm
, libepoxy
, libpcap
, libsamplerate
, SDL2
, SDL2_image
, makeDesktopItem
, mesa
, libdrm
, libGLU
, gettext
, meson
, ninja
, openssl
, perl
, pkg-config
, python3
, vte
, which
, wrapGAppsHook
}:

stdenv.mkDerivation rec {
stdenv.mkDerivation (self: {
  pname = "xemu";
  version = "0.7.84";

  src = fetchFromGitHub {
    owner = "xemu-project";
    repo = "xemu";
    rev = "v${version}";
    fetchSubmodules = true;
    rev = "v${self.version}";
    hash = "sha256-pEXjwoQKbMmVNYCnh5nqP7k0acYOAp8SqxYZwPzVwDY=";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [
    copyDesktopItems
    meson
    ninja
    perl
    pkg-config
    python3
    python3.pkgs.pyyaml
    ninja
    which
    meson
    perl
    wrapGAppsHook
    copyDesktopItems
  ];

  buildInputs = [
    SDL2
    SDL2_image
    gettext
    glib
    gtk3
    openssl
    mesa
    libepoxy
    libGLU
    libdrm
    libepoxy
    libpcap
    libsamplerate
    SDL2
    libGLU
    SDL2_image
    gettext
    mesa
    openssl
    vte
  ];

@@ -80,23 +80,26 @@ stdenv.mkDerivation rec {

  buildFlags = [ "qemu-system-i386" ];

  desktopItems = [(makeDesktopItem {
  desktopItems = [
    (makeDesktopItem {
      name = "xemu";
      desktopName = "xemu";
      exec = "xemu";
      icon = "xemu";
  })] ;
    })
  ];

  preConfigure = let
    # When the data below can't be obtained through git, the build process tries
    # to run `XEMU_COMMIT=$(cat XEMU_COMMIT)` (and similar)
    branch = "master";
    commit = "d8fa50e524c22f85ecb2e43108fd6a5501744351";
    inherit (self) version;
  in ''
    patchShebangs .
    configureFlagsArray+=("--extra-cflags=-DXBOX=1 -Wno-error=redundant-decls")
    substituteInPlace ./scripts/xemu-version.sh \
      --replace 'date -u' "date -d @$SOURCE_DATE_EPOCH '+%Y-%m-%d %H:%M:%S'"
    # If the versions can't be obtained through git, the build process tries
    # to run `XEMU_COMMIT=$(cat XEMU_COMMIT)` (and similar)
    echo '${commit}' > XEMU_COMMIT
    echo '${branch}' > XEMU_BRANCH
    echo '${version}' > XEMU_VERSION
@@ -110,22 +113,29 @@ stdenv.mkDerivation rec {
  installPhase = ''
    runHook preInstall

    mkdir -p $out/{bin,share}
    cp qemu-system-i386 $out/bin/xemu

    for RES in 16x16 24x24 32x32 48x48 128x128 256x256 512x512
    do
      mkdir -p $out/share/icons/hicolor/$RES/apps/
      cp ../ui/icons/xemu_$RES.png $out/share/icons/hicolor/$RES/apps/xemu.png
    done
    install -Dm755 -T qemu-system-i386 $out/bin/xemu
  '' +
  # Generate code to install the icons
  (lib.concatMapStringsSep ";\n"
    (res:
      "install -Dm644 -T ../ui/icons/xemu_${res}.png $out/share/icons/hicolor/${res}/apps/xemu.png")
    [ "16x16" "24x24" "32x32" "48x48" "128x128" "256x256" "512x512" ]) +
  ''

    runHook postInstall
  '';

  meta = with lib; {
  meta = {
    homepage = "https://xemu.app/";
    description = "Original Xbox emulator";
    maintainers = with maintainers; [ ];
    license = licenses.gpl2Plus;
    longDescription = ''
      A free and open-source application that emulates the original Microsoft
      Xbox game console, enabling people to play their original Xbox games on
      Windows, macOS, and Linux systems.
    '';
    changelog = "https://github.com/xemu-project/xemu/releases/tag/v${self.version}";
    license = lib.licenses.gpl2Plus;
    maintainers = with lib.maintainers; [ AndersonTorres genericnerdyusername ];
    platforms = with lib.platforms; linux;
  };
}
})