Skip to content

Commit

Permalink
Merge pull request cachix#351 from totoroot/add-lychee-hook
Browse files Browse the repository at this point in the history
Add pre-commit hook for lychee (fast link checker)
  • Loading branch information
domenkozar authored Sep 10, 2023
2 parents 58e22ea + bc3a057 commit 4f883a7
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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" ];
};
};
}

0 comments on commit 4f883a7

Please sign in to comment.