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

56 lines
1.5 KiB
Nix
Raw Normal View History

{ lib, stdenv
, fetchFromGitHub
, rustPlatform
, asciidoctor
, installShellFiles
, pkg-config
2018-09-08 13:21:25 +01:00
, Security
, withPCRE2 ? true
, pcre2 ? null
2018-09-08 13:21:25 +01:00
}:
2016-09-23 21:39:58 +01:00
rustPlatform.buildRustPackage rec {
2019-04-16 21:27:05 +01:00
pname = "ripgrep";
version = "12.1.1";
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;
sha256 = "1hqps7l5qrjh9f914r5i6kmcz6f1yb951nv4lby0cjnp5l253kps";
2016-09-23 21:39:58 +01:00
};
cargoSha256 = "03wf9r2csi6jpa7v5sw5lpxkrk4wfzwmzx7k3991q3bdjzcwnnwp";
2018-09-08 13:21:25 +01:00
2021-01-15 09:19:50 +00:00
cargoBuildFlags = lib.optional withPCRE2 "--features pcre2";
nativeBuildInputs = [ asciidoctor installShellFiles ]
++ lib.optional withPCRE2 pkg-config;
2021-01-15 09:19:50 +00:00
buildInputs = (lib.optional withPCRE2 pcre2)
++ (lib.optional stdenv.isDarwin Security);
2016-09-23 21:39:58 +01:00
preFixup = ''
2020-03-20 06:47:20 +00:00
installManPage $releaseDir/build/ripgrep-*/out/rg.1
installShellCompletion $releaseDir/build/ripgrep-*/out/rg.{bash,fish}
installShellCompletion --zsh complete/_rg
'';
doInstallCheck = true;
installCheckPhase = ''
file="$(mktemp)"
echo "abc\nbcd\ncde" > "$file"
$out/bin/rg -N 'bcd' "$file"
$out/bin/rg -N 'cd' "$file"
2021-02-19 14:33:59 +00:00
'' + lib.optionalString withPCRE2 ''
echo '(a(aa)aa)' | $out/bin/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";
2017-08-24 23:25:02 +01:00
license = with licenses; [ unlicense /* or */ mit ];
2020-06-08 04:24:36 +01:00
maintainers = with maintainers; [ tailhook globin ma27 zowoq ];
2016-09-23 21:39:58 +01:00
};
}