13 canRunRg = stdenv.hostPlatform.emulatorAvailable buildPackages;
14 rg = "${stdenv.hostPlatform.emulator buildPackages} $out/bin/rg";
15 in rustPlatform.buildRustPackage rec {
19 src = fetchFromGitHub {
23 hash = "sha256-gyWnahj1A+iXUQlQ1O1H1u7K5euYQOld9qWm99Vjaeg=";
26 cargoHash = "sha256-b+iA8iTYWlczBpNq9eyHrWG8LMU4WPBzaU6pQRht+yE=";
28 nativeBuildInputs = [ installShellFiles ]
29 ++ lib.optional withPCRE2 pkg-config;
30 buildInputs = lib.optional withPCRE2 pcre2
31 ++ lib.optional stdenv.hostPlatform.isDarwin Security;
33 buildFeatures = lib.optional withPCRE2 "pcre2";
35 preFixup = lib.optionalString canRunRg ''
36 ${rg} --generate man > rg.1
39 installShellCompletion --cmd rg \
40 --bash <(${rg} --generate complete-bash) \
41 --fish <(${rg} --generate complete-fish) \
42 --zsh <(${rg} --generate complete-zsh)
45 doInstallCheck = true;
46 installCheckPhase = ''
48 echo "abc\nbcd\ncde" > "$file"
49 ${rg} -N 'bcd' "$file"
51 '' + lib.optionalString withPCRE2 ''
52 echo '(a(aa)aa)' | ${rg} -P '\((a*|(?R))*\)'
56 description = "Utility that combines the usability of The Silver Searcher with the raw speed of grep";
57 homepage = "https://github.com/BurntSushi/ripgrep";
58 changelog = "https://github.com/BurntSushi/ripgrep/releases/tag/${version}";
59 license = with licenses; [ unlicense /* or */ mit ];
60 maintainers = with maintainers; [ globin ma27 zowoq ];