Merge pull request #228872 from K900/weird-fruit

yuzu: update, switch to qt6, clean up, etc
This commit is contained in:
Linus Heckemann 2023-05-10 11:57:02 +02:00 committed by GitHub
commit cf4f8bfe60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 179 additions and 164 deletions

View file

@ -1,45 +1,68 @@
{ branch ? "mainline"
, libsForQt5
, qt6Packages
, fetchFromGitHub
, fetchgit
, fetchurl
, fetchzip
, runCommand
, gnutar
}:
let
# Mirror of https://api.yuzu-emu.org/gamedb, last updated 2022-08-13
# Please make sure to update this when updating yuzu!
sources = import ./sources.nix;
compat-list = fetchurl {
name = "yuzu-compat-list";
url = "https://raw.githubusercontent.com/flathub/org.yuzu_emu.yuzu/d83401d2ee3fd5e1922e31baed1f3bdb1c0f036c/compatibility_list.json";
sha256 = "sha256-anOmO7NscHDsQxT03+YbJEyBkXjhcSVGgKpDwt//GHw=";
url = "https://raw.githubusercontent.com/flathub/org.yuzu_emu.yuzu/${sources.compatList.rev}/compatibility_list.json";
hash = sources.compatList.hash;
};
mainlineSrc = fetchFromGitHub {
owner = "yuzu-emu";
repo = "yuzu-mainline";
rev = "mainline-0-${sources.mainline.version}";
hash = sources.mainline.hash;
fetchSubmodules = true;
};
# The mirror repo for early access builds is missing submodule info,
# but the Windows distributions include a source tarball, which in turn
# includes the full git metadata. So, grab that and rehydrate it.
# This has the unfortunate side effect of requiring two FODs, one
# for the Windows download and one for the full repo with submodules.
eaZip = fetchzip {
name = "yuzu-ea-windows-dist";
url = "https://github.com/pineappleEA/pineapple-src/releases/download/EA-${sources.ea.version}/Windows-Yuzu-EA-${sources.ea.version}.zip";
hash = sources.ea.distHash;
};
eaGitSrc = runCommand "yuzu-ea-dist-unpacked" {
src = eaZip;
nativeBuildInputs = [ gnutar ];
}
''
mkdir $out
tar xf $src/*.tar.xz --directory=$out --strip-components=1
'';
eaSrcRehydrated = fetchgit {
url = eaGitSrc;
fetchSubmodules = true;
hash = sources.ea.fullHash;
};
in {
mainline = libsForQt5.callPackage ./generic.nix rec {
pname = "yuzu-mainline";
version = "1245";
src = fetchFromGitHub {
owner = "yuzu-emu";
repo = "yuzu-mainline";
rev = "mainline-0-${version}";
sha256 = "sha256-lWXlY1KQC067MvCRUFhmr0c7KDrHDuwJOhIWMKw1f+A=";
fetchSubmodules = true;
};
inherit branch compat-list;
mainline = qt6Packages.callPackage ./generic.nix {
branch = "mainline";
version = sources.mainline.version;
src = mainlineSrc;
inherit compat-list;
};
early-access = libsForQt5.callPackage ./generic.nix rec {
pname = "yuzu-ea";
version = "2945";
src = fetchFromGitHub {
owner = "pineappleEA";
repo = "pineapple-src";
rev = "EA-${version}";
sha256 = "sha256-/051EtQxhB5oKH/JxZZ2AjnxOBcRxCBIwd4Qr8lq7Ok=";
fetchSubmodules = true;
};
inherit branch compat-list;
early-access = qt6Packages.callPackage ./generic.nix {
branch = "early-access";
version = sources.ea.version;
src = eaSrcRehydrated;
inherit compat-list;
};
}.${branch}

View file

@ -1,22 +1,25 @@
{ pname
, version
{ version
, src
, branch
, compat-list
, lib
, stdenv
, runCommandLocal
, substituteAll
, wrapQtAppsHook
, alsa-lib
, boost
, catch2
, catch2_3
, cmake
, cpp-jwt
, cubeb
, discord-rpc
, doxygen
, enet
, ffmpeg
, fmt_8
, fmt
, glslang
, httplib
, inih
, libjack2
, libopus
, libpulseaudio
@ -29,7 +32,9 @@
, pkg-config
, python3
, qtbase
, qtmultimedia
, qttools
, qtwayland
, qtwebengine
, rapidjson
, SDL2
@ -42,8 +47,10 @@
, zstd
}:
stdenv.mkDerivation rec {
inherit pname version src;
stdenv.mkDerivation {
pname = "yuzu-${branch}";
inherit version src;
nativeBuildInputs = [
cmake
@ -57,49 +64,64 @@ stdenv.mkDerivation rec {
buildInputs = [
alsa-lib
boost
catch2
catch2_3
cpp-jwt
cubeb
discord-rpc
# intentionally omitted: dynarmic - prefer vendored version for compatibility
enet
ffmpeg
fmt_8
fmt
glslang
httplib
inih
libjack2
libopus
libpulseaudio
libusb1
libva
libzip
# intentionally omitted: LLVM - heavy, only used for stack traces in the debugger
lz4
nlohmann_json
qtbase
qtmultimedia
qttools
qtwayland
qtwebengine
rapidjson
SDL2
sndio
speexdsp
udev
vulkan-headers
# intentionally omitted: xbyak - prefer vendored version for compatibility
zlib
zstd
];
doCheck = true;
# 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;
# -Werror causes build failures for deprecation warnings introduced by transitive dependency updates
postPatch = ''
sed -i '/-Werror/d' src/common/CMakeLists.txt
'';
cmakeFlags = [
"-DYUZU_USE_BUNDLED_QT=OFF"
"-DYUZU_USE_BUNDLED_FFMPEG=OFF"
"-DYUZU_USE_BUNDLED_OPUS=OFF"
"-DYUZU_USE_EXTERNAL_SDL2=OFF"
# actually has a noticeable performance impact
"-DYUZU_ENABLE_LTO=ON"
# build with qt6
"-DENABLE_QT6=ON"
"-DENABLE_QT_TRANSLATION=ON"
# use system libraries
"-DYUZU_USE_EXTERNAL_SDL2=OFF"
"-DYUZU_USE_EXTERNAL_VULKAN_HEADERS=OFF"
# 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
@ -107,21 +129,17 @@ stdenv.mkDerivation rec {
"-DENABLE_COMPATIBILITY_LIST_DOWNLOAD=OFF" # We provide this deterministically
];
# Fixes vulkan detection.
# FIXME: patchelf --add-rpath corrupts the binary for some reason, investigate
qtWrapperArgs = [
# Fixes vulkan detection
"--prefix LD_LIBRARY_PATH : ${vulkan-loader}/lib"
# Without yuzu doesnt start on wayland. See https://github.com/yuzu-emu/yuzu/issues/6088
"--set QT_QPA_PLATFORM xcb"
];
preConfigure = ''
# This prevents a check for submodule directories.
rm -f .gitmodules
# see https://github.com/NixOS/nixpkgs/issues/114044, setting this through cmakeFlags does not work.
cmakeFlagsArray+=(
"-DTITLE_BAR_FORMAT_IDLE=yuzu ${branch} ${version}"
"-DTITLE_BAR_FORMAT_RUNNING=yuzu ${branch} ${version} | {3}"
"-DTITLE_BAR_FORMAT_IDLE=yuzu | ${branch} ${version} (nixpkgs) {}"
"-DTITLE_BAR_FORMAT_RUNNING=yuzu | ${branch} ${version} (nixpkgs) | {}"
)
'';
@ -130,12 +148,7 @@ stdenv.mkDerivation rec {
ln -sf ${compat-list} ./dist/compatibility_list/compatibility_list.json
'';
passthru.updateScript = runCommandLocal "yuzu-${branch}-updateScript" {
script = substituteAll {
src = ./update.sh;
inherit branch;
};
} "install -Dm755 $script $out";
passthru.updateScript = ./update.sh;
meta = with lib; {
homepage = "https://yuzu-emu.org";
@ -143,8 +156,8 @@ stdenv.mkDerivation rec {
description = "The ${branch} branch of an experimental Nintendo Switch emulator written in C++";
longDescription = ''
An experimental Nintendo Switch emulator written in C++.
Using the mainline branch is recommanded for general usage.
Using the early-access branch is recommanded if you would like to try out experimental features, with a cost of stability.
Using the mainline branch is recommended for general usage.
Using the early-access branch is recommended if you would like to try out experimental features, with a cost of stability.
'';
mainProgram = "yuzu";
platforms = [ "x86_64-linux" ];
@ -158,6 +171,7 @@ stdenv.mkDerivation rec {
ivar
joshuafern
sbruder
k900
];
};
}

View file

@ -0,0 +1,19 @@
# Generated by ./update.sh - do not update manually!
# Last updated: 2023-05-05
{
compatList = {
rev = "773d28cbc699427c8baa427452d7b229920eec59";
hash = "sha256:1hdsza3wf9a0yvj6h55gsl7xqvhafvbz1i8paz9kg7l49b0gnlh1";
};
mainline = {
version = "1421";
hash = "sha256:1ldxframs7a8rmna9ymyx20n89594q0d1266kr7ah8yvh1gp04r3";
};
ea = {
version = "3557";
distHash = "sha256:0bddx5d88cfaaqbzr59w9kqjjsf9xvgvdn1g0l9w3ifr9zc2vlwr";
fullHash = "sha256:0w1ji3a8iridh4dpyal8lscgwddf9pwz1pfigksmvbn8mm9d9xwl";
};
}

View file

@ -1,105 +1,66 @@
#! /usr/bin/env nix-shell
#! nix-shell -I nixpkgs=./. -i bash -p nix nix-prefetch-git coreutils curl jq gnused
#! nix-shell -i bash -p nix nix-prefetch-git gnutar curl jq
set -euo pipefail
# Will be replaced with the actual branch when running this from passthru.updateScript
BRANCH="@branch@"
DEFAULT_NIX="$(dirname "${BASH_SOURCE[@]}")/default.nix"
cd "$(dirname "$(readlink -f "$0")")"
if [[ "$(basename "$PWD")" = "yuzu" ]]; then
echo "error: Script must be ran from nixpkgs's root directory for compatibility with the maintainer script"
exit 1
fi
updateBranch() {
local branch attribute oldVersion oldHash newVersion newHash
branch="$1"
attribute="yuzu-$branch"
[[ "$branch" = "early-access" ]] && attribute="yuzu-ea" # Attribute path doesnt match the branch name
oldVersion="$(nix eval --raw -f "./default.nix" "$attribute".version)"
oldHash="$(nix eval --raw -f "./default.nix" "$attribute".src.drvAttrs.outputHash)"
if [[ "$branch" = "mainline" ]]; then
newVersion="$(curl -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "https://api.github.com/repos/yuzu-emu/yuzu-mainline/releases?per_page=1" \
| jq -r '.[0].name' | cut -d" " -f2)"
elif [[ "$branch" = "early-access" ]]; then
newVersion="$(curl -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "https://api.github.com/repos/pineappleEA/pineapple-src/releases?per_page=2" \
| jq -r '.[].tag_name' | grep '^EA-[0-9]*' | head -n1 | cut -d"-" -f2 | cut -d" " -f1)"
fi
if [[ "${oldVersion}" = "${newVersion}" ]]; then
echo "$attribute is already up to date."
return
else
echo "$attribute: ${oldVersion} -> ${newVersion}"
fi
echo " fetching source code to generate hash..."
if [[ "$branch" = "mainline" ]]; then
newHash="$(nix-prefetch-git --quiet --fetch-submodules --rev "mainline-0-${newVersion}" "https://github.com/yuzu-emu/yuzu-mainline" | jq -r '.sha256')"
elif [[ "$branch" = "early-access" ]]; then
newHash="$(nix-prefetch-git --quiet --fetch-submodules --rev "EA-${newVersion}" "https://github.com/pineappleEA/pineapple-src" | jq -r '.sha256')"
fi
newHash="$(nix hash to-sri --type sha256 "${newHash}")"
sed -i "s,${oldVersion},${newVersion}," "$DEFAULT_NIX"
sed -i "s,${oldHash},${newHash},g" "$DEFAULT_NIX"
echo " successfully updated $attribute. new hash: $newHash"
log() {
tput bold
echo "#" "$@"
tput sgr0
}
updateCompatibilityList() {
local latestRevision oldUrl newUrl oldHash newHash oldDate newDate
latestRevision="$(curl -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "https://api.github.com/repos/flathub/org.yuzu_emu.yuzu/commits/master" | jq -r '.sha')"
alias curl='curl -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"}'
oldUrl="$(sed -n '/yuzu-compat-list/,/url/p' "$DEFAULT_NIX" | tail -n1 | cut -d'"' -f2)"
newUrl="https://raw.githubusercontent.com/flathub/org.yuzu_emu.yuzu/${latestRevision}/compatibility_list.json"
log "Updating compatibility list..."
compatListRev="$(curl "https://api.github.com/repos/flathub/org.yuzu_emu.yuzu/commits/master" | jq -r '.sha')"
oldDate="$(sed -n '/last updated.*/p' "$DEFAULT_NIX" | rev | cut -d' ' -f1 | rev)"
newDate="$(curl -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "https://api.github.com/repos/flathub/org.yuzu_emu.yuzu/commits/${latestRevision}" \
| jq -r '.commit.committer.date' | cut -d'T' -f1)"
log "Downloading rev: ${compatListRev}"
compatListHash="$(nix-prefetch-url "https://raw.githubusercontent.com/flathub/org.yuzu_emu.yuzu/${compatListRev}/compatibility_list.json")"
oldHash="$(sed -n '/yuzu-compat-list/,/sha256/p' "$DEFAULT_NIX" | tail -n1 | cut -d'"' -f2)"
newHash="$(nix hash to-sri --type sha256 "$(nix-prefetch-url --quiet "$newUrl")")"
log "Updating mainline..."
mainlineVersion="$(curl "https://api.github.com/repos/yuzu-emu/yuzu-mainline/releases?per_page=1" | jq -r '.[0].name' | cut -d" " -f2)"
if [[ "$oldHash" = "$newHash" ]]; then
echo "compatibility_list is already up to date."
return
else
echo "compatibility_list: $oldDate -> $newDate"
fi
log "Downloading version: ${mainlineVersion}"
mainlineHash="$(nix-prefetch-git --fetch-submodules --rev "mainline-0-${mainlineVersion}" "https://github.com/yuzu-emu/yuzu-mainline" | jq -r '.sha256')"
sed -i "s,${oldUrl},${newUrl},g" "$DEFAULT_NIX"
sed -i "s,${oldHash},${newHash},g" "$DEFAULT_NIX"
sed -i "s,${oldDate},${newDate},g" "$DEFAULT_NIX"
echo " successfully updated compatibility_list. new hash: $newHash"
log "Updating early access..."
eaVersion="$(curl "https://api.github.com/repos/pineappleEA/pineapple-src/releases?per_page=1" | jq -r '.[0].tag_name' | cut -d"-" -f2)"
log "Downloading dist version: ${eaVersion}"
fetched="$(nix-prefetch-url --unpack --print-path "https://github.com/pineappleEA/pineapple-src/releases/download/EA-${eaVersion}/Windows-Yuzu-EA-${eaVersion}.zip")"
eaDistHash="$(echo "${fetched}" | head -n1)"
eaDist="$(echo "${fetched}" | tail -n1)"
eaDistUnpacked="$(mktemp -d)"
trap 'rm -rf "$eaDistUnpacked"' EXIT
log "Unpacking dist..."
tar xf "$eaDist"/*.tar.xz --directory="$eaDistUnpacked" --strip-components=1
log "Rehydrating..."
eaFullHash="$(nix-prefetch-git --fetch-submodules "$eaDistUnpacked" | jq -r '.sha256')"
cat >sources.nix <<EOF
# Generated by ./update.sh - do not update manually!
# Last updated: $(date +%F)
{
compatList = {
rev = "$compatListRev";
hash = "sha256:$compatListHash";
};
mainline = {
version = "$mainlineVersion";
hash = "sha256:$mainlineHash";
};
ea = {
version = "$eaVersion";
distHash = "sha256:$eaDistHash";
fullHash = "sha256:$eaFullHash";
};
}
if [[ "$BRANCH" = "mainline" ]] || [[ "$BRANCH" = "early-access" ]]; then
updateBranch "$BRANCH"
updateCompatibilityList
else # Script is not ran from passthru.updateScript
if (( $# == 0 )); then
updateBranch "mainline"
updateBranch "early-access"
fi
while (( "$#" > 0 )); do
case "$1" in
mainline|yuzu-mainline)
updateBranch "mainline"
;;
early-access|yuzu-early-access|ea|yuzu-ea)
updateBranch "early-access"
;;
*)
echo "error: invalid branch: $1."
echo "usage: $(basename "$0") [mainline|early-access]"
exit 1
;;
esac
shift
done
updateCompatibilityList
fi
EOF

View file

@ -2467,14 +2467,12 @@ with pkgs;
### APPLICATIONS/EMULATORS/YUZU
yuzu-mainline = import ../applications/emulators/yuzu {
yuzu-mainline = qt6Packages.callPackage ../applications/emulators/yuzu {
branch = "mainline";
inherit libsForQt5 fetchFromGitHub fetchurl;
};
yuzu-early-access = import ../applications/emulators/yuzu {
yuzu-early-access = qt6Packages.callPackage ../applications/emulators/yuzu {
branch = "early-access";
inherit libsForQt5 fetchFromGitHub fetchurl;
};
### APPLICATIONS/EMULATORS/COMMANDERX16