python312Packages.yoda: 2.0.1 -> 2.0.2
[NixPkgs.git] / pkgs / by-name / ce / cemu / package.nix
bloba188326d9de43d111ff4fcfbf063f08d02e533a3
2   lib,
3   SDL2,
4   addDriverRunpath,
5   boost,
6   cmake,
7   cubeb,
8   curl,
9   fetchFromGitHub,
10   fmt_9,
11   gamemode,
12   glm,
13   glslang,
14   gtk3,
15   hidapi,
16   imgui,
17   libXrender,
18   libpng,
19   libusb1,
20   libzip,
21   nasm,
22   ninja,
23   nix-update-script,
24   pkg-config,
25   pugixml,
26   rapidjson,
27   stdenv,
28   testers,
29   vulkan-headers,
30   vulkan-loader,
31   wayland,
32   wayland-scanner,
33   wrapGAppsHook3,
34   wxGTK32,
35   zarchive,
38 let
39   # cemu doesn't build with imgui 1.90.2 or newer:
40   # error: 'struct ImGuiIO' has no member named 'ImeWindowHandle'
41   imgui' = imgui.overrideAttrs rec {
42     version = "1.90.1";
43     src = fetchFromGitHub {
44       owner = "ocornut";
45       repo = "imgui";
46       rev = "v${version}";
47       hash = "sha256-gf47uLeNiXQic43buB5ZnMqiotlUfIyAsP+3H7yJuFg=";
48     };
49   };
51 stdenv.mkDerivation (finalAttrs: {
52   pname = "cemu";
53   version = "2.4";
55   src = fetchFromGitHub {
56     owner = "cemu-project";
57     repo = "Cemu";
58     rev = "v${finalAttrs.version}";
59     hash = "sha256-JBd5ntU1fFDvQpNbfP63AQANzuQTdfd4dfB29/BN5LM=";
60   };
62   patches = [
63     # glslangTargets want SPIRV-Tools-opt to be defined:
64     # > The following imported targets are referenced, but are missing:
65     # > SPIRV-Tools-opt
66     ./0000-spirv-tools-opt-cmakelists.patch
67     ./0001-glslang-cmake-target.patch
68   ];
70   nativeBuildInputs = [
71     SDL2
72     addDriverRunpath
73     wrapGAppsHook3
74     cmake
75     nasm
76     ninja
77     pkg-config
78     wxGTK32
79     wayland-scanner
80   ];
82   buildInputs = [
83     SDL2
84     boost
85     cubeb
86     curl
87     fmt_9
88     glm
89     glslang
90     gtk3
91     hidapi
92     imgui'
93     libpng
94     libusb1
95     libzip
96     libXrender
97     pugixml
98     rapidjson
99     vulkan-headers
100     wayland
101     wxGTK32
102     zarchive
103   ];
105   cmakeFlags = [
106     (lib.cmakeFeature "CMAKE_C_FLAGS_RELEASE" "-DNDEBUG")
107     (lib.cmakeFeature "CMAKE_CXX_FLAGS_RELEASE" "-DNDEBUG")
108     (lib.cmakeBool "ENABLE_VCPKG" false)
109     (lib.cmakeBool "ENABLE_FERAL_GAMEMODE" true)
111     # PORTABLE: "All data created and maintained by Cemu will be in
112     # the directory where the executable file is located"
113     (lib.cmakeBool "PORTABLE" false)
114   ];
116   strictDeps = true;
118   preConfigure =
119     let
120       tag = lib.splitString "." (lib.last (lib.splitString "-" finalAttrs.version));
121       majorv = builtins.elemAt tag 0;
122       minorv = builtins.elemAt tag 1;
123     in
124     ''
125       rm -rf dependencies/imgui
126       # cemu expects imgui source code, not just header files
127       ln -s ${imgui'.src} dependencies/imgui
128       substituteInPlace CMakeLists.txt --replace-fail "EMULATOR_VERSION_MAJOR \"0\"" "EMULATOR_VERSION_MAJOR \"${majorv}\""
129       substituteInPlace CMakeLists.txt --replace-fail "EMULATOR_VERSION_MINOR \"0\"" "EMULATOR_VERSION_MINOR \"${minorv}\""
130       substituteInPlace dependencies/gamemode/lib/gamemode_client.h --replace-fail "libgamemode.so.0" "${gamemode.lib}/lib/libgamemode.so.0"
131     '';
133   installPhase = ''
134     runHook preInstall
136     install -Dm755 ../bin/Cemu_release $out/bin/Cemu
137     ln -s $out/bin/Cemu $out/bin/cemu
139     mkdir -p $out/share/applications
140     substitute ../dist/linux/info.cemu.Cemu.desktop $out/share/applications/info.cemu.Cemu.desktop \
141       --replace "Exec=Cemu" "Exec=$out/bin/Cemu"
143     install -Dm644 ../dist/linux/info.cemu.Cemu.metainfo.xml -t $out/share/metainfo
144     install -Dm644 ../src/resource/logo_icon.png $out/share/icons/hicolor/128x128/apps/info.cemu.Cemu.png
146     runHook postInstall
147   '';
149   preFixup =
150     let
151       libs = [ vulkan-loader ] ++ cubeb.passthru.backendLibs;
152     in
153     ''
154       gappsWrapperArgs+=(
155         --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath libs}"
156       )
157     '';
159   passthru = {
160     updateScript = nix-update-script { };
161     tests = {
162       version = testers.testVersion {
163         package = finalAttrs.finalPackage;
164       };
165     };
166   };
168   meta = {
169     description = "Software to emulate Wii U games and applications on PC";
170     homepage = "https://cemu.info";
171     license = lib.licenses.mpl20;
172     mainProgram = "cemu";
173     maintainers = with lib.maintainers; [
174       zhaofengli
175       baduhai
176       AndersonTorres
177     ];
178     platforms = [ "x86_64-linux" ];
179   };