Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / by-name / ba / bat / package.nix
blob29de95279e283db199c114fdf3cb96bd09191076
1 { lib
2 , stdenv
3 , rustPlatform
4 , fetchFromGitHub
5 , pkg-config
6 , less
7 , libiconv
8 , installShellFiles
9 , makeWrapper
10 , darwin
13 rustPlatform.buildRustPackage rec {
14   pname = "bat";
15   version = "0.24.0";
17   src = fetchFromGitHub {
18     owner = "sharkdp";
19     repo = "bat";
20     rev = "v${version}";
21     hash = "sha256-1RjlJEmY/jMf0IYQbrWrT1CHFyiqgarOl72u9xjjQiQ=";
22   };
23   cargoHash = "sha256-b7wNWdKQ4QLeCf7bNZRfzT9hD/D/oDglU7Xyb65IrGY=";
25   nativeBuildInputs = [ pkg-config installShellFiles makeWrapper ];
27   buildInputs = lib.optionals stdenv.isDarwin [ libiconv darwin.apple_sdk.frameworks.Security ];
29   postInstall = ''
30     installManPage $releaseDir/build/bat-*/out/assets/manual/bat.1
31     installShellCompletion $releaseDir/build/bat-*/out/assets/completions/bat.{bash,fish,zsh}
32   '';
34   # Insert Nix-built `less` into PATH because the system-provided one may be too old to behave as
35   # expected with certain flag combinations.
36   postFixup = ''
37     wrapProgram "$out/bin/bat" \
38       --prefix PATH : "${lib.makeBinPath [ less ]}"
39   '';
41   # Skip test cases which depends on `more`
42   checkFlags = [
43     "--skip=alias_pager_disable_long_overrides_short"
44     "--skip=config_read_arguments_from_file"
45     "--skip=env_var_bat_paging"
46     "--skip=pager_arg_override_env_noconfig"
47     "--skip=pager_arg_override_env_withconfig"
48     "--skip=pager_basic"
49     "--skip=pager_basic_arg"
50     "--skip=pager_env_bat_pager_override_config"
51     "--skip=pager_env_pager_nooverride_config"
52     "--skip=pager_more"
53     "--skip=pager_most"
54     "--skip=pager_overwrite"
55   ];
57   doInstallCheck = true;
58   installCheckPhase = ''
59     runHook preInstallCheck
61     testFile=$(mktemp /tmp/bat-test.XXXX)
62     echo -ne 'Foobar\n\n\n42' > $testFile
63     $out/bin/bat -p $testFile | grep "Foobar"
64     $out/bin/bat -p $testFile -r 4:4 | grep 42
65     rm $testFile
67     runHook postInstallCheck
68   '';
70   meta = with lib; {
71     description = "A cat(1) clone with syntax highlighting and Git integration";
72     homepage = "https://github.com/sharkdp/bat";
73     changelog = "https://github.com/sharkdp/bat/raw/v${version}/CHANGELOG.md";
74     license = with licenses; [ asl20 /* or */ mit ];
75     mainProgram = "bat";
76     maintainers = with maintainers; [ dywedir lilyball zowoq SuperSandro2000 ];
77   };