mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
testers.lycheeLinkCheck: Add online attribute for nix run
(cherry picked from commit c2ebd3ea60
)
This commit is contained in:
parent
bf8c7334f8
commit
8567fac505
@ -44,7 +44,13 @@ If the `moduleNames` argument is omitted, `hasPkgConfigModules` will use `meta.p
|
||||
|
||||
Check that internal hyperlinks are correct, using the [`lychee` package](https://search.nixos.org/packages?show=lychee&type=packages&query=lychee).
|
||||
|
||||
Only an offline check is performed, so that network access is not required.
|
||||
When building the check, only an offline check is performed, so that network access is not required.
|
||||
|
||||
If you'd like to run the check with network access, the returned attribute `online` can be invoked with [`nix run`](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-run) ([experimental](https://nixos.org/manual/nix/stable/contributing/experimental-features#xp-feature-nix-command)). For example:
|
||||
|
||||
```shell
|
||||
nix run nixpkgs#lychee.tests.ok.online
|
||||
```
|
||||
|
||||
:::{.example #ex-lycheelinkcheck}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
deps@{ formats, lib, lychee, stdenv }:
|
||||
deps@{ formats, lib, lychee, stdenv, writeShellApplication }:
|
||||
let
|
||||
|
||||
# See https://nixos.org/manual/nixpkgs/unstable/#tester-lycheeLinkCheck
|
||||
@ -23,6 +23,18 @@ let
|
||||
} // lib.optionalAttrs (finalAttrs.passthru.remapUrl != null) {
|
||||
remap = [ "${remapUrl} file://${finalAttrs.site}" ];
|
||||
} // extraConfig;
|
||||
online = writeShellApplication {
|
||||
name = "run-lychee-online";
|
||||
runtimeInputs = [ finalAttrs.passthru.lychee ];
|
||||
# Comment out to run shellcheck:
|
||||
checkPhase = "";
|
||||
text = ''
|
||||
site=${finalAttrs.site}
|
||||
configFile=${finalAttrs.configFile}
|
||||
echo Checking links on $site
|
||||
exec lychee --config $configFile $site "$@"
|
||||
'';
|
||||
};
|
||||
};
|
||||
buildCommand = ''
|
||||
echo Checking internal links on $site
|
||||
|
Loading…
Reference in New Issue
Block a user