nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 98 lines 2.5 kB view raw
1{ 2 lib, 3 rustPlatform, 4 fetchFromGitHub, 5 pkg-config, 6 less, 7 installShellFiles, 8 makeWrapper, 9 zlib, 10 versionCheckHook, 11}: 12 13rustPlatform.buildRustPackage (finalAttrs: { 14 pname = "bat"; 15 version = "0.26.1"; 16 17 src = fetchFromGitHub { 18 owner = "sharkdp"; 19 repo = "bat"; 20 rev = "v${finalAttrs.version}"; 21 hash = "sha256-IbTvFT37BFo0tKOiApDL9sT+/nMD33MO3TXuho+lF2c="; 22 }; 23 24 cargoHash = "sha256-WRLCs1hrwFT3tya9CzKUuh5g+6fYqKDtv3yvDx8Wws8="; 25 26 nativeBuildInputs = [ 27 pkg-config 28 installShellFiles 29 makeWrapper 30 ]; 31 32 buildInputs = [ 33 zlib 34 ]; 35 36 postInstall = '' 37 installManPage $releaseDir/build/bat-*/out/assets/manual/bat.1 38 installShellCompletion $releaseDir/build/bat-*/out/assets/completions/bat.{bash,fish,zsh} 39 ''; 40 41 # Insert Nix-built `less` into PATH because the system-provided one may be too old to behave as 42 # expected with certain flag combinations. 43 postFixup = '' 44 wrapProgram "$out/bin/bat" \ 45 --prefix PATH : "${lib.makeBinPath [ less ]}" 46 ''; 47 48 # Skip test cases which depends on `more` 49 checkFlags = [ 50 "--skip=alias_pager_disable_long_overrides_short" 51 "--skip=config_read_arguments_from_file" 52 "--skip=env_var_bat_paging" 53 "--skip=pager_arg_override_env_noconfig" 54 "--skip=pager_arg_override_env_withconfig" 55 "--skip=pager_basic" 56 "--skip=pager_basic_arg" 57 "--skip=pager_env_bat_pager_override_config" 58 "--skip=pager_env_pager_nooverride_config" 59 "--skip=pager_more" 60 "--skip=pager_most" 61 "--skip=pager_overwrite" 62 # Fails if the filesystem performs UTF-8 validation (such as ZFS with utf8only=on) 63 "--skip=file_with_invalid_utf8_filename" 64 ]; 65 66 nativeInstallCheckInputs = [ 67 versionCheckHook 68 ]; 69 doInstallCheck = true; 70 installCheckPhase = '' 71 runHook preInstallCheck 72 73 testFile=$(mktemp /tmp/bat-test.XXXX) 74 echo -ne 'Foobar\n\n\n42' > $testFile 75 $out/bin/bat -p $testFile | grep "Foobar" 76 $out/bin/bat -p $testFile -r 4:4 | grep 42 77 rm $testFile 78 79 runHook postInstallCheck 80 ''; 81 82 meta = { 83 description = "Cat(1) clone with syntax highlighting and Git integration"; 84 homepage = "https://github.com/sharkdp/bat"; 85 changelog = "https://github.com/sharkdp/bat/raw/v${finalAttrs.version}/CHANGELOG.md"; 86 license = with lib.licenses; [ 87 asl20 # or 88 mit 89 ]; 90 mainProgram = "bat"; 91 maintainers = with lib.maintainers; [ 92 dywedir 93 zowoq 94 SuperSandro2000 95 sigmasquadron 96 ]; 97 }; 98})