diff options
| -rw-r--r-- | default.nix | 1 | ||||
| -rw-r--r-- | pkgs/hgrep/default.nix | 56 |
2 files changed, 57 insertions, 0 deletions
diff --git a/default.nix b/default.nix index f183158..9c05a71 100644 --- a/default.nix +++ b/default.nix @@ -15,5 +15,6 @@ overlays = import ./overlays; # nixpkgs overlays example-package = pkgs.callPackage ./pkgs/example-package { }; + hgrep = pkgs.callPackage ./pkgs/hgrep { }; reparojson = pkgs.callPackage ./pkgs/reparojson { }; } diff --git a/pkgs/hgrep/default.nix b/pkgs/hgrep/default.nix new file mode 100644 index 0000000..9db9780 --- /dev/null +++ b/pkgs/hgrep/default.nix @@ -0,0 +1,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"; + }; +} |
