about summary refs log tree commit diff
path: root/pkgs/tools/misc/bat
diff options
context:
space:
mode:
authorLily Ballard <lily@sb.org>2019-12-22 17:25:31 -0800
committerLily Ballard <lily@sb.org>2019-12-22 17:25:31 -0800
commit8a9fb54f07cb593aaac5a3f74e4a17cc831b16e0 (patch)
treee61c76cb09f02fdc35c16bee91dd98d732b4e083 /pkgs/tools/misc/bat
parent7887a811935a4b1cf11f6869d715603ca5e3f56c (diff)
bat: insert less into PATH
The default pager for `bat` is `less -RF --no-init`. Overriding this to
`less -RF` in order to enable alternate screen behavior (e.g. page
up/down keys) causes the `-F` flag to behave badly in the version of
`less` shipped on macOS. The simplest way to fix this is to simply put
Nix's `less` into the `PATH` so it takes precedence.
Diffstat (limited to 'pkgs/tools/misc/bat')
-rw-r--r--pkgs/tools/misc/bat/default.nix13
1 files changed, 10 insertions, 3 deletions
diff --git a/pkgs/tools/misc/bat/default.nix b/pkgs/tools/misc/bat/default.nix
index 6b62ca247cb0f..6f5dc209b9643 100644
--- a/pkgs/tools/misc/bat/default.nix
+++ b/pkgs/tools/misc/bat/default.nix
@@ -1,5 +1,5 @@
-{ stdenv, rustPlatform, fetchFromGitHub, llvmPackages, pkgconfig
-, Security, libiconv, installShellFiles
+{ stdenv, rustPlatform, fetchFromGitHub, llvmPackages, pkgconfig, less
+, Security, libiconv, installShellFiles, makeWrapper
 }:
 
 rustPlatform.buildRustPackage rec {
@@ -16,7 +16,7 @@ rustPlatform.buildRustPackage rec {
 
   cargoSha256 = "0d7h0kn41w6wm4w63vjy2i7r19jkansfvfjn7vgh2gqh5m60kal2";
 
-  nativeBuildInputs = [ pkgconfig llvmPackages.libclang installShellFiles ];
+  nativeBuildInputs = [ pkgconfig llvmPackages.libclang installShellFiles makeWrapper ];
 
   buildInputs = stdenv.lib.optionals stdenv.isDarwin [ Security libiconv ];
 
@@ -27,6 +27,13 @@ rustPlatform.buildRustPackage rec {
     installShellCompletion assets/completions/bat.fish
   '';
 
+  # Insert Nix-built `less` into PATH because the system-provided one may be too old to behave as
+  # expected with certain flag combinations.
+  postFixup = ''
+    wrapProgram "$out/bin/bat" \
+      --prefix PATH : "${stdenv.lib.makeBinPath [ less ]}"
+  '';
+
   meta = with stdenv.lib; {
     description = "A cat(1) clone with syntax highlighting and Git integration";
     homepage    = https://github.com/sharkdp/bat;