acr-cli: init at 0.14 (#359508)
[NixPkgs.git] / pkgs / by-name / re / repgrep / package.nix
blob1fb6156dfc4ec573350f6f73a1d6e88c9dfa78d6
1 { lib
2 , stdenv
3 , rustPlatform
4 , fetchFromGitHub
5 , asciidoctor
6 , installShellFiles
7 , makeWrapper
8 , ripgrep
9 }:
11 rustPlatform.buildRustPackage rec {
12   pname = "repgrep";
13   version = "0.15.0";
15   src = fetchFromGitHub {
16     owner = "acheronfail";
17     repo = "repgrep";
18     rev = version;
19     hash = "sha256-6ba7EJUts0Ni9EA3ENlK+a2FaPo7JohtCyqwR9DdL1E=";
20   };
22   cargoHash = "sha256-XEjKTZ3qaiLWbm2wF+V97u9tGXDq/oTm249ubUE9n94=";
24   nativeBuildInputs = [
25     asciidoctor
26     installShellFiles
27     makeWrapper
28   ];
30   postInstall = ''
31     wrapProgram $out/bin/rgr \
32       --prefix PATH : ${lib.makeBinPath [ ripgrep ]}
34     pushd "$(dirname "$(find -path '**/repgrep-stamp' | head -n 1)")"
35     installManPage rgr.1
36     popd
37   '' + lib.optionalString (stdenv.hostPlatform.canExecute stdenv.buildPlatform) ''
38     # As it can be seen here: https://github.com/acheronfail/repgrep/blob/0.15.0/.github/workflows/release.yml#L206, the completions are just the same as ripgrep
39     installShellCompletion --cmd rgr \
40       --bash <(${lib.getExe ripgrep} --generate complete-bash | sed 's/-c rg/-c rgr/') \
41       --zsh <(${lib.getExe ripgrep} --generate complete-zsh | sed 's/-c rg/-c rgr/') \
42       --fish <(${lib.getExe ripgrep} --generate complete-fish | sed 's/-c rg/-c rgr/')
43   '';
45   meta = with lib; {
46     description = "Interactive replacer for ripgrep that makes it easy to find and replace across files on the command line";
47     homepage = "https://github.com/acheronfail/repgrep";
48     changelog = "https://github.com/acheronfail/repgrep/blob/${src.rev}/CHANGELOG.md";
49     license = with licenses; [ mit asl20 unlicense ];
50     maintainers = with maintainers; [ figsoda ];
51     mainProgram = "rgr";
52   };