diff options
Diffstat (limited to 'pkgs/tools/text/markdownlint-cli2/default.nix')
-rw-r--r-- | pkgs/tools/text/markdownlint-cli2/default.nix | 57 |
1 files changed, 41 insertions, 16 deletions
diff --git a/pkgs/tools/text/markdownlint-cli2/default.nix b/pkgs/tools/text/markdownlint-cli2/default.nix index 7ffacaa08db75..d98d3a9f29c6d 100644 --- a/pkgs/tools/text/markdownlint-cli2/default.nix +++ b/pkgs/tools/text/markdownlint-cli2/default.nix @@ -1,32 +1,57 @@ -{ lib -, buildNpmPackage -, fetchFromGitHub +{ + lib, + stdenvNoCC, + fetchurl, + makeWrapper, + markdownlint-cli2, + nodejs, + runCommand, + zstd, }: -buildNpmPackage rec { +stdenvNoCC.mkDerivation (finalAttrs: { pname = "markdownlint-cli2"; - version = "0.9.0"; + version = "0.13.0"; - src = fetchFromGitHub { - owner = "DavidAnson"; - repo = "markdownlint-cli2"; - rev = "v${version}"; - hash = "sha256-qtdR7Rhz+HLZJX82OrN+twOsvFOv99e4BBDVV1UayPI="; + # 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="; }; - npmDepsHash = "sha256-Fx0lDcvzLRVSAX0apKmu1CBfnGmGQR9FQEdhHUtue/c="; + nativeBuildInputs = [ + makeWrapper + zstd + ]; - postPatch = '' - ln -s npm-shrinkwrap.json package-lock.json + 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 ''; - dontNpmBuild = true; + 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/${src.rev}/CHANGELOG.md"; + 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 ]; + mainProgram = "markdownlint-cli2"; }; -} +}) |