diff --git a/modules/desktop/desktop-environment/config/mimeapps.list b/modules/desktop/desktop-environment/config/mimeapps.list index 372b9c6a..a547d02f 100644 --- a/modules/desktop/desktop-environment/config/mimeapps.list +++ b/modules/desktop/desktop-environment/config/mimeapps.list @@ -10,3 +10,4 @@ image/jpeg=org.photoqt.PhotoQt.desktop; image/png=org.photoqt.PhotoQt.desktop; text/x-java=nvim.desktop; x-scheme-handler/ror2mm=r2modman.desktop +x-scheme-handler/discord-712465656758665259=discord-712465656758665259.desktop diff --git a/pkgs/default.nix b/pkgs/default.nix index 27907d77..74657153 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -30,4 +30,6 @@ trash-d = pkgs.callPackage ./trash-d { inherit (inputs) trash-d-src; }; + + yuzu = pkgs.callPackage ./yuzu {}; } diff --git a/pkgs/yuzu/compat-list.nix b/pkgs/yuzu/compat-list.nix new file mode 100644 index 00000000..bd7cd4eb --- /dev/null +++ b/pkgs/yuzu/compat-list.nix @@ -0,0 +1,20 @@ +{ + stdenv, + fetchFromGitHub, + ... +}: +stdenv.mkDerivation { + pname = "yuzu-compatibility-list"; + version = "unstable-2024-02-26"; + + src = fetchFromGitHub { + owner = "flathub"; + repo = "org.yuzu_emu.yuzu"; + rev = "9c2032a3c7e64772a8112b77ed8b660242172068"; + hash = "sha256-ITh/W4vfC9w9t+TJnPeTZwWifnhTNKX54JSSdpgaoBk="; + }; + + buildCommand = '' + cp $src/compatibility_list.json $out + ''; +} diff --git a/pkgs/yuzu/default.nix b/pkgs/yuzu/default.nix new file mode 100644 index 00000000..d10d2d30 --- /dev/null +++ b/pkgs/yuzu/default.nix @@ -0,0 +1,17 @@ +{ + qt6Packages, + makeScopeWithSplicing', + generateSplicesForMkScope, + ... +}: +(makeScopeWithSplicing' { + otherSplices = generateSplicesForMkScope "yuzuPackages"; + f = self: + qt6Packages + // { + compat-list = self.callPackage ./compat-list.nix {}; + nx_tzdb = self.callPackage ./nx_tzdb.nix {}; + + mainline = self.callPackage ./mainline.nix {}; + }; +}).mainline diff --git a/pkgs/yuzu/mainline.nix b/pkgs/yuzu/mainline.nix new file mode 100644 index 00000000..ab7b6523 --- /dev/null +++ b/pkgs/yuzu/mainline.nix @@ -0,0 +1,183 @@ +{ + lib, + stdenv, + fetchFromGitHub, + nix-update-script, + wrapQtAppsHook, + autoconf, + boost, + catch2_3, + cmake, + compat-list, + cpp-jwt, + cubeb, + discord-rpc, + enet, + fmt, + glslang, + libopus, + libusb1, + libva, + lz4, + nlohmann_json, + nv-codec-headers-12, + nx_tzdb, + pkg-config, + qtbase, + qtmultimedia, + qttools, + qtwayland, + qtwebengine, + SDL2, + vulkan-headers, + vulkan-loader, + yasm, + zlib, + zstd, + ... +}: +stdenv.mkDerivation (finalAttrs: { + pname = "yuzu"; + version = "1727"; + + src = fetchFromGitHub { + owner = "yuzu-emu"; + repo = "yuzu-mainline"; + rev = "mainline-0-${finalAttrs.version}"; + hash = "sha256-DKIVXy3OGUfdw/mZtPzom40KU51CvXaV+KqRjQseDyk="; + fetchSubmodules = true; + }; + + nativeBuildInputs = [ + cmake + glslang + pkg-config + qttools + wrapQtAppsHook + ]; + + buildInputs = [ + # vulkan-headers must come first, so the older propagated versions + # don't get picked up by accident + vulkan-headers + + boost + catch2_3 + cpp-jwt + cubeb + discord-rpc + # intentionally omitted: dynarmic - prefer vendored version for compatibility + enet + + # vendored ffmpeg deps + autoconf + yasm + libva # for accelerated video decode on non-nvidia + nv-codec-headers-12 # for accelerated video decode on nvidia + # end vendored ffmpeg deps + + fmt + # intentionally omitted: gamemode - loaded dynamically at runtime + # intentionally omitted: httplib - upstream requires an older version than what we have + libopus + libusb1 + # intentionally omitted: LLVM - heavy, only used for stack traces in the debugger + lz4 + nlohmann_json + qtbase + qtmultimedia + qtwayland + qtwebengine + # intentionally omitted: renderdoc - heavy, developer only + SDL2 + # not packaged in nixpkgs: simpleini + # intentionally omitted: stb - header only libraries, vendor uses git snapshot + # not packaged in nixpkgs: vulkan-memory-allocator + # intentionally omitted: xbyak - prefer vendored version for compatibility + zlib + zstd + ]; + + # This changes `ir/opt` to `ir/var/empty` in `externals/dynarmic/src/dynarmic/CMakeLists.txt` + # making the build fail, as that path does not exist + dontFixCmake = true; + + cmakeFlags = [ + # actually has a noticeable performance impact + "-DYUZU_ENABLE_LTO=ON" + + # build with qt6 + "-DENABLE_QT6=ON" + "-DENABLE_QT_TRANSLATION=ON" + + # use system libraries + # NB: "external" here means "from the externals/ directory in the source", + # so "off" means "use system" + "-DYUZU_USE_EXTERNAL_SDL2=OFF" + "-DYUZU_USE_EXTERNAL_VULKAN_HEADERS=OFF" + + # don't use system ffmpeg, yuzu uses internal APIs + "-DYUZU_USE_BUNDLED_FFMPEG=ON" + + # don't check for missing submodules + "-DYUZU_CHECK_SUBMODULES=OFF" + + # enable some optional features + "-DYUZU_USE_QT_WEB_ENGINE=ON" + "-DYUZU_USE_QT_MULTIMEDIA=ON" + "-DUSE_DISCORD_PRESENCE=ON" + + # We dont want to bother upstream with potentially outdated compat reports + "-DYUZU_ENABLE_COMPATIBILITY_REPORTING=OFF" + "-DENABLE_COMPATIBILITY_LIST_DOWNLOAD=OFF" # We provide this deterministically + ]; + + # Does some handrolled SIMD + env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isx86_64 "-msse4.1"; + + # Fixes vulkan detection. + # FIXME: patchelf --add-rpath corrupts the binary for some reason, investigate + qtWrapperArgs = [ + "--prefix LD_LIBRARY_PATH : ${vulkan-loader}/lib" + ]; + + preConfigure = '' + # see https://github.com/NixOS/nixpkgs/issues/114044, setting this through cmakeFlags does not work. + cmakeFlagsArray+=( + "-DTITLE_BAR_FORMAT_IDLE=${finalAttrs.pname} | ${finalAttrs.version} (nixpkgs) {}" + "-DTITLE_BAR_FORMAT_RUNNING=${finalAttrs.pname} | ${finalAttrs.version} (nixpkgs) | {}" + ) + + # provide pre-downloaded tz data + mkdir -p build/externals/nx_tzdb + ln -s ${nx_tzdb} build/externals/nx_tzdb/nx_tzdb + ''; + + # This must be done after cmake finishes as it overwrites the file + postConfigure = '' + ln -sf ${compat-list} ./dist/compatibility_list/compatibility_list.json + ''; + + postInstall = '' + install -Dm444 $src/dist/72-yuzu-input.rules $out/lib/udev/rules.d/72-yuzu-input.rules + ''; + + passthru.updateScript = nix-update-script { + extraArgs = ["--version-regex" "mainline-0-(.*)"]; + }; + + meta = with lib; { + homepage = "https://yuzu-emu.org"; + changelog = "https://yuzu-emu.org/entry"; + description = "An experimental Nintendo Switch emulator written in C++"; + mainProgram = "yuzu"; + platforms = ["aarch64-linux" "x86_64-linux"]; + license = with licenses; [ + gpl3Plus + # Icons + asl20 + mit + cc0 + ]; + }; +}) diff --git a/pkgs/yuzu/nx_tzdb.nix b/pkgs/yuzu/nx_tzdb.nix new file mode 100644 index 00000000..a016f1af --- /dev/null +++ b/pkgs/yuzu/nx_tzdb.nix @@ -0,0 +1,21 @@ +{ + stdenv, + fetchurl, + unzip, + ... +}: +stdenv.mkDerivation rec { + pname = "nx_tzdb"; + version = "221202"; + + src = fetchurl { + url = "https://github.com/lat9nq/tzdb_to_nx/releases/download/${version}/${version}.zip"; + hash = "sha256-mRzW+iIwrU1zsxHmf+0RArU8BShAoEMvCz+McXFFK3c="; + }; + + nativeBuildInputs = [unzip]; + + buildCommand = '' + unzip $src -d $out + ''; +}