nixpkgs/pkgs/by-name/ce/cemu/package.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

181 lines
4.0 KiB
Nix
Raw Normal View History

{
lib,
SDL2,
addDriverRunpath,
boost,
cmake,
cubeb,
curl,
fetchFromGitHub,
fmt_9,
gamemode,
glm,
glslang,
gtk3,
hidapi,
imgui,
libXrender,
libpng,
libusb1,
libzip,
nasm,
ninja,
nix-update-script,
pkg-config,
pugixml,
rapidjson,
stdenv,
2024-06-17 19:59:40 +00:00
testers,
vulkan-headers,
vulkan-loader,
wayland,
wayland-scanner,
wrapGAppsHook3,
wxGTK32,
zarchive,
2022-10-31 20:01:48 +00:00
}:
let
# cemu doesn't build with imgui 1.90.2 or newer:
# error: 'struct ImGuiIO' has no member named 'ImeWindowHandle'
imgui' = imgui.overrideAttrs rec {
version = "1.90.1";
src = fetchFromGitHub {
owner = "ocornut";
repo = "imgui";
rev = "v${version}";
hash = "sha256-gf47uLeNiXQic43buB5ZnMqiotlUfIyAsP+3H7yJuFg=";
};
};
2024-11-05 16:42:32 +00:00
in
stdenv.mkDerivation (finalAttrs: {
2022-10-31 20:01:48 +00:00
pname = "cemu";
2024-11-14 12:36:16 +00:00
version = "2.4";
2022-10-31 20:01:48 +00:00
src = fetchFromGitHub {
owner = "cemu-project";
repo = "Cemu";
rev = "v${finalAttrs.version}";
2024-11-14 12:36:16 +00:00
hash = "sha256-JBd5ntU1fFDvQpNbfP63AQANzuQTdfd4dfB29/BN5LM=";
2022-10-31 20:01:48 +00:00
};
patches = [
# glslangTargets want SPIRV-Tools-opt to be defined:
# > The following imported targets are referenced, but are missing:
# > SPIRV-Tools-opt
./0000-spirv-tools-opt-cmakelists.patch
2024-11-05 16:42:32 +00:00
./0001-glslang-cmake-target.patch
2022-10-31 20:01:48 +00:00
];
nativeBuildInputs = [
SDL2
addDriverRunpath
wrapGAppsHook3
2022-10-31 20:01:48 +00:00
cmake
nasm
ninja
2022-10-31 20:01:48 +00:00
pkg-config
wxGTK32
wayland-scanner
2022-10-31 20:01:48 +00:00
];
buildInputs = [
SDL2
boost
cubeb
curl
fmt_9
glm
glslang
2022-10-31 20:01:48 +00:00
gtk3
2023-08-27 06:28:35 +00:00
hidapi
imgui'
2022-10-31 20:01:48 +00:00
libpng
2023-11-05 22:34:28 +00:00
libusb1
2022-10-31 20:01:48 +00:00
libzip
libXrender
pugixml
rapidjson
vulkan-headers
2022-12-16 08:29:33 +00:00
wayland
2022-10-31 20:01:48 +00:00
wxGTK32
zarchive
];
cmakeFlags = [
(lib.cmakeFeature "CMAKE_C_FLAGS_RELEASE" "-DNDEBUG")
(lib.cmakeFeature "CMAKE_CXX_FLAGS_RELEASE" "-DNDEBUG")
(lib.cmakeBool "ENABLE_VCPKG" false)
(lib.cmakeBool "ENABLE_FERAL_GAMEMODE" true)
# PORTABLE: "All data created and maintained by Cemu will be in
# the directory where the executable file is located"
(lib.cmakeBool "PORTABLE" false)
2022-10-31 20:01:48 +00:00
];
strictDeps = true;
2024-11-05 16:42:32 +00:00
preConfigure =
let
tag = lib.splitString "." (lib.last (lib.splitString "-" finalAttrs.version));
majorv = builtins.elemAt tag 0;
minorv = builtins.elemAt tag 1;
in
''
rm -rf dependencies/imgui
# cemu expects imgui source code, not just header files
ln -s ${imgui'.src} dependencies/imgui
substituteInPlace CMakeLists.txt --replace-fail "EMULATOR_VERSION_MAJOR \"0\"" "EMULATOR_VERSION_MAJOR \"${majorv}\""
substituteInPlace CMakeLists.txt --replace-fail "EMULATOR_VERSION_MINOR \"0\"" "EMULATOR_VERSION_MINOR \"${minorv}\""
substituteInPlace dependencies/gamemode/lib/gamemode_client.h --replace-fail "libgamemode.so.0" "${gamemode.lib}/lib/libgamemode.so.0"
'';
2022-10-31 20:01:48 +00:00
installPhase = ''
runHook preInstall
install -Dm755 ../bin/Cemu_release $out/bin/Cemu
ln -s $out/bin/Cemu $out/bin/cemu
mkdir -p $out/share/applications
substitute ../dist/linux/info.cemu.Cemu.desktop $out/share/applications/info.cemu.Cemu.desktop \
--replace "Exec=Cemu" "Exec=$out/bin/Cemu"
install -Dm644 ../dist/linux/info.cemu.Cemu.metainfo.xml -t $out/share/metainfo
install -Dm644 ../src/resource/logo_icon.png $out/share/icons/hicolor/128x128/apps/info.cemu.Cemu.png
runHook postInstall
'';
2024-11-05 16:42:32 +00:00
preFixup =
let
libs = [ vulkan-loader ] ++ cubeb.passthru.backendLibs;
in
''
gappsWrapperArgs+=(
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath libs}"
)
'';
2022-10-31 20:01:48 +00:00
passthru = {
updateScript = nix-update-script { };
2024-06-17 19:59:40 +00:00
tests = {
version = testers.testVersion {
package = finalAttrs.finalPackage;
};
};
};
meta = {
description = "Software to emulate Wii U games and applications on PC";
2022-10-31 20:01:48 +00:00
homepage = "https://cemu.info";
license = lib.licenses.mpl20;
mainProgram = "cemu";
2024-11-05 16:42:32 +00:00
maintainers = with lib.maintainers; [
zhaofengli
baduhai
AndersonTorres
];
platforms = [ "x86_64-linux" ];
2022-10-31 20:01:48 +00:00
};
})