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; }` 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} `lychee` (derivation, optional) {#tester-lycheeLinkCheck-param-lychee}
: The `lychee` package to use. : The `lychee` package to use.

View File

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

View File

@@ -14,10 +14,21 @@ let
check = config.node.pkgs.testers.lycheeLinkCheck { check = config.node.pkgs.testers.lycheeLinkCheck {
site = sitePkg; site = sitePkg;
}; };
checkJson = config.node.pkgs.testers.lycheeLinkCheck {
site = sitePkg;
extraArgs = [
"--format"
"json"
];
};
in in
{ {
name = "testers-lychee-link-check-run"; name = "testers-lychee-link-check-run";
nodes.client = { ... }: { }; nodes.client =
{ pkgs, ... }:
{
environment.systemPackages = [ pkgs.jq ];
};
nodes.example = { nodes.example = {
networking.firewall.allowedTCPPorts = [ 80 ]; networking.firewall.allowedTCPPorts = [ 80 ];
services.nginx = { services.nginx = {
@@ -67,5 +78,13 @@ in
client.succeed(""" client.succeed("""
${lib.getExe check.online} ${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
""")
''; '';
} }