From 99a2a29f0ae69c01fdeedd701fd1c6a44123ad3a Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Sat, 25 Apr 2026 16:24:25 +0100 Subject: [PATCH] flake: Use lychee for link checking Introduce [lychee] link checking in the flake.nix checks. Since `nix flake check` is limited by sandboxing, it only checks for internal links. Running `lychee` from the directory will check external links. In the future, this can be done via git hooks. [lychee]: https://github.com/lycheeverse/lychee --- .gitignore | 2 ++ flake.nix | 44 ++++++++++++++++++++++++++++++-------------- lychee.toml | 12 ++++++++++++ 3 files changed, 44 insertions(+), 14 deletions(-) create mode 100644 lychee.toml diff --git a/.gitignore b/.gitignore index 8583d22..a42b609 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules/ result +.lycheecache +.direnv/ diff --git a/flake.nix b/flake.nix index e0ff168..dbd9963 100644 --- a/flake.nix +++ b/flake.nix @@ -26,6 +26,7 @@ buildInputs = (with pkgs; [ asciidoctor + pkgs.lychee nodejs shellcheck yq @@ -35,20 +36,35 @@ ]; }; - checks.grammar = - pkgs.runCommand "grammar-check" { - nativeBuildInputs = - (with pkgs; [ - nearley - nodejs - yq - ]) - ++ [ - nearley + checks = { + grammar = + pkgs.runCommand "grammar-check" { + nativeBuildInputs = + (with pkgs; [ + nearley + nodejs + yq + ]) + ++ [ + nearley + ]; + } '' + ${./0004-general-uri-scheme/data/test/uri-scheme-tester.sh} ${./0004-general-uri-scheme/data} + touch $out + ''; + + links = pkgs.testers.lycheeLinkCheck { + site = pkgs.lib.sources.sourceFilesBySuffices ./. [".md" ".adoc"]; + extraConfig = { + extensions = ["md" "adoc"]; + include_fragments = true; + exclude = [ + "^rad:.*$" + "^web\\+rad:.*$" + "^vscode:.*$" ]; - } '' - ${./0004-general-uri-scheme/data/test/uri-scheme-tester.sh} ${./0004-general-uri-scheme/data} - touch $out - ''; + }; + }; + }; }); } diff --git a/lychee.toml b/lychee.toml new file mode 100644 index 0000000..14afa65 --- /dev/null +++ b/lychee.toml @@ -0,0 +1,12 @@ +extensions = ["md", "adoc"] +include_fragments = true +# Exclude custom URI schemes that lychee cannot resolve +exclude = [ + '^rad:', + '^web\+rad:', + '^vscode:', +] +include_mail = false +timeout = 20 +max_retries = 2 +retry_wait_time = 2