From bf5cf73b0a7f64bca732f876d35186f39ae4de21 Mon Sep 17 00:00:00 2001 From: "J. T. Elscott" <78996170+99jte@users.noreply.github.com> Date: Thu, 13 Mar 2025 10:05:47 -0700 Subject: [PATCH 1/3] kdePackages.khelpcenter: fix manpage search Previously the shebang in khc_mansearch.py pointed to /bin/env and caused it to fail; add python3 to the extraBuildInputs to that it gets converted to a nix path. Also get the man-db binaries by their nix path rather than hoping that they're in the runtime PATH. --- pkgs/kde/gear/khelpcenter/default.nix | 9 ++++++++ ...se_nix_paths_for_mansearch_utilities.patch | 23 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 pkgs/kde/gear/khelpcenter/use_nix_paths_for_mansearch_utilities.patch diff --git a/pkgs/kde/gear/khelpcenter/default.nix b/pkgs/kde/gear/khelpcenter/default.nix index 2348754b71b6..e69cd63a7d53 100644 --- a/pkgs/kde/gear/khelpcenter/default.nix +++ b/pkgs/kde/gear/khelpcenter/default.nix @@ -1,7 +1,10 @@ { mkKdeDerivation, + replaceVars, qtwebengine, xapian, + man-db, + python3, }: mkKdeDerivation { pname = "khelpcenter"; @@ -9,6 +12,12 @@ mkKdeDerivation { extraBuildInputs = [ qtwebengine xapian + python3 + ]; + patches = [ + (replaceVars ./use_nix_paths_for_mansearch_utilities.patch { + inherit man-db; + }) ]; meta.mainProgram = "khelpcenter"; } diff --git a/pkgs/kde/gear/khelpcenter/use_nix_paths_for_mansearch_utilities.patch b/pkgs/kde/gear/khelpcenter/use_nix_paths_for_mansearch_utilities.patch new file mode 100644 index 000000000000..531819730127 --- /dev/null +++ b/pkgs/kde/gear/khelpcenter/use_nix_paths_for_mansearch_utilities.patch @@ -0,0 +1,23 @@ +diff --git a/searchhandlers/khc_mansearch.py b/searchhandlers/khc_mansearch.py +index ce61ed9c..a8c4c653 100755 +--- a/searchhandlers/khc_mansearch.py ++++ b/searchhandlers/khc_mansearch.py +@@ -32,15 +32,15 @@ def main(): + # If the query is a single word, perhaps it is the literal name of the + # command, or a prefix, or a substring + if not ' ' in words: +- results_prefix = subprocess.run(['whatis', '-w', words + '*'], capture_output=True, text=True) ++ results_prefix = subprocess.run(['@man-db@/bin/whatis', '-w', words + '*'], capture_output=True, text=True) + if results_prefix.returncode == 0: + command_results += results_prefix.stdout +- results_substring = subprocess.run(['whatis', '-w', '*' + words + '*'], capture_output=True, text=True) ++ results_substring = subprocess.run(['@man-db@/bin/whatis', '-w', '*' + words + '*'], capture_output=True, text=True) + if results_substring.returncode == 0: + command_results += results_substring.stdout + + # Build the apropos command line +- apropos = ['apropos', '-L', args.lang] ++ apropos = ['@man-db@/bin/apropos', '-L', args.lang] + if args.method == 'and': + apropos.append('--and') + apropos.extend(words.split(' ')) From 513de13f422f23f358e4d38149c8ce83fe2e3aa3 Mon Sep 17 00:00:00 2001 From: "J. T. Elscott" <78996170+99jte@users.noreply.github.com> Date: Thu, 13 Mar 2025 10:08:44 -0700 Subject: [PATCH 2/3] kdePackages.khelpcenter: runtime dependency on kio-extras (through wrapQtAppsHook) to retrieve manpages --- pkgs/kde/gear/khelpcenter/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/kde/gear/khelpcenter/default.nix b/pkgs/kde/gear/khelpcenter/default.nix index e69cd63a7d53..795ec3b4aeb3 100644 --- a/pkgs/kde/gear/khelpcenter/default.nix +++ b/pkgs/kde/gear/khelpcenter/default.nix @@ -5,6 +5,7 @@ xapian, man-db, python3, + kio-extras, }: mkKdeDerivation { pname = "khelpcenter"; @@ -13,6 +14,7 @@ mkKdeDerivation { qtwebengine xapian python3 + kio-extras ]; patches = [ (replaceVars ./use_nix_paths_for_mansearch_utilities.patch { From 615baa8d74c4dc707e8027eeafe57ffadddd9ebf Mon Sep 17 00:00:00 2001 From: "J. T. Elscott" <78996170+99jte@users.noreply.github.com> Date: Thu, 13 Mar 2025 10:18:11 -0700 Subject: [PATCH 3/3] kdePackages.kio-extras: add a manpage search path for nixos Add the path /run/current-system/etc/man_db.conf. With my previous commits in this PR, khelpcenter is able to search for manpages because it calls out to man-db, but it doesn't know where to find them when asked to display them. --- .../kio-extras/add-nixos-man-db-config-path.patch | 13 +++++++++++++ pkgs/kde/gear/kio-extras/default.nix | 4 ++++ 2 files changed, 17 insertions(+) create mode 100644 pkgs/kde/gear/kio-extras/add-nixos-man-db-config-path.patch diff --git a/pkgs/kde/gear/kio-extras/add-nixos-man-db-config-path.patch b/pkgs/kde/gear/kio-extras/add-nixos-man-db-config-path.patch new file mode 100644 index 000000000000..275e6121c17f --- /dev/null +++ b/pkgs/kde/gear/kio-extras/add-nixos-man-db-config-path.patch @@ -0,0 +1,13 @@ +diff --git a/man/kio_man.cpp b/man/kio_man.cpp +index a2fb6dbf5..cb6f373bc 100644 +--- a/man/kio_man.cpp ++++ b/man/kio_man.cpp +@@ -868,6 +868,8 @@ void MANProtocol::constructPath(QStringList &constr_path, QStringList constr_cat + mc.setFileName("/etc/manpath.config"); // SuSE, Debian + if (!mc.exists()) + mc.setFileName("/etc/man.config"); // Mandrake ++ if (!mc.exists()) ++ mc.setFileName("/run/current-system/etc/man_db.conf"); // NixOS + + if (mc.open(QIODevice::ReadOnly)) { + QTextStream is(&mc); diff --git a/pkgs/kde/gear/kio-extras/default.nix b/pkgs/kde/gear/kio-extras/default.nix index 2260feeac62c..5bcf4b605069 100644 --- a/pkgs/kde/gear/kio-extras/default.nix +++ b/pkgs/kde/gear/kio-extras/default.nix @@ -19,6 +19,10 @@ mkKdeDerivation { pname = "kio-extras"; + patches = [ + # An upstream merge request is pending for this https://invent.kde.org/network/kio-extras/-/merge_requests/422 + ./add-nixos-man-db-config-path.patch + ]; extraNativeBuildInputs = [ pkg-config gperf