diff --git a/pkgs/by-name/sh/shadps4-qtlauncher/package.nix b/pkgs/by-name/sh/shadps4-qtlauncher/package.nix new file mode 100644 index 000000000000..8b0a0888bef2 --- /dev/null +++ b/pkgs/by-name/sh/shadps4-qtlauncher/package.nix @@ -0,0 +1,104 @@ +{ + lib, + stdenv, + fetchFromGitHub, + + cmake, + pkg-config, + qt6, + + fmt, + sdl3, + toml11, + + shadps4, +}: +stdenv.mkDerivation (finalAttrs: { + pname = "shadps4-qtlauncher"; + version = "224"; + + src = fetchFromGitHub { + owner = "shadps4-emu"; + repo = "shadps4-qtlauncher"; + tag = "v${finalAttrs.version}"; + hash = "sha256-lRZH9fokUKN/n3m/ZkTsRHwkwZZ04buvqBMXYLrqqLE="; + + postCheckout = '' + cd "$out" + + git rev-parse --short=8 HEAD > $out/COMMIT + date -u -d "@$(git log -1 --pretty=%ct)" "+%Y-%m-%dT%H:%M:%SZ" > $out/SOURCE_DATE_EPOCH + + git -C externals submodule update --init --recursive \ + volk \ + json + ''; + }; + + strictDeps = true; + __structuredAttrs = true; + + patches = [ + ./qt-paths.patch + # https://github.com/shadps4-emu/shadps4-qtlauncher/pull/335 + ./version-directory.patch + ]; + + postPatch = '' + substituteInPlace src/common/scm_rev.cpp.in \ + --replace-fail @APP_VERSION@ ${finalAttrs.version} \ + --replace-fail @GIT_REV@ $(cat COMMIT) \ + --replace-fail @GIT_BRANCH@ ${finalAttrs.version} \ + --replace-fail @GIT_DESC@ nixpkgs \ + --replace-fail @BUILD_DATE@ $(cat SOURCE_DATE_EPOCH) + + substituteInPlace src/common/versions.cpp \ + --replace-fail "@shadps4-qt@" "$out" + + substituteInPlace src/qt_gui/gui_settings.cpp \ + --replace-fail "@shadps4-qt@" "$out" + + substituteInPlace src/qt_gui/version_dialog.cpp \ + --replace-fail "@shadps4-qt@" "$out" + ''; + + nativeBuildInputs = [ + cmake + pkg-config + qt6.wrapQtAppsHook + ]; + + buildInputs = [ + fmt + sdl3 + toml11 + qt6.qtbase + qt6.qttools + qt6.qtmultimedia + ]; + + cmakeFlags = [ + (lib.cmakeBool "ENABLE_UPDATER" false) + (lib.cmakeBool "HIDE_VERSION_MANAGER" true) + ]; + + postInstall = '' + substitute ${./versions.json} $out/share/versions.json \ + --replace-fail @shadps4@ ${lib.getExe shadps4} + + substitute ${./qt_ui.ini} $out/share/qt_ui.ini \ + --replace-fail @shadps4@ ${lib.getExe shadps4} + ''; + + meta = { + inherit (shadps4.meta) + platforms + license + maintainers + ; + + description = shadps4.meta.description + " (Qt UI)"; + homepage = "https://github.com/shadps4-emu/shadps4-qtlauncher"; + mainProgram = "shadPS4QtLauncher"; + }; +}) diff --git a/pkgs/by-name/sh/shadps4-qtlauncher/qt-paths.patch b/pkgs/by-name/sh/shadps4-qtlauncher/qt-paths.patch new file mode 100644 index 000000000000..45d41ddbf425 --- /dev/null +++ b/pkgs/by-name/sh/shadps4-qtlauncher/qt-paths.patch @@ -0,0 +1,50 @@ +diff --git a/src/common/versions.cpp b/src/common/versions.cpp +index b935bb6..8625989 100644 +--- a/src/common/versions.cpp ++++ b/src/common/versions.cpp +@@ -18,7 +18,7 @@ namespace VersionManager { + + std::vector GetVersionList(std::filesystem::path const& path) { + std::filesystem::path cfg_path = +- path.empty() ? Common::FS::GetUserPath(Common::FS::PathType::LauncherDir) / "versions.json" ++ path.empty() ? "@shadps4-qt@/share/versions.json" + : path; + + std::ifstream ifs{cfg_path}; +@@ -76,7 +76,7 @@ std::vector GetVersionList(std::filesystem::path const& path) { + + void SaveVersionList(std::vector const& versions, std::filesystem::path const& path) { + std::filesystem::path out_path = +- path.empty() ? Common::FS::GetUserPath(Common::FS::PathType::LauncherDir) / "versions.json" ++ path.empty() ? "@shadps4-qt@/share/versions.json" + : path; + + json root = json::array(); +diff --git a/src/qt_gui/gui_settings.cpp b/src/qt_gui/gui_settings.cpp +index 707131c..40e3f14 100644 +--- a/src/qt_gui/gui_settings.cpp ++++ b/src/qt_gui/gui_settings.cpp +@@ -5,7 +5,9 @@ + #include "gui_settings.h" + + gui_settings::gui_settings(QObject* parent) : settings(parent) { +- m_settings = std::make_unique(ComputeSettingsDir() + "qt_ui.ini", ++ QString currentPath; ++ Common::FS::PathToQString(currentPath, "@shadps4-qt@/share/qt_ui.ini"); ++ m_settings = std::make_unique(currentPath, + QSettings::Format::IniFormat, parent); + } + +diff --git a/src/qt_gui/version_dialog.cpp b/src/qt_gui/version_dialog.cpp +index 2ed0418..13c6788 100644 +--- a/src/qt_gui/version_dialog.cpp ++++ b/src/qt_gui/version_dialog.cpp +@@ -638,7 +638,7 @@ tr("First you need to choose a location to save the versions in\n'Path to save v + } + + void VersionDialog::LoadInstalledList() { +- const auto path = Common::FS::GetUserPath(Common::FS::PathType::LauncherDir) / "versions.json"; ++ const auto path = "@shadps4-qt@/share/versions.json"; + auto versions = VersionManager::GetVersionList(path); + const auto& selected_version = + m_gui_settings->GetValue(gui::vm_versionSelected).toString().toStdString(); diff --git a/pkgs/by-name/sh/shadps4-qtlauncher/qt_ui.ini b/pkgs/by-name/sh/shadps4-qtlauncher/qt_ui.ini new file mode 100644 index 000000000000..dd5bc8fef4d1 --- /dev/null +++ b/pkgs/by-name/sh/shadps4-qtlauncher/qt_ui.ini @@ -0,0 +1,2 @@ +[version_manager] +versionSelected=@shadps4@ diff --git a/pkgs/by-name/sh/shadps4-qtlauncher/version-directory.patch b/pkgs/by-name/sh/shadps4-qtlauncher/version-directory.patch new file mode 100644 index 000000000000..77b80208c18e --- /dev/null +++ b/pkgs/by-name/sh/shadps4-qtlauncher/version-directory.patch @@ -0,0 +1,37 @@ +diff --git a/src/qt_gui/game_install_dialog.cpp b/src/qt_gui/game_install_dialog.cpp +index 8a9b94d..919d4a5 100644 +--- a/src/qt_gui/game_install_dialog.cpp ++++ b/src/qt_gui/game_install_dialog.cpp +@@ -144,7 +144,9 @@ void GameInstallDialog::Save() { + // Check games directory. + auto gamesDirectory = m_gamesDirectory->text(); + auto addonsDirectory = m_addonsDirectory->text(); ++#ifndef HIDE_VERSION_MANAGER + auto versionDirectory = m_versionDirectory->text(); ++#endif + + if (gamesDirectory.isEmpty() || !QDir(gamesDirectory).exists() || + !QDir::isAbsolutePath(gamesDirectory)) { +@@ -167,6 +169,7 @@ void GameInstallDialog::Save() { + } + } + ++#ifndef HIDE_VERSION_MANAGER + if (versionDirectory.isEmpty() || !QDir::isAbsolutePath(versionDirectory)) { + QMessageBox::critical(this, tr("Error"), + "The value for location to install emulator versions is not valid."); +@@ -181,11 +184,14 @@ void GameInstallDialog::Save() { + return; + } + } ++#endif + + // Save the directories + Config::addGameInstallDir(Common::FS::PathFromQString(gamesDirectory)); + Config::setAddonInstallDir(Common::FS::PathFromQString(addonsDirectory)); ++#ifndef HIDE_VERSION_MANAGER + m_gui_settings->SetValue(gui::vm_versionPath, versionDirectory); ++#endif + + const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir); + Config::save(config_dir / "config.toml"); diff --git a/pkgs/by-name/sh/shadps4-qtlauncher/versions.json b/pkgs/by-name/sh/shadps4-qtlauncher/versions.json new file mode 100644 index 000000000000..abe7564b8e74 --- /dev/null +++ b/pkgs/by-name/sh/shadps4-qtlauncher/versions.json @@ -0,0 +1,8 @@ +[ + { + "codename": "built-in", + "name": "built-in", + "path": "@shadps4@", + "type": 0 + } +]