Commit a3cdf49d authored by SamLukeYes's avatar SamLukeYes
Browse files

ppsspp: add SDL and headless

Change the default ppsspp package to SDL frontend, as it supports
vulkan, and is allowed to build the headless binary together.
parent fae0b890
Loading
Loading
Loading
Loading
+100 −57
Original line number Diff line number Diff line
@@ -3,20 +3,41 @@
, fetchFromGitHub
, SDL2
, cmake
, copyDesktopItems
, ffmpeg
, glew
, libffi
, libzip
, makeDesktopItem
, makeWrapper
, pkg-config
, python3
, qtbase
, qtmultimedia
, qtbase ? null
, qtmultimedia ? null
, snappy
, wrapQtAppsHook
, vulkan-loader
, wayland
, wrapQtAppsHook ? null
, zlib
, enableVulkan ? true
, forceWayland ? false
}:

let
  enableQt = (qtbase != null);
  frontend = if enableQt then "Qt" else "SDL and headless";
  vulkanPath = lib.makeLibraryPath [ vulkan-loader ];

  # experimental, see https://github.com/hrydgard/ppsspp/issues/13845
  vulkanWayland = enableVulkan && forceWayland;
in
  # Only SDL front end needs to specify whether to use Wayland
  assert forceWayland -> !enableQt;
  stdenv.mkDerivation (finalAttrs: {
  pname = "ppsspp";
    pname = "ppsspp"
      + lib.optionalString enableQt "-qt"
      + lib.optionalString (!enableQt) "-sdl"
      + lib.optionalString forceWayland "-wayland";
    version = "1.13.1";

    src = fetchFromGitHub {
@@ -34,6 +55,8 @@ stdenv.mkDerivation (finalAttrs: {

    nativeBuildInputs = [
      cmake
      copyDesktopItems
      makeWrapper
      pkg-config
      python3
      wrapQtAppsHook
@@ -42,37 +65,57 @@ stdenv.mkDerivation (finalAttrs: {
    buildInputs = [
      SDL2
      ffmpeg
    glew
      (glew.override { enableEGL = forceWayland; })
      libzip
      qtbase
      qtmultimedia
      snappy
      zlib
  ];
    ] ++ lib.optional enableVulkan vulkan-loader
      ++ lib.optionals vulkanWayland [ wayland libffi ];

    cmakeFlags = [
    "-DHEADLESS=OFF"
      "-DHEADLESS=${if enableQt then "OFF" else "ON"}"
      "-DOpenGL_GL_PREFERENCE=GLVND"
      "-DUSE_SYSTEM_FFMPEG=ON"
      "-DUSE_SYSTEM_LIBZIP=ON"
      "-DUSE_SYSTEM_SNAPPY=ON"
    "-DUSING_QT_UI=ON"
      "-DUSE_WAYLAND_WSI=${if vulkanWayland then "ON" else "OFF"}"
      "-DUSING_QT_UI=${if enableQt then "ON" else "OFF"}"
    ];

    desktopItems = [(makeDesktopItem {
      desktopName = "PPSSPP";
      name = "ppsspp";
      exec = "ppsspp";
      icon = "ppsspp";
      comment = "Play PSP games on your computer";
      categories = [ "Game" "Emulator" ];
    })];

    installPhase = ''
      runHook preInstall
    mkdir -p $out/share/ppsspp
      mkdir -p $out/share/{applications,ppsspp}
    '' + (if enableQt then ''
      install -Dm555 PPSSPPQt $out/bin/ppsspp
      wrapProgram $out/bin/ppsspp \
    '' else ''
      install -Dm555 PPSSPPHeadless $out/bin/ppsspp-headless
      install -Dm555 PPSSPPSDL $out/share/ppsspp/
      makeWrapper $out/share/ppsspp/PPSSPPSDL $out/bin/ppsspp \
        --set SDL_VIDEODRIVER ${if forceWayland then "wayland" else "x11"} \
    '') + lib.optionalString enableVulkan ''
        --prefix LD_LIBRARY_PATH : ${vulkanPath} \
    '' + "\n" + ''
      mv assets $out/share/ppsspp
      runHook postInstall
    '';

    meta = with lib; {
      homepage = "https://www.ppsspp.org/";
    description = "A HLE Playstation Portable emulator, written in C++";
      description = "A HLE Playstation Portable emulator, written in C++ (${frontend})";
      license = licenses.gpl2Plus;
      maintainers = with maintainers; [ AndersonTorres ];
      platforms = platforms.linux;
    };
  })
# TODO: add SDL headless port
+11 −1
Original line number Diff line number Diff line
@@ -1493,8 +1493,18 @@ with pkgs;
  pcsxr = callPackage ../applications/emulators/pcsxr { };
  ppsspp = callPackage ../applications/emulators/ppsspp {
  ppsspp = callPackage ../applications/emulators/ppsspp { };
  ppsspp-sdl = ppsspp;
  ppsspp-sdl-wayland = ppsspp.override {
    forceWayland = true;
    enableVulkan = false; # https://github.com/hrydgard/ppsspp/issues/13845
  };
  ppsspp-qt = ppsspp.override {
    inherit (libsForQt5) qtbase qtmultimedia wrapQtAppsHook;
    enableVulkan = false; # https://github.com/hrydgard/ppsspp/issues/11628
  };
  proton-caller = callPackage ../applications/emulators/proton-caller { };