about summary refs log tree commit diff
path: root/pkgs/by-name/pc/pcsx2/package.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/pc/pcsx2/package.nix')
-rw-r--r--pkgs/by-name/pc/pcsx2/package.nix152
1 files changed, 129 insertions, 23 deletions
diff --git a/pkgs/by-name/pc/pcsx2/package.nix b/pkgs/by-name/pc/pcsx2/package.nix
index 4454727158a90..2e0a3f7c64f5d 100644
--- a/pkgs/by-name/pc/pcsx2/package.nix
+++ b/pkgs/by-name/pc/pcsx2/package.nix
@@ -1,39 +1,145 @@
 {
-  stdenv,
   lib,
+  SDL2,
   callPackage,
+  cmake,
+  cubeb,
+  curl,
+  extra-cmake-modules,
+  ffmpeg,
+  libXrandr,
+  libaio,
+  libbacktrace,
+  libpcap,
+  libwebp,
+  llvmPackages_17,
+  lz4,
+  makeWrapper,
+  pkg-config,
+  qt6,
+  soundtouch,
+  strip-nondeterminism,
+  vulkan-headers,
+  vulkan-loader,
+  wayland,
+  zip,
+  zstd,
 }:
+
 let
-  pname = "pcsx2";
-  version = "1.7.5779";
-  meta = with lib; {
+  sources = callPackage ./sources.nix { };
+  inherit (qt6)
+    qtbase
+    qtsvg
+    qttools
+    qtwayland
+    wrapQtAppsHook
+    ;
+in
+llvmPackages_17.stdenv.mkDerivation (finalAttrs: {
+  inherit (sources.pcsx2) pname version src;
+
+  patches = [
+    # Remove PCSX2_GIT_REV
+    ./0000-define-rev.patch
+  ];
+
+  cmakeFlags = [
+    (lib.cmakeBool "DISABLE_ADVANCE_SIMD" true)
+    (lib.cmakeBool "USE_LINKED_FFMPEG" true)
+    (lib.cmakeFeature "PCSX2_GIT_REV" finalAttrs.src.rev)
+  ];
+
+  nativeBuildInputs = [
+    cmake
+    pkg-config
+    strip-nondeterminism
+    wrapQtAppsHook
+    zip
+  ];
+
+  buildInputs = [
+    curl
+    extra-cmake-modules
+    ffmpeg
+    libaio
+    libbacktrace
+    libpcap
+    libwebp
+    libXrandr
+    lz4
+    qtbase
+    qtsvg
+    qttools
+    qtwayland
+    SDL2
+    sources.shaderc-patched
+    soundtouch
+    vulkan-headers
+    wayland
+    zstd
+  ] ++ cubeb.passthru.backendLibs;
+
+  strictDeps = true;
+
+  installPhase = ''
+    runHook preInstall
+    mkdir -p $out/bin
+    cp -a bin/pcsx2-qt bin/resources $out/bin/
+
+    install -Dm644 $src/pcsx2-qt/resources/icons/AppIcon64.png $out/share/pixmaps/PCSX2.png
+    install -Dm644 $src/.github/workflows/scripts/linux/pcsx2-qt.desktop $out/share/applications/PCSX2.desktop
+
+    zip -jq $out/bin/resources/patches.zip ${sources.pcsx2_patches.src}/patches/*
+    strip-nondeterminism $out/bin/resources/patches.zip
+    runHook postInstall
+  '';
+
+  qtWrapperArgs =
+    let
+      libs = lib.makeLibraryPath (
+        [
+          vulkan-loader
+          sources.shaderc-patched
+        ]
+        ++ cubeb.passthru.backendLibs
+      );
+    in
+    [ "--prefix LD_LIBRARY_PATH : ${libs}" ];
+
+  # https://github.com/PCSX2/pcsx2/pull/10200
+  # Can't avoid the double wrapping, the binary wrapper from qtWrapperArgs doesn't support --run
+  postFixup = ''
+    source "${makeWrapper}/nix-support/setup-hook"
+    wrapProgram $out/bin/pcsx2-qt \
+      --run 'if [[ -z $I_WANT_A_BROKEN_WAYLAND_UI ]]; then export QT_QPA_PLATFORM=xcb; fi'
+  '';
+
+  meta = {
+    homepage = "https://pcsx2.net";
     description = "Playstation 2 emulator";
     longDescription = ''
-      PCSX2 is an open-source PlayStation 2 (AKA PS2) emulator. Its purpose
-      is to emulate the PS2 hardware, using a combination of MIPS CPU
-      Interpreters, Recompilers and a Virtual Machine which manages hardware
-      states and PS2 system memory. This allows you to play PS2 games on your
-      PC, with many additional features and benefits.
+      PCSX2 is an open-source PlayStation 2 (AKA PS2) emulator. Its purpose is
+      to emulate the PS2 hardware, using a combination of MIPS CPU Interpreters,
+      Recompilers and a Virtual Machine which manages hardware states and PS2
+      system memory. This allows you to play PS2 games on your PC, with many
+      additional features and benefits.
     '';
-    hydraPlatforms = platforms.linux;
-    homepage = "https://pcsx2.net";
-    license = with licenses; [
+    changelog = "https://github.com/PCSX2/pcsx2/releases/tag/v${finalAttrs.version}";
+    downloadPage = "https://github.com/PCSX2/pcsx2";
+    license = with lib.licenses; [
       gpl3Plus
       lgpl3Plus
     ];
-    maintainers = with maintainers; [
+    mainProgram = "pcsx2-qt";
+    maintainers = with lib.maintainers; [
+      AndersonTorres
       hrdinka
       govanify
       matteopacini
     ];
-    mainProgram = "pcsx2-qt";
-    platforms = [ "x86_64-linux" "x86_64-darwin" ];
-    sourceProvenance =
-      lib.optional stdenv.isDarwin sourceTypes.binaryNativeCode
-      ++ lib.optional stdenv.isLinux sourceTypes.fromSource;
+    platforms = lib.systems.inspect.patternLogicalAnd
+      lib.systems.inspect.patterns.isLinux
+      lib.systems.inspect.patterns.isx86_64;
   };
-in
-if stdenv.isDarwin then
-  callPackage ./darwin.nix { inherit pname version meta; }
-else
-  callPackage ./linux.nix { inherit pname version meta; }
+})