bottom: add gpu recognition, new apple sdk, refactor (#360568)
[NixPkgs.git] / pkgs / by-name / pr / prismlauncher / package.nix
blob03c1f042153067ceed2ec8ac911991d3606f3bb9
2   addDriverRunpath,
3   alsa-lib,
4   flite,
5   gamemode,
6   glfw3-minecraft,
7   jdk17,
8   jdk21,
9   jdk8,
10   kdePackages,
11   lib,
12   libGL,
13   libX11,
14   libXcursor,
15   libXext,
16   libXrandr,
17   libXxf86vm,
18   libjack2,
19   libpulseaudio,
20   libusb1,
21   mesa-demos,
22   openal,
23   pciutils,
24   pipewire,
25   prismlauncher-unwrapped,
26   stdenv,
27   symlinkJoin,
28   udev,
29   vulkan-loader,
30   xrandr,
32   additionalLibs ? [ ],
33   additionalPrograms ? [ ],
34   controllerSupport ? stdenv.hostPlatform.isLinux,
35   gamemodeSupport ? stdenv.hostPlatform.isLinux,
36   jdks ? [
37     jdk21
38     jdk17
39     jdk8
40   ],
41   msaClientID ? null,
42   textToSpeechSupport ? stdenv.hostPlatform.isLinux,
45 assert lib.assertMsg (
46   controllerSupport -> stdenv.hostPlatform.isLinux
47 ) "controllerSupport only has an effect on Linux.";
49 assert lib.assertMsg (
50   textToSpeechSupport -> stdenv.hostPlatform.isLinux
51 ) "textToSpeechSupport only has an effect on Linux.";
53 let
54   prismlauncher' = prismlauncher-unwrapped.override { inherit msaClientID gamemodeSupport; };
57 symlinkJoin {
58   name = "prismlauncher-${prismlauncher'.version}";
60   paths = [ prismlauncher' ];
62   nativeBuildInputs = [ kdePackages.wrapQtAppsHook ];
64   buildInputs =
65     [
66       kdePackages.qtbase
67       kdePackages.qtsvg
68     ]
69     ++ lib.optional (
70       lib.versionAtLeast kdePackages.qtbase.version "6" && stdenv.hostPlatform.isLinux
71     ) kdePackages.qtwayland;
73   postBuild = ''
74     wrapQtAppsHook
75   '';
77   qtWrapperArgs =
78     let
79       runtimeLibs =
80         [
81           (lib.getLib stdenv.cc.cc)
82           ## native versions
83           glfw3-minecraft
84           openal
86           ## openal
87           alsa-lib
88           libjack2
89           libpulseaudio
90           pipewire
92           ## glfw
93           libGL
94           libX11
95           libXcursor
96           libXext
97           libXrandr
98           libXxf86vm
100           udev # oshi
102           vulkan-loader # VulkanMod's lwjgl
103         ]
104         ++ lib.optional textToSpeechSupport flite
105         ++ lib.optional gamemodeSupport gamemode.lib
106         ++ lib.optional controllerSupport libusb1
107         ++ additionalLibs;
109       runtimePrograms = [
110         mesa-demos
111         pciutils # need lspci
112         xrandr # needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
113       ] ++ additionalPrograms;
115     in
116     [ "--prefix PRISMLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}" ]
117     ++ lib.optionals stdenv.hostPlatform.isLinux [
118       "--set LD_LIBRARY_PATH ${addDriverRunpath.driverLink}/lib:${lib.makeLibraryPath runtimeLibs}"
119       "--prefix PATH : ${lib.makeBinPath runtimePrograms}"
120     ];
122   meta = {
123     inherit (prismlauncher'.meta)
124       description
125       longDescription
126       homepage
127       changelog
128       license
129       maintainers
130       mainProgram
131       platforms
132       ;
133   };