From bc3a057e5738e336f8b7569c95d35487d5d5eeb5 Mon Sep 17 00:00:00 2001 From: Matthias Thym Date: Sat, 9 Sep 2023 16:34:02 +0200 Subject: [PATCH] Add pre-commit hook for lychee (fast link checker) --- modules/hooks.nix | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/modules/hooks.nix b/modules/hooks.nix index 5c29d892..d64050ea 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -722,6 +722,22 @@ in default = ""; }; }; + + lychee = { + configPath = + mkOption { + type = types.str; + description = lib.mdDoc "Path to the config file."; + default = ""; + }; + + flags = + mkOption { + type = types.str; + description = lib.mdDoc "Flags passed to lychee. See all available [here](https://lychee.cli.rs/#/usage/cli)."; + default = ""; + }; + }; }; config.hooks = @@ -1802,5 +1818,20 @@ in entry = "${tools.crystal}/bin/crystal tool format"; files = "\\.cr$"; }; + + lychee = { + name = "lychee"; + description = "A fast, async, stream-based link checker that finds broken hyperlinks and mail adresses inside Markdown, HTML, reStructuredText, or any other text file or website."; + entry = + let + cmdArgs = + mkCmdArgs + (with settings.lychee; [ + [ (configPath != "") " --config ${configPath}" ] + ]); + in + "${pkgs.lychee}/bin/lychee${cmdArgs} ${settings.lychee.flags}"; + types = [ "text" ]; + }; }; }