From 619c4b605e267f2eae56458d72070d4726ae1a31 Mon Sep 17 00:00:00 2001 From: K900 Date: Fri, 29 Dec 2023 14:41:34 +0300 Subject: [PATCH] yuzu: reorganize everything, use common updater scripts, actually update --- .../emulators/yuzu/compat-list.nix | 18 ++++ pkgs/applications/emulators/yuzu/default.nix | 84 +++++-------------- .../emulators/yuzu/early-access/default.nix | 36 ++++++++ .../emulators/yuzu/early-access/sources.nix | 7 ++ .../emulators/yuzu/early-access/update.sh | 48 +++++++++++ .../yuzu/{generic.nix => mainline.nix} | 51 ++++++----- pkgs/applications/emulators/yuzu/nx_tzdb.nix | 20 +++++ pkgs/applications/emulators/yuzu/sources.nix | 19 ----- pkgs/applications/emulators/yuzu/update.sh | 66 --------------- pkgs/top-level/aliases.nix | 6 +- pkgs/top-level/all-packages.nix | 11 +-- 11 files changed, 181 insertions(+), 185 deletions(-) create mode 100644 pkgs/applications/emulators/yuzu/compat-list.nix create mode 100644 pkgs/applications/emulators/yuzu/early-access/default.nix create mode 100644 pkgs/applications/emulators/yuzu/early-access/sources.nix create mode 100755 pkgs/applications/emulators/yuzu/early-access/update.sh rename pkgs/applications/emulators/yuzu/{generic.nix => mainline.nix} (77%) create mode 100644 pkgs/applications/emulators/yuzu/nx_tzdb.nix delete mode 100644 pkgs/applications/emulators/yuzu/sources.nix delete mode 100755 pkgs/applications/emulators/yuzu/update.sh diff --git a/pkgs/applications/emulators/yuzu/compat-list.nix b/pkgs/applications/emulators/yuzu/compat-list.nix new file mode 100644 index 000000000000..431a2e5197e3 --- /dev/null +++ b/pkgs/applications/emulators/yuzu/compat-list.nix @@ -0,0 +1,18 @@ +{ stdenv, fetchFromGitHub, unstableGitUpdater }: +stdenv.mkDerivation { + pname = "yuzu-compatibility-list"; + version = "unstable-2023-12-28"; + + src = fetchFromGitHub { + owner = "flathub"; + repo = "org.yuzu_emu.yuzu"; + rev = "0b9bf10851d6ad54441dc4f687d5755ed2c6f7a8"; + hash = "sha256-oWEeAhyxFO1TFH3d+/ivRf1KnNUU8y5c/7NtOzlpKXg="; + }; + + buildCommand = '' + cp $src/compatibility_list.json $out + ''; + + passthru.updateScript = unstableGitUpdater {}; +} diff --git a/pkgs/applications/emulators/yuzu/default.nix b/pkgs/applications/emulators/yuzu/default.nix index ef9c12703f24..116f12b2a963 100644 --- a/pkgs/applications/emulators/yuzu/default.nix +++ b/pkgs/applications/emulators/yuzu/default.nix @@ -1,68 +1,22 @@ -{ branch ? "mainline" -, qt6Packages -, fetchFromGitHub -, fetchgit -, fetchurl -, fetchzip -, runCommand -, gnutar -}: +{ qt6Packages, makeScopeWithSplicing', generateSplicesForMkScope, vulkan-headers, fetchFromGitHub }: -let - sources = import ./sources.nix; +makeScopeWithSplicing' { + otherSplices = generateSplicesForMkScope "yuzuPackages"; + f = self: qt6Packages // { + compat-list = self.callPackage ./compat-list.nix {}; + nx_tzdb = self.callPackage ./nx_tzdb.nix {}; - compat-list = fetchurl { - name = "yuzu-compat-list"; - url = "https://raw.githubusercontent.com/flathub/org.yuzu_emu.yuzu/${sources.compatList.rev}/compatibility_list.json"; - hash = sources.compatList.hash; + mainline = self.callPackage ./mainline.nix {}; + early-access = self.callPackage ./early-access {}; + + vulkan-headers = vulkan-headers.overrideAttrs(old: rec { + version = "1.3.274"; + src = fetchFromGitHub { + owner = "KhronosGroup"; + repo = "Vulkan-Headers"; + rev = "v${version}"; + hash = "sha256-SsS5VlEnhjOSu8MlIVC0d2r2EAf8QsNJPEAXNtbDOJ4="; + }; + }); }; - - 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 = qt6Packages.callPackage ./generic.nix { - branch = "mainline"; - version = sources.mainline.version; - src = mainlineSrc; - inherit compat-list; - }; - - early-access = qt6Packages.callPackage ./generic.nix { - branch = "early-access"; - version = sources.ea.version; - src = eaSrcRehydrated; - inherit compat-list; - }; -}.${branch} +} diff --git a/pkgs/applications/emulators/yuzu/early-access/default.nix b/pkgs/applications/emulators/yuzu/early-access/default.nix new file mode 100644 index 000000000000..842f7c107975 --- /dev/null +++ b/pkgs/applications/emulators/yuzu/early-access/default.nix @@ -0,0 +1,36 @@ +{ mainline, fetchzip, fetchgit, runCommand, gnutar }: +# 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. +let + sources = import ./sources.nix; + + zip = fetchzip { + name = "yuzu-ea-windows-dist"; + url = "https://github.com/pineappleEA/pineapple-src/releases/download/EA-${sources.version}/Windows-Yuzu-EA-${sources.version}.zip"; + hash = sources.distHash; + }; + + gitSrc = runCommand "yuzu-ea-dist-unpacked" { + src = zip; + nativeBuildInputs = [ gnutar ]; + } + '' + mkdir $out + tar xf $src/*.tar.xz --directory=$out --strip-components=1 + ''; + + rehydratedSrc = fetchgit { + url = gitSrc; + fetchSubmodules = true; + hash = sources.fullHash; + }; +in mainline.overrideAttrs(old: { + pname = "yuzu-early-access"; + version = sources.version; + src = rehydratedSrc; + passthru.updateScript = ./update.sh; + meta = old.meta // { description = old.meta.description + " - early access branch"; }; +}) diff --git a/pkgs/applications/emulators/yuzu/early-access/sources.nix b/pkgs/applications/emulators/yuzu/early-access/sources.nix new file mode 100644 index 000000000000..4f9c6a1f8d39 --- /dev/null +++ b/pkgs/applications/emulators/yuzu/early-access/sources.nix @@ -0,0 +1,7 @@ +# Generated by ./update.sh - do not update manually! +# Last updated: 2023-12-29 +{ + version = "4037"; + distHash = "sha256:0pw56hj13fm9j5nja1lhj839d88w00kcr30kygasr36w9c7yv2n7"; + fullHash = "sha256:0f42fp8z333b3k4pn8j0cp3480llvlygl5p6qfgywhq3g5hcpzpb"; +} diff --git a/pkgs/applications/emulators/yuzu/early-access/update.sh b/pkgs/applications/emulators/yuzu/early-access/update.sh new file mode 100755 index 000000000000..0e98185bbf9a --- /dev/null +++ b/pkgs/applications/emulators/yuzu/early-access/update.sh @@ -0,0 +1,48 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i bash -p nix nix-prefetch-git gnutar curl jq unzip + +set -euo pipefail + +cd "$(dirname "$(readlink -f "$0")")" + +log() { + tput bold + echo "#" "$@" + tput sgr0 +} + +oldVersion="$(nix --experimental-features nix-command eval -f sources.nix --raw version)" +newVersion="$(curl "https://api.github.com/repos/pineappleEA/pineapple-src/releases?per_page=1" | jq -r '.[0].tag_name' | cut -d"-" -f2)" + +if [ "$oldVersion" == "$newVersion" ]; then + log "Already up to date" + exit 0 +fi + +fetched="$(nix-prefetch-url --unpack --print-path "https://github.com/pineappleEA/pineapple-src/releases/download/EA-${newVersion}/Windows-Yuzu-EA-${newVersion}.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 < ${newVersion}" ./sources.nix +fi diff --git a/pkgs/applications/emulators/yuzu/generic.nix b/pkgs/applications/emulators/yuzu/mainline.nix similarity index 77% rename from pkgs/applications/emulators/yuzu/generic.nix rename to pkgs/applications/emulators/yuzu/mainline.nix index a24ded852531..6964f272553e 100644 --- a/pkgs/applications/emulators/yuzu/generic.nix +++ b/pkgs/applications/emulators/yuzu/mainline.nix @@ -1,21 +1,18 @@ -{ version -, src -, branch -, compat-list - -, lib +{ lib , stdenv +, fetchFromGitHub +, nix-update-script , wrapQtAppsHook , alsa-lib , boost , catch2_3 , cmake +, compat-list , cpp-jwt , cubeb , discord-rpc , doxygen , enet -, fetchurl , ffmpeg , fmt , glslang @@ -29,6 +26,7 @@ , libzip , lz4 , nlohmann_json +, nx_tzdb , perl , pkg-config , python3 @@ -47,17 +45,17 @@ , zlib , zstd }: +stdenv.mkDerivation(finalAttrs: { + pname = "yuzu"; + version = "1665"; -let - tzinfoVersion = "221202"; - tzinfo = fetchurl { - url = "https://github.com/lat9nq/tzdb_to_nx/releases/download/${tzinfoVersion}/${tzinfoVersion}.zip"; - hash = "sha256-mRzW+iIwrU1zsxHmf+0RArU8BShAoEMvCz+McXFFK3c="; + src = fetchFromGitHub { + owner = "yuzu-emu"; + repo = "yuzu-mainline"; + rev = "mainline-0-${finalAttrs.version}"; + hash = "sha256-xzSup1oz83GPpOGh9aJJ5YjoFX/cBI8RV6SvDYNH/zA="; + fetchSubmodules = true; }; -in stdenv.mkDerivation { - pname = "yuzu-${branch}"; - - inherit version src; nativeBuildInputs = [ cmake @@ -69,6 +67,10 @@ in stdenv.mkDerivation { ]; buildInputs = [ + # vulkan-headers must come first, so the older propagated versions + # don't get picked up by accident + vulkan-headers + alsa-lib boost catch2_3 @@ -101,7 +103,6 @@ in stdenv.mkDerivation { sndio speexdsp udev - vulkan-headers # intentionally omitted: xbyak - prefer vendored version for compatibility zlib zstd @@ -120,6 +121,8 @@ in stdenv.mkDerivation { "-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" @@ -145,13 +148,13 @@ in stdenv.mkDerivation { preConfigure = '' # see https://github.com/NixOS/nixpkgs/issues/114044, setting this through cmakeFlags does not work. cmakeFlagsArray+=( - "-DTITLE_BAR_FORMAT_IDLE=yuzu | ${branch} ${version} (nixpkgs) {}" - "-DTITLE_BAR_FORMAT_RUNNING=yuzu | ${branch} ${version} (nixpkgs) | {}" + "-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 -sf ${tzinfo} build/externals/nx_tzdb/${tzinfoVersion}.zip + ln -sf ${nx_tzdb} build/externals/nx_tzdb/${nx_tzdb.version}.zip ''; # This must be done after cmake finishes as it overwrites the file @@ -159,12 +162,14 @@ in stdenv.mkDerivation { ln -sf ${compat-list} ./dist/compatibility_list/compatibility_list.json ''; - passthru.updateScript = ./update.sh; + 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 = "The ${branch} branch of an experimental Nintendo Switch emulator written in C++"; + 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. @@ -185,4 +190,4 @@ in stdenv.mkDerivation { k900 ]; }; -} +}) diff --git a/pkgs/applications/emulators/yuzu/nx_tzdb.nix b/pkgs/applications/emulators/yuzu/nx_tzdb.nix new file mode 100644 index 000000000000..faca41e24737 --- /dev/null +++ b/pkgs/applications/emulators/yuzu/nx_tzdb.nix @@ -0,0 +1,20 @@ +{ stdenv, fetchurl, 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="; + }; + + dontUnpack = true; + + buildCommand = '' + cp $src $out + ''; + + passthru.updateScript = gitUpdater { + url = "https://github.com/lat9nq/tzdb_to_nx.git"; + }; +} diff --git a/pkgs/applications/emulators/yuzu/sources.nix b/pkgs/applications/emulators/yuzu/sources.nix deleted file mode 100644 index 4952c74ac4b4..000000000000 --- a/pkgs/applications/emulators/yuzu/sources.nix +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by ./update.sh - do not update manually! -# Last updated: 2023-12-14 -{ - compatList = { - rev = "fc974b6e78105774dae5f68e712a6beb51b9db1e"; - hash = "sha256:1hdsza3wf9a0yvj6h55gsl7xqvhafvbz1i8paz9kg7l49b0gnlh1"; - }; - - mainline = { - version = "1651"; - hash = "sha256:00cxyh3d18k17g982yqcbaq4b6bgs4kji0yz6i15h066aj15dimy"; - }; - - ea = { - version = "4019"; - distHash = "sha256:1qd953bl216yxmaa6y0iil6pn2pn53k87qwagbmcd4l5h4aaqi7h"; - fullHash = "sha256:0na96hqfdd40q6drrlgak4qdsxs3wfizxhb8kf8qrbai3qfpx00v"; - }; -} diff --git a/pkgs/applications/emulators/yuzu/update.sh b/pkgs/applications/emulators/yuzu/update.sh deleted file mode 100755 index ad34bfee3d6b..000000000000 --- a/pkgs/applications/emulators/yuzu/update.sh +++ /dev/null @@ -1,66 +0,0 @@ -#! /usr/bin/env nix-shell -#! nix-shell -i bash -p nix nix-prefetch-git gnutar curl jq unzip - -set -euo pipefail - -cd "$(dirname "$(readlink -f "$0")")" - -log() { - tput bold - echo "#" "$@" - tput sgr0 -} - -alias curl='curl -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"}' - -log "Updating compatibility list..." -compatListRev="$(curl "https://api.github.com/repos/flathub/org.yuzu_emu.yuzu/commits/master" | jq -r '.sha')" - -log "Downloading rev: ${compatListRev}" -compatListHash="$(nix-prefetch-url "https://raw.githubusercontent.com/flathub/org.yuzu_emu.yuzu/${compatListRev}/compatibility_list.json")" - -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)" - -log "Downloading version: ${mainlineVersion}" -mainlineHash="$(nix-prefetch-git --fetch-submodules --rev "mainline-0-${mainlineVersion}" "https://github.com/yuzu-emu/yuzu-mainline" | jq -r '.sha256')" - -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 <