aboutsummaryrefslogtreecommitdiffhomepage
path: root/pkgs/hgrep/default.nix
blob: 97db7800c84eb44ed1af317cf89162b016f3df69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
  fetchFromGitHub,
  installShellFiles,
  lib,
  rustPlatform,
}:

rustPlatform.buildRustPackage rec {
  pname = "hgrep";
  version = "0.3.8";

  src = fetchFromGitHub {
    owner = "rhysd";
    repo = "hgrep";
    rev = "v${version}";
    hash = "sha256-GcV6tZLhAtBE0/husOqZ3Gib9nXXg7kcxrNp9IK0eTo=";
  };
  cargoHash = "sha256-NxfWY9OoMNASlWE48njuAdTI11JAV+rzjD0OU2cHLsc=";

  nativeBuildInputs = [
    installShellFiles
  ];

  # Disable bat-printer because I won't use it.
  # https://github.com/rhysd/hgrep/blob/v0.3.8/Cargo.toml#L44-L48
  buildNoDefaultFeatures = true;
  buildFeatures = [
    "ripgrep"
    # "bat-printer"
    "syntect-printer"
  ];

  checkFlags = [
    # Disable snapshot tests.
    "--skip=tests::arg_matches"
  ];

  postFixup = ''
    $out/bin/hgrep --generate-man-page > hgrep.1
    installManPage hgrep.1

    installShellCompletion --cmd hgrep \
      --bash <($out/bin/hgrep --generate-completion-script bash) \
      --zsh  <($out/bin/hgrep --generate-completion-script zsh) \
      --fish <($out/bin/hgrep --generate-completion-script fish) \
      ;
  '';

  meta = {
    description = "hgrep is a grep tool with human-friendly search output. This is similar to `-C` option of `grep` command, but its output is enhanced with syntax highlighting focusing on human readable outputs.";
    homepage = "https://github.com/rhysd/hgrep";
    changelog = "https://github.com/rhysd/hgrep/raw/v${version}/CHANGELOG.md";
    license = lib.licenses.mit;
    mainProgram = "hgrep";
  };
}