nixpkgs/pkgs/tools/text/ripgrep/default.nix
Daniël de Kok 85f96822a0 treewide: fix cargoSha256/cargoHash
Rust 1.50.0 incorporated a Cargo change (rust-lang/cargo#8937) in
which cargo vendor erroneously changed permissions of vendored
crates. This was fixed in Rust
1.51.0 (rust-lang/cargo#9131). Unfortunately, this means that all
cargoSha256/cargoHashes produced during the Rust 1.50.0 cycle are
potentially broken.

This change updates cargoSha256/cargoHash tree-wide.

Fixes #121994.
2021-05-08 00:36:37 -07:00

56 lines
1.5 KiB
Nix

{ lib, stdenv
, fetchFromGitHub
, rustPlatform
, asciidoctor
, installShellFiles
, pkg-config
, Security
, withPCRE2 ? true
, pcre2
}:
rustPlatform.buildRustPackage rec {
pname = "ripgrep";
version = "12.1.1";
src = fetchFromGitHub {
owner = "BurntSushi";
repo = pname;
rev = version;
sha256 = "1hqps7l5qrjh9f914r5i6kmcz6f1yb951nv4lby0cjnp5l253kps";
};
cargoSha256 = "1nyfxma2vwfq6r614ng8qq8vanb540a5z0ibs85wz5sjm3hp1l4f";
cargoBuildFlags = lib.optional withPCRE2 "--features pcre2";
nativeBuildInputs = [ asciidoctor installShellFiles ]
++ lib.optional withPCRE2 pkg-config;
buildInputs = lib.optional withPCRE2 pcre2
++ lib.optional stdenv.isDarwin Security;
preFixup = ''
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"
'' + lib.optionalString withPCRE2 ''
echo '(a(aa)aa)' | $out/bin/rg -P '\((a*|(?R))*\)'
'';
meta = with lib; {
description = "A utility that combines the usability of The Silver Searcher with the raw speed of grep";
homepage = "https://github.com/BurntSushi/ripgrep";
license = with licenses; [ unlicense /* or */ mit ];
maintainers = with maintainers; [ tailhook globin ma27 zowoq ];
mainProgram = "rg";
};
}