Skip to content

Commit

Permalink
feat(pkgs/yuzu-early-access): add it
Browse files Browse the repository at this point in the history
  • Loading branch information
wrvsrx committed Mar 16, 2024
1 parent 73af36b commit 6e364a9
Show file tree
Hide file tree
Showing 10 changed files with 311 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkgs/to-normal-packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ rec {
};
metacubexd = callPackage ./metacubexd { source = sources.metacubexd; };
yalantinglibs = callPackage ./yalantinglibs { source = sources.yalantinglibs; };
yuzu-early-access = (callPackage ./yuzu { source = sources.yuzu; }).early-access;

# my packages
giraffe-wallpaper = callIFD {
Expand Down
22 changes: 22 additions & 0 deletions pkgs/to-normal-packages/yuzu/compat-list.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
stdenv,
fetchFromGitHub,
unstableGitUpdater,
}:
stdenv.mkDerivation {
pname = "yuzu-compatibility-list";
version = "unstable-2024-02-14";

src = fetchFromGitHub {
owner = "flathub";
repo = "org.yuzu_emu.yuzu";
rev = "8ef2f834b7437101d855f49f719474613c6fdfda";
hash = "sha256-RGEx7xediERrBW7vFwmecE3tLCo81zhOIVMnWG+XVd8=";
};

buildCommand = ''
cp $src/compatibility_list.json $out
'';

passthru.updateScript = unstableGitUpdater { };
}
19 changes: 19 additions & 0 deletions pkgs/to-normal-packages/yuzu/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
qt6Packages,
makeScopeWithSplicing',
generateSplicesForMkScope,
source,
}:

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 { };
early-access = self.callPackage ./early-access { inherit source; };
};
}
7 changes: 7 additions & 0 deletions pkgs/to-normal-packages/yuzu/early-access/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{ mainline, source }:
mainline.overrideAttrs (old: {
inherit (source) pname version src;
meta = old.meta // {
description = old.meta.description + " - early access branch";
};
})
195 changes: 195 additions & 0 deletions pkgs/to-normal-packages/yuzu/mainline.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
{
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 = "1715";

src = fetchFromGitHub {
owner = "yuzu-emu";
repo = "yuzu-mainline";
rev = "mainline-0-${finalAttrs.version}";
hash = "sha256-ctmySxBLI/1/0ekvqOq+FsWq73iHa/awARtCgZ/ztXs=";
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 = "-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++";
longDescription = ''
An experimental Nintendo Switch emulator written in C++.
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" ];
license = with licenses; [
gpl3Plus
# Icons
asl20
mit
cc0
];
maintainers = with maintainers; [
ashley
ivar
joshuafern
sbruder
k900
];
};
})
23 changes: 23 additions & 0 deletions pkgs/to-normal-packages/yuzu/nx_tzdb.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
stdenv,
fetchurl,
unzip,
gitUpdater,
}:
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
'';

passthru.updateScript = gitUpdater { url = "https://github.com/lat9nq/tzdb_to_nx.git"; };
}
7 changes: 7 additions & 0 deletions pkgs/to-normal-packages/yuzu/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p nix-update
#shellcheck shell=bash
nix-update -u yuzuPackages.nx_tzdb "$@"
nix-update -u yuzuPackages.compat-list "$@"
nix-update -u yuzuPackages.mainline "$@"
nix-update -u yuzuPackages.early-access --override-filename pkgs/applications/emulators/yuzu/early-access/sources.nix "$@"
20 changes: 20 additions & 0 deletions pkgs/to-sources/_sources/generated.json
Original file line number Diff line number Diff line change
Expand Up @@ -643,5 +643,25 @@
"type": "github"
},
"version": "v0.3.0"
},
"yuzu": {
"cargoLocks": null,
"date": "2024-03-15",
"extract": null,
"name": "yuzu",
"passthru": null,
"pinned": false,
"src": {
"deepClone": false,
"fetchSubmodules": true,
"leaveDotGit": false,
"name": null,
"owner": "yuzu-mirror",
"repo": "yuzu",
"rev": "4ad024d2fc9d12a131d69deb1b07b7be36dc4f17",
"sha256": "sha256-YxPbzqgQ8Hh2evs+57LSnvOWrVIm1ukaCWzlzB6otk4=",
"type": "github"
},
"version": "4ad024d2fc9d12a131d69deb1b07b7be36dc4f17"
}
}
12 changes: 12 additions & 0 deletions pkgs/to-sources/_sources/generated.nix
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,16 @@
sha256 = "sha256-Su3mnC7hsw0T0u6HfsnYAwXml2T7CABySv7a18+KnK0=";
};
};
yuzu = {
pname = "yuzu";
version = "4ad024d2fc9d12a131d69deb1b07b7be36dc4f17";
src = fetchFromGitHub {
owner = "yuzu-mirror";
repo = "yuzu";
rev = "4ad024d2fc9d12a131d69deb1b07b7be36dc4f17";
fetchSubmodules = true;
sha256 = "sha256-YxPbzqgQ8Hh2evs+57LSnvOWrVIm1ukaCWzlzB6otk4=";
};
date = "2024-03-15";
};
}
5 changes: 5 additions & 0 deletions pkgs/to-sources/nvfetcher.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,8 @@ fetch.github = "MetaCubeX/metacubexd"
[auth-thu]
src.git = "https://github.com/z4yx/GoAuthing"
fetch.github = "z4yx/GoAuthing"

[yuzu]
src.git = "https://github.com/yuzu-mirror/yuzu"
git.fetchSubmodules = true
fetch.github = "yuzu-mirror/yuzu"

0 comments on commit 6e364a9

Please sign in to comment.