Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / by-name / pp / ppsspp / package.nix
blob2fbcdef3f7441ddf8350f47b122f7145371f83de
2   lib,
3   SDL2,
4   cmake,
5   copyDesktopItems,
6   fetchFromGitHub,
7   ffmpeg,
8   glew,
9   libffi,
10   libsForQt5,
11   libzip,
12   makeDesktopItem,
13   makeWrapper,
14   pkg-config,
15   python3,
16   snappy,
17   stdenv,
18   vulkan-loader,
19   wayland,
20   zlib,
22   enableQt ? false,
23   enableVulkan ? true,
24   forceWayland ? false,
25   useSystemFfmpeg? false,
26   useSystemSnappy? true,
29 let
30   # experimental, see https://github.com/hrydgard/ppsspp/issues/13845
31   vulkanWayland = enableVulkan && forceWayland;
32   inherit (libsForQt5) qtbase qtmultimedia wrapQtAppsHook;
34 # Only SDL frontend needs to specify whether to use Wayland
35 assert forceWayland -> !enableQt;
36 stdenv.mkDerivation (finalAttrs: {
37   pname = "ppsspp"
38           + lib.optionalString enableQt "-qt"
39           + lib.optionalString (!enableQt) "-sdl"
40           + lib.optionalString forceWayland "-wayland";
41   version = "1.17.1";
43   src = fetchFromGitHub {
44     owner = "hrydgard";
45     repo = "ppsspp";
46     rev = "v${finalAttrs.version}";
47     fetchSubmodules = true;
48     hash = "sha256-I84zJqEE1X/eo/ukeGA2iZe3lWKvilk+RNGUzl2wZXY=";
49   };
51   postPatch = ''
52     substituteInPlace git-version.cmake --replace unknown ${finalAttrs.src.rev}
53     substituteInPlace UI/NativeApp.cpp --replace /usr/share $out/share
54   '';
56   nativeBuildInputs = [
57     cmake
58     copyDesktopItems
59     makeWrapper
60     pkg-config
61     python3
62   ]
63   ++ lib.optionals enableQt [ wrapQtAppsHook ];
65   buildInputs = [
66     SDL2
67     glew
68     libzip
69     zlib
70   ]
71   ++ lib.optionals useSystemFfmpeg [
72     ffmpeg
73   ]
74   ++ lib.optionals useSystemSnappy [
75     snappy
76   ]
77   ++ lib.optionals enableQt [
78     qtbase
79     qtmultimedia
80   ]
81   ++ lib.optionals enableVulkan [ vulkan-loader ]
82   ++ lib.optionals vulkanWayland [ wayland libffi ];
84   cmakeFlags = [
85     (lib.cmakeBool "HEADLESS" (!enableQt))
86     (lib.cmakeBool "USE_SYSTEM_FFMPEG" useSystemFfmpeg)
87     (lib.cmakeBool "USE_SYSTEM_LIBZIP" true)
88     (lib.cmakeBool "USE_SYSTEM_SNAPPY" useSystemSnappy)
89     (lib.cmakeBool "USE_WAYLAND_WSI" vulkanWayland)
90     (lib.cmakeBool "USING_QT_UI" enableQt)
91     (lib.cmakeFeature "OpenGL_GL_PREFERENCE" "GLVND")
92   ];
94   desktopItems = [
95     (makeDesktopItem {
96       desktopName = "PPSSPP";
97       name = "ppsspp";
98       exec = "ppsspp";
99       icon = "ppsspp";
100       comment = "Play PSP games on your computer";
101       categories = [ "Game" "Emulator" ];
102     })
103   ];
105   installPhase =
106     lib.concatStringsSep "\n" ([
107       ''runHook preInstall''
108     ]
109     ++ [
110       ''mkdir -p $out/share/{applications,ppsspp/bin,icons}''
111     ]
112     ++ (if enableQt then [
113       ''install -Dm555 PPSSPPQt $out/share/ppsspp/bin/''
114       ] else [
115         ''install -Dm555 PPSSPPHeadless $out/share/ppsspp/bin/''
116         ''makeWrapper $out/share/ppsspp/bin/PPSSPPHeadless $out/bin/ppsspp-headless''
117         ''install -Dm555 PPSSPPSDL $out/share/ppsspp/bin/''
118       ])
119     ++ [
120       ''mv assets $out/share/ppsspp''
121       ''mv ../icons/hicolor $out/share/icons''
122     ]
123     ++ [
124       ''runHook postInstall''
125     ]);
127   postFixup =
128     let
129       wrapperArgs =
130         lib.concatStringsSep " "
131           (lib.optionals enableVulkan [
132             "--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ vulkan-loader ]}"
133           ] ++ lib.optionals (!enableQt) [
134             "--set SDL_VIDEODRIVER ${if forceWayland then "wayland" else "x11"}"
135           ]);
136       binToBeWrapped = if enableQt then "PPSSPPQt" else "PPSSPPSDL";
137     in
138       ''makeWrapper $out/share/ppsspp/bin/${binToBeWrapped} $out/bin/ppsspp ${wrapperArgs}'';
140   meta = {
141     homepage = "https://www.ppsspp.org/";
142     description = "HLE Playstation Portable emulator, written in C++ ("
143                   + (if enableQt then "Qt" else "SDL + headless") + ")";
144     longDescription = ''
145       PPSSPP is a PSP emulator, which means that it can run games and other
146       software that was originally made for the Sony PSP.
148       The PSP had multiple types of software. The two most common are native PSP
149       games on UMD discs and downloadable games (that were stored in the
150       directory PSP/GAME on the "memory stick"). But there were also UMD Video
151       discs, and PS1 games that could run in a proprietary emulator. PPSSPP does
152       not run those.
153     '';
154     license = lib.licenses.gpl2Plus;
155     maintainers = [ lib.maintainers.AndersonTorres ];
156     mainProgram = "ppsspp";
157     platforms = lib.platforms.linux;
158   };