2021-01-15 22:18:51 +00:00
|
|
|
{ lib, stdenv
|
2024-01-02 11:29:13 +00:00
|
|
|
, buildPackages
|
2020-04-24 23:36:52 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, rustPlatform
|
|
|
|
, installShellFiles
|
2021-02-16 17:04:54 +00:00
|
|
|
, pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
, Security
|
|
|
|
, withPCRE2 ? true
|
2021-05-03 20:48:10 +00:00
|
|
|
, pcre2
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
let
|
|
|
|
canRunRg = stdenv.hostPlatform.emulatorAvailable buildPackages;
|
|
|
|
rg = "${stdenv.hostPlatform.emulator buildPackages} $out/bin/rg";
|
|
|
|
in rustPlatform.buildRustPackage rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "ripgrep";
|
2024-01-02 11:29:13 +00:00
|
|
|
version = "14.0.3";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "BurntSushi";
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
2024-01-02 11:29:13 +00:00
|
|
|
hash = "sha256-NBGbiy+1AUIBJFx6kcGPSKo08a+dkNo4rNH2I1pki4U=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
cargoHash = "sha256-s6oK0/eL+NAhG3ySUlJBRatUuWXxfRVgAvlJm++0lkg=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
nativeBuildInputs = [ installShellFiles ]
|
2021-02-16 17:04:54 +00:00
|
|
|
++ lib.optional withPCRE2 pkg-config;
|
2021-05-03 20:48:10 +00:00
|
|
|
buildInputs = lib.optional withPCRE2 pcre2
|
|
|
|
++ lib.optional stdenv.isDarwin Security;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
buildFeatures = lib.optional withPCRE2 "pcre2";
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
preFixup = lib.optionalString canRunRg ''
|
|
|
|
${rg} --generate man > rg.1
|
|
|
|
installManPage rg.1
|
2020-05-03 17:38:23 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
installShellCompletion --cmd rg \
|
|
|
|
--bash <(${rg} --generate complete-bash) \
|
|
|
|
--fish <(${rg} --generate complete-fish) \
|
|
|
|
--zsh <(${rg} --generate complete-zsh)
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-02-19 19:06:45 +00:00
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
file="$(mktemp)"
|
|
|
|
echo "abc\nbcd\ncde" > "$file"
|
2024-01-02 11:29:13 +00:00
|
|
|
${rg} -N 'bcd' "$file"
|
|
|
|
${rg} -N 'cd' "$file"
|
2021-02-19 19:06:45 +00:00
|
|
|
'' + lib.optionalString withPCRE2 ''
|
2024-01-02 11:29:13 +00:00
|
|
|
echo '(a(aa)aa)' | ${rg} -P '\((a*|(?R))*\)'
|
2021-02-19 19:06:45 +00:00
|
|
|
'';
|
2020-12-25 13:55:36 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A utility that combines the usability of The Silver Searcher with the raw speed of grep";
|
|
|
|
homepage = "https://github.com/BurntSushi/ripgrep";
|
2024-01-02 11:29:13 +00:00
|
|
|
changelog = "https://github.com/BurntSushi/ripgrep/releases/tag/${version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = with licenses; [ unlicense /* or */ mit ];
|
2023-08-04 22:07:22 +00:00
|
|
|
maintainers = with maintainers; [ globin ma27 zowoq ];
|
2021-05-03 20:48:10 +00:00
|
|
|
mainProgram = "rg";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|