From b95aad0ec08d10450ac001043a9500297a97be1f Mon Sep 17 00:00:00 2001 From: Niklas Korz Date: Mon, 16 Jun 2025 16:05:36 +0200 Subject: [PATCH] kdePackages.koi: patch hardcoded binary paths Co-authored-by: alexyao2015 <33379584+alexyao2015@users.noreply.github.com> --- .../koi/0001-locate-plasma-tools.patch | 44 +++++++++++++++++++ pkgs/kde/third-party/koi/default.nix | 25 +++++++++++ 2 files changed, 69 insertions(+) create mode 100644 pkgs/kde/third-party/koi/0001-locate-plasma-tools.patch diff --git a/pkgs/kde/third-party/koi/0001-locate-plasma-tools.patch b/pkgs/kde/third-party/koi/0001-locate-plasma-tools.patch new file mode 100644 index 000000000000..2f4a8a2a7629 --- /dev/null +++ b/pkgs/kde/third-party/koi/0001-locate-plasma-tools.patch @@ -0,0 +1,44 @@ +diff --git a/src/plugins/colorscheme.cpp b/src/plugins/colorscheme.cpp +index 7c51806..4d8015b 100644 +--- a/src/plugins/colorscheme.cpp ++++ b/src/plugins/colorscheme.cpp +@@ -3,16 +3,7 @@ + #include + + void ColorScheme::setTheme(QString themeName) { +- QProcess process; +- QString locateProgram = "whereis"; +- QStringList programToLocate = {"plasma-apply-colorscheme"}; +- +- process.start(locateProgram, programToLocate); +- process.waitForFinished(); +- +- QString program(process.readAllStandardOutput()); +- program.replace("plasma-apply-colorscheme: ", ""); +- program.replace("\n", ""); ++ QString program("@plasma-apply-colorscheme@"); + + QStringList arguments{themeName}; + QProcess::startDetached(program, arguments); +diff --git a/src/plugins/icons.cpp b/src/plugins/icons.cpp +index 1cc306f..745d042 100644 +--- a/src/plugins/icons.cpp ++++ b/src/plugins/icons.cpp +@@ -5,16 +5,7 @@ + void Icons::setTheme(QString iconTheme) { + + // locate plasma-changeicons program +- QProcess process; +- QString locateProgram = "whereis"; +- QStringList programToLocate = {"plasma-changeicons"}; +- +- process.start(locateProgram, programToLocate); +- process.waitForFinished(); +- +- QString program(process.readAllStandardOutput()); +- program.replace("plasma-changeicons: ", ""); +- program.replace("\n", ""); ++ QString program("@plasma-changeicons@"); + + // apply the icon theme + QStringList arguments{iconTheme}; diff --git a/pkgs/kde/third-party/koi/default.nix b/pkgs/kde/third-party/koi/default.nix index 9e1bfd3d62de..3cdc6f2bc066 100644 --- a/pkgs/kde/third-party/koi/default.nix +++ b/pkgs/kde/third-party/koi/default.nix @@ -7,6 +7,10 @@ kcoreaddons, kwidgetsaddons, wrapQtAppsHook, + kdbusaddons, + kde-cli-tools, + plasma-workspace, + qtstyleplugin-kvantum, }: stdenv.mkDerivation (finalAttrs: { pname = "koi"; @@ -19,6 +23,27 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-fXLGlq41Qwdp0cYJcNqPlYnlpVXsZk0imYxP7Bgdcvw="; }; + patches = [ + # koi tries to access KDE utility binaries at their absolute paths or by using `whereis`. + # We patch the absolute paths below in `postPatch` and replace the `whereis` invocations + # here with a placeholder that is also substituted in `postPatch`. + ./0001-locate-plasma-tools.patch + ]; + + postPatch = '' + substituteInPlace src/utils.cpp \ + --replace-fail /usr/bin/kquitapp6 ${lib.getExe' kdbusaddons "kquitapp6"} \ + --replace-fail /usr/bin/kstart ${lib.getExe' kde-cli-tools "kstart"} + substituteInPlace src/plugins/plasmastyle.cpp \ + --replace-fail /usr/bin/plasma-apply-desktoptheme ${lib.getExe' plasma-workspace "plasma-apply-desktoptheme"} + substituteInPlace src/plugins/colorscheme.cpp \ + --replace-fail '@plasma-apply-colorscheme@' ${lib.getExe' plasma-workspace "plasma-apply-colorscheme"} + substituteInPlace src/plugins/icons.cpp \ + --replace-fail '@plasma-changeicons@' ${plasma-workspace}/libexec/plasma-changeicons + substituteInPlace src/plugins/kvantumstyle.cpp \ + --replace-fail /usr/bin/kvantummanager ${lib.getExe' qtstyleplugin-kvantum "kvantummanager"} + ''; + nativeBuildInputs = [ cmake wrapQtAppsHook