nixpkgs/pkgs/tools/text/ripgrep/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
1.7 KiB
Nix
Raw Normal View History

{ lib, stdenv
2023-11-27 23:45:23 +00:00
, buildPackages
, fetchFromGitHub
, rustPlatform
, installShellFiles
, pkg-config
2018-09-08 13:21:25 +01:00
, Security
, withPCRE2 ? true
2021-05-03 15:59:17 +01:00
, pcre2
2018-09-08 13:21:25 +01:00
}:
2016-09-23 21:39:58 +01:00
let
canRunRg = stdenv.hostPlatform.emulatorAvailable buildPackages;
rg = "${stdenv.hostPlatform.emulator buildPackages} $out/bin/rg";
in rustPlatform.buildRustPackage rec {
2019-04-16 21:27:05 +01:00
pname = "ripgrep";
2024-01-07 02:56:07 +00:00
version = "14.1.0";
2016-09-23 21:39:58 +01:00
src = fetchFromGitHub {
owner = "BurntSushi";
2019-04-16 21:27:05 +01:00
repo = pname;
2018-08-04 21:59:33 +01:00
rev = version;
2024-01-07 02:56:07 +00:00
hash = "sha256-CBU1GzgWMPTVsgaPMy39VRcENw5iWRUrRpjyuGiZpPI=";
2016-09-23 21:39:58 +01:00
};
2024-01-07 02:56:07 +00:00
cargoHash = "sha256-8FxN5MhYduMkzym7Xx4dnVbWaBKv9pgbXMIRGiRRQew=";
2018-09-08 13:21:25 +01:00
2023-11-26 22:04:07 +00:00
nativeBuildInputs = [ installShellFiles ]
++ lib.optional withPCRE2 pkg-config;
2021-05-03 15:59:17 +01:00
buildInputs = lib.optional withPCRE2 pcre2
++ lib.optional stdenv.isDarwin Security;
2016-09-23 21:39:58 +01:00
2021-11-15 23:52:56 +00:00
buildFeatures = lib.optional withPCRE2 "pcre2";
preFixup = lib.optionalString canRunRg ''
${rg} --generate man > rg.1
2023-11-26 22:04:07 +00:00
installManPage rg.1
2023-11-26 22:04:07 +00:00
installShellCompletion --cmd rg \
--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"
${rg} -N 'bcd' "$file"
${rg} -N 'cd' "$file"
2021-02-19 14:33:59 +00:00
'' + lib.optionalString withPCRE2 ''
echo '(a(aa)aa)' | ${rg} -P '\((a*|(?R))*\)'
'';
meta = with lib; {
2016-12-15 23:41:22 +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";
2023-11-29 16:23:23 +00:00
changelog = "https://github.com/BurntSushi/ripgrep/releases/tag/${version}";
2017-08-24 23:25:02 +01:00
license = with licenses; [ unlicense /* or */ mit ];
2023-07-19 11:12:34 +01:00
maintainers = with maintainers; [ globin ma27 zowoq ];
2021-04-27 17:46:23 +01:00
mainProgram = "rg";
2016-09-23 21:39:58 +01:00
};
}