1{
2 lib,
3 curl,
4 stdenv,
5 fetchFromGitHub,
6 rustPlatform,
7 pkg-config,
8 asciidoctor,
9 openssl,
10 ansi2html,
11 installShellFiles,
12}:
13
14rustPlatform.buildRustPackage rec {
15 pname = "mdcat";
16 version = "2.7.1";
17
18 src = fetchFromGitHub {
19 owner = "swsnr";
20 repo = "mdcat";
21 rev = "mdcat-${version}";
22 hash = "sha256-j6BFXx5cyjE3+fo1gGKlqpsxrm3i9HfQ9tJGNNjjLwo=";
23 };
24
25 nativeBuildInputs = [
26 pkg-config
27 asciidoctor
28 installShellFiles
29 ];
30 buildInputs = [
31 curl
32 openssl
33 ];
34
35 cargoHash = "sha256-8A0RLbFkh3fruZAbjJzipQvuFLchqIRovPcc6MSKdOc=";
36
37 nativeCheckInputs = [ ansi2html ];
38 # Skip tests that use the network and that include files.
39 checkFlags = [
40 "--skip magic::tests::detect_mimetype_of_larger_than_magic_param_bytes_max_length"
41 "--skip magic::tests::detect_mimetype_of_magic_param_bytes_max_length"
42 "--skip magic::tests::detect_mimetype_of_png_image"
43 "--skip magic::tests::detect_mimetype_of_svg_image"
44 "--skip resources::tests::read_url_with_http_url_fails_when_size_limit_is_exceeded"
45 "--skip resources::tests::read_url_with_http_url_fails_when_status_404"
46 "--skip resources::tests::read_url_with_http_url_returns_content_when_status_200"
47 "--skip iterm2_tests_render_md_samples_images_md"
48 ];
49
50 postInstall = ''
51 installManPage $releaseDir/build/mdcat-*/out/mdcat.1
52 ln -sr $out/bin/{mdcat,mdless}
53 ''
54 + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
55 for bin in mdcat mdless; do
56 installShellCompletion --cmd $bin \
57 --bash <($out/bin/$bin --completions bash) \
58 --fish <($out/bin/$bin --completions fish) \
59 --zsh <($out/bin/$bin --completions zsh)
60 done
61 '';
62
63 meta = with lib; {
64 description = "cat for markdown";
65 homepage = "https://github.com/swsnr/mdcat";
66 changelog = "https://github.com/swsnr/mdcat/releases/tag/mdcat-${version}";
67 license = with licenses; [ mpl20 ];
68 maintainers = with maintainers; [ SuperSandro2000 ];
69 };
70}