summary refs log tree commit diff
diff options
context:
space:
mode:
authorAnderson Torres <torres.anderson.85@protonmail.com>2022-08-15 20:32:21 -0300
committerGitHub <noreply@github.com>2022-08-15 20:32:21 -0300
commit0442e4020f535a12067c2add4e226f0c58a07732 (patch)
tree57b36553cd80cb6c623ba8e3dc048bde0c40767b
parentd7e6face041d508bacfe6734747c4d00c734e448 (diff)
parenta3cdf49dbf5483656a22e5f7481892022b59e577 (diff)
downloadnixpkgs-0442e4020f535a12067c2add4e226f0c58a07732.tar
nixpkgs-0442e4020f535a12067c2add4e226f0c58a07732.tar.gz
nixpkgs-0442e4020f535a12067c2add4e226f0c58a07732.tar.bz2
nixpkgs-0442e4020f535a12067c2add4e226f0c58a07732.tar.lz
nixpkgs-0442e4020f535a12067c2add4e226f0c58a07732.tar.xz
nixpkgs-0442e4020f535a12067c2add4e226f0c58a07732.tar.zst
nixpkgs-0442e4020f535a12067c2add4e226f0c58a07732.zip
Merge pull request #186441 from SamLukeYes/ppsspp
ppsspp: add SDL and headless
-rw-r--r--pkgs/applications/emulators/ppsspp/default.nix157
-rw-r--r--pkgs/top-level/all-packages.nix12
2 files changed, 111 insertions, 58 deletions
diff --git a/pkgs/applications/emulators/ppsspp/default.nix b/pkgs/applications/emulators/ppsspp/default.nix
index 1264768f387..6281cbd2c08 100644
--- a/pkgs/applications/emulators/ppsspp/default.nix
+++ b/pkgs/applications/emulators/ppsspp/default.nix
@@ -3,76 +3,119 @@
 , 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
 }:
 
-stdenv.mkDerivation (finalAttrs: {
-  pname = "ppsspp";
-  version = "1.13.1";
+let
+  enableQt = (qtbase != null);
+  frontend = if enableQt then "Qt" else "SDL and headless";
+  vulkanPath = lib.makeLibraryPath [ vulkan-loader ];
 
-  src = fetchFromGitHub {
-    owner = "hrydgard";
-    repo = "ppsspp";
-    rev = "v${finalAttrs.version}";
-    fetchSubmodules = true;
-    sha256 = "sha256-WsFy2aSOmkII2Lte5et4W6qj0AXUKWWkYe88T0OQP08=";
-  };
+  # 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"
+      + lib.optionalString enableQt "-qt"
+      + lib.optionalString (!enableQt) "-sdl"
+      + lib.optionalString forceWayland "-wayland";
+    version = "1.13.1";
 
-  postPatch = ''
-    substituteInPlace git-version.cmake --replace unknown ${finalAttrs.src.rev}
-    substituteInPlace UI/NativeApp.cpp --replace /usr/share $out/share
-  '';
+    src = fetchFromGitHub {
+      owner = "hrydgard";
+      repo = "ppsspp";
+      rev = "v${finalAttrs.version}";
+      fetchSubmodules = true;
+      sha256 = "sha256-WsFy2aSOmkII2Lte5et4W6qj0AXUKWWkYe88T0OQP08=";
+    };
 
-  nativeBuildInputs = [
-    cmake
-    pkg-config
-    python3
-    wrapQtAppsHook
-  ];
+    postPatch = ''
+      substituteInPlace git-version.cmake --replace unknown ${finalAttrs.src.rev}
+      substituteInPlace UI/NativeApp.cpp --replace /usr/share $out/share
+    '';
 
-  buildInputs = [
-    SDL2
-    ffmpeg
-    glew
-    libzip
-    qtbase
-    qtmultimedia
-    snappy
-    zlib
-  ];
+    nativeBuildInputs = [
+      cmake
+      copyDesktopItems
+      makeWrapper
+      pkg-config
+      python3
+      wrapQtAppsHook
+    ];
 
-  cmakeFlags = [
-    "-DHEADLESS=OFF"
-    "-DOpenGL_GL_PREFERENCE=GLVND"
-    "-DUSE_SYSTEM_FFMPEG=ON"
-    "-DUSE_SYSTEM_LIBZIP=ON"
-    "-DUSE_SYSTEM_SNAPPY=ON"
-    "-DUSING_QT_UI=ON"
-  ];
+    buildInputs = [
+      SDL2
+      ffmpeg
+      (glew.override { enableEGL = forceWayland; })
+      libzip
+      qtbase
+      qtmultimedia
+      snappy
+      zlib
+    ] ++ lib.optional enableVulkan vulkan-loader
+      ++ lib.optionals vulkanWayland [ wayland libffi ];
 
-  installPhase = ''
-    runHook preInstall
-    mkdir -p $out/share/ppsspp
-    install -Dm555 PPSSPPQt $out/bin/ppsspp
-    mv assets $out/share/ppsspp
-    runHook postInstall
-  '';
+    cmakeFlags = [
+      "-DHEADLESS=${if enableQt then "OFF" else "ON"}"
+      "-DOpenGL_GL_PREFERENCE=GLVND"
+      "-DUSE_SYSTEM_FFMPEG=ON"
+      "-DUSE_SYSTEM_LIBZIP=ON"
+      "-DUSE_SYSTEM_SNAPPY=ON"
+      "-DUSE_WAYLAND_WSI=${if vulkanWayland then "ON" else "OFF"}"
+      "-DUSING_QT_UI=${if enableQt then "ON" else "OFF"}"
+    ];
 
-  meta = with lib; {
-    homepage = "https://www.ppsspp.org/";
-    description = "A HLE Playstation Portable emulator, written in C++";
-    license = licenses.gpl2Plus;
-    maintainers = with maintainers; [ AndersonTorres ];
-    platforms = platforms.linux;
-  };
-})
-# TODO: add SDL headless port
+    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/{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++ (${frontend})";
+      license = licenses.gpl2Plus;
+      maintainers = with maintainers; [ AndersonTorres ];
+      platforms = platforms.linux;
+    };
+  })
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 638a9dfa8f4..27a7b1bf6a3 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -1497,8 +1497,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 { };