about summary refs log tree commit diff
path: root/pkgs/tools/text/markdownlint-cli2/default.nix
blob: 90a4b871cbc19a1c957ac86a9a9e5eafdd3d1e6f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
  lib,
  stdenvNoCC,
  fetchurl,
  makeWrapper,
  markdownlint-cli2,
  nodejs,
  runCommand,
  zstd,
}:

stdenvNoCC.mkDerivation (finalAttrs: {
  pname = "markdownlint-cli2";
  version = "0.13.0";

  # upstream is not interested in including package-lock.json in the source
  # https://github.com/DavidAnson/markdownlint-cli2/issues/198#issuecomment-1690529976
  # see also https://github.com/DavidAnson/markdownlint-cli2/issues/186
  # so use the tarball from the archlinux mirror
  src = fetchurl {
    url = "https://us.mirrors.cicku.me/archlinux/extra/os/x86_64/markdownlint-cli2-${finalAttrs.version}-1-any.pkg.tar.zst";
    hash = "sha256-ioSVse3fS6n2wauZ0VsF6TQKy/ZsyLACQ4anNybIe+I=";
  };

  nativeBuildInputs = [
    makeWrapper
    zstd
  ];

  dontBuild = true;

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    cp -r lib share $out
    makeWrapper "${lib.getExe nodejs}" "$out/bin/markdownlint-cli2" \
      --add-flags "$out/lib/node_modules/markdownlint-cli2/markdownlint-cli2.js"

    runHook postInstall
  '';

  passthru.tests = {
    smoke = runCommand "${finalAttrs.pname}-test" { nativeBuildInputs = [ markdownlint-cli2 ]; } ''
      markdownlint-cli2 ${markdownlint-cli2}/share/doc/markdownlint-cli2/README.md > $out
    '';
  };

  meta = {
    changelog = "https://github.com/DavidAnson/markdownlint-cli2/blob/v${finalAttrs.version}/CHANGELOG.md";
    description = "Fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files with the markdownlint library";
    homepage = "https://github.com/DavidAnson/markdownlint-cli2";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ natsukium ];
  };
})