about summary refs log tree commit diff
path: root/pkgs/tools/text/ripgrep
diff options
context:
space:
mode:
authorColin <colin@uninsane.org>2023-11-30 00:31:30 +0000
committerColin <colin@uninsane.org>2023-12-31 10:41:32 +0000
commit71b9377fab4fbab22b069e89dc17179de723ba5a (patch)
treeea92a76e13c8d1ac8a4e9696653e76f01ce1a64b /pkgs/tools/text/ripgrep
parentf58962c689b26105c2ee903c4eca8b5079180f0c (diff)
downloadnixlib-71b9377fab4fbab22b069e89dc17179de723ba5a.tar
nixlib-71b9377fab4fbab22b069e89dc17179de723ba5a.tar.gz
nixlib-71b9377fab4fbab22b069e89dc17179de723ba5a.tar.bz2
nixlib-71b9377fab4fbab22b069e89dc17179de723ba5a.tar.lz
nixlib-71b9377fab4fbab22b069e89dc17179de723ba5a.tar.xz
nixlib-71b9377fab4fbab22b069e89dc17179de723ba5a.tar.zst
nixlib-71b9377fab4fbab22b069e89dc17179de723ba5a.zip
ripgrep: fix shell completions when cross compiling
Diffstat (limited to 'pkgs/tools/text/ripgrep')
-rw-r--r--pkgs/tools/text/ripgrep/default.nix24
1 files changed, 13 insertions, 11 deletions
diff --git a/pkgs/tools/text/ripgrep/default.nix b/pkgs/tools/text/ripgrep/default.nix
index 5c8427679c82..af42afde1158 100644
--- a/pkgs/tools/text/ripgrep/default.nix
+++ b/pkgs/tools/text/ripgrep/default.nix
@@ -7,10 +7,12 @@
 , Security
 , withPCRE2 ? true
 , pcre2
-, enableManpages ? stdenv.hostPlatform.emulatorAvailable buildPackages
 }:
 
-rustPlatform.buildRustPackage rec {
+let
+  canRunRg = stdenv.hostPlatform.emulatorAvailable buildPackages;
+  rg = "${stdenv.hostPlatform.emulator buildPackages} $out/bin/rg";
+in rustPlatform.buildRustPackage rec {
   pname = "ripgrep";
   version = "14.0.3";
 
@@ -30,24 +32,24 @@ rustPlatform.buildRustPackage rec {
 
   buildFeatures = lib.optional withPCRE2 "pcre2";
 
-  preFixup = lib.optionalString enableManpages ''
-    ${stdenv.hostPlatform.emulator buildPackages} $out/bin/rg --generate man > rg.1
+  preFixup = lib.optionalString canRunRg ''
+    ${rg} --generate man > rg.1
     installManPage rg.1
-  '' + ''
+
     installShellCompletion --cmd rg \
-      --bash <($out/bin/rg --generate complete-bash) \
-      --fish <($out/bin/rg --generate complete-fish) \
-      --zsh <($out/bin/rg --generate complete-zsh)
+      --bash <(${rg} --generate complete-bash) \
+      --fish <(${rg} --generate complete-fish) \
+      --zsh <(${rg} --generate complete-zsh)
   '';
 
   doInstallCheck = true;
   installCheckPhase = ''
     file="$(mktemp)"
     echo "abc\nbcd\ncde" > "$file"
-    $out/bin/rg -N 'bcd' "$file"
-    $out/bin/rg -N 'cd' "$file"
+    ${rg} -N 'bcd' "$file"
+    ${rg} -N 'cd' "$file"
   '' + lib.optionalString withPCRE2 ''
-    echo '(a(aa)aa)' | $out/bin/rg -P '\((a*|(?R))*\)'
+    echo '(a(aa)aa)' | ${rg} -P '\((a*|(?R))*\)'
   '';
 
   meta = with lib; {