testers.lycheeLinkCheck: add extraArgs

This commit is contained in:
Robert Hensing
2026-05-09 22:55:43 +02:00
parent f9be9e95fb
commit 71a39baee8
3 changed files with 31 additions and 3 deletions

View File

@@ -129,6 +129,13 @@ It has two modes:
Example: `{ "include_verbatim" = true; }`
`extraArgs` (list of strings, optional) {#tester-lycheeLinkCheck-param-extraArgs}
: Extra command line arguments to pass to the `lychee` invocation.
These are passed in both the offline (build) and [`online`](#tester-lycheeLinkCheck-return) modes.
Example: `[ "--format" "json" ]`
`lychee` (derivation, optional) {#tester-lycheeLinkCheck-param-lychee}
: The `lychee` package to use.

View File

@@ -37,6 +37,7 @@ let
remap ? { },
lychee ? deps.lychee,
extraConfig ? { },
extraArgs ? [ ],
}:
stdenv.mkDerivation (finalAttrs: {
name = "lychee-link-check";
@@ -47,6 +48,7 @@ let
cacert
];
configFile = (formats.toml { }).generate "lychee.toml" finalAttrs.passthru.config;
inherit extraArgs;
# These can be overridden with overrideAttrs if needed.
passthru = {
@@ -69,13 +71,13 @@ let
site=${finalAttrs.site}
configFile=${finalAttrs.configFile}
echo Checking links on $site
exec lychee --config $configFile $site "$@"
exec lychee --config $configFile ${lib.escapeShellArgs extraArgs} $site "$@"
'';
};
};
buildCommand = ''
echo Checking internal links on $site
lychee --offline --config $configFile $site
lychee --offline --config $configFile "''${extraArgs[@]}" $site
touch $out
'';
});

View File

@@ -14,10 +14,21 @@ let
check = config.node.pkgs.testers.lycheeLinkCheck {
site = sitePkg;
};
checkJson = config.node.pkgs.testers.lycheeLinkCheck {
site = sitePkg;
extraArgs = [
"--format"
"json"
];
};
in
{
name = "testers-lychee-link-check-run";
nodes.client = { ... }: { };
nodes.client =
{ pkgs, ... }:
{
environment.systemPackages = [ pkgs.jq ];
};
nodes.example = {
networking.firewall.allowedTCPPorts = [ 80 ];
services.nginx = {
@@ -67,5 +78,13 @@ in
client.succeed("""
${lib.getExe check.online}
""")
# EXTRA ARGS CASE: verify extraArgs are passed through to online wrapper
with subtest("extraArgs are passed to the online wrapper"):
client.succeed("""
${lib.getExe checkJson.online} --output /tmp/lychee.json
jq -e .total /tmp/lychee.json
""")
'';
}