Skip to content

Commit 9f32239

Browse files
committed
Run linkcheck as regular passthru test
... and add nix-manual.site attribute for a nice and DRY aftertaste.
1 parent e07510e commit 9f32239

File tree

2 files changed

+33
-23
lines changed

2 files changed

+33
-23
lines changed

doc/manual/package.nix

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
# Configuration Options
1919

2020
version,
21+
22+
# `tests` attribute
23+
testers,
2124
}:
2225

2326
let
@@ -87,6 +90,29 @@ mkMesonDerivation (finalAttrs: {
8790
echo "doc manual ''$out/share/doc/nix/manual" >> ''$out/nix-support/hydra-build-products
8891
'';
8992

93+
/**
94+
The root of the HTML manual.
95+
E.g. "${nix-manual.site}/index.html" exists.
96+
*/
97+
passthru.site = finalAttrs.finalPackage + "/share/doc/nix/manual";
98+
99+
passthru.tests = {
100+
# https://nixos.org/manual/nixpkgs/stable/index.html#tester-lycheeLinkCheck
101+
linkcheck = testers.lycheeLinkCheck {
102+
inherit (finalAttrs.finalPackage) site;
103+
extraConfig = {
104+
exclude = [
105+
# Exclude auto-generated JSON schema documentation which has
106+
# auto-generated fragment IDs that don't match the link references
107+
".*/protocols/json/.*\\.html"
108+
# Exclude undocumented builtins
109+
".*/language/builtins\\.html#builtins-addErrorContext"
110+
".*/language/builtins\\.html#builtins-appendContext"
111+
];
112+
};
113+
};
114+
};
115+
90116
meta = {
91117
platforms = lib.platforms.all;
92118
};

flake.nix

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -320,30 +320,14 @@
320320

321321
checks = forAllSystems (
322322
system:
323-
let
324-
pkgs = nixpkgsFor.${system}.native;
325-
in
326-
{
327-
# https://nixos.org/manual/nixpkgs/stable/index.html#tester-lycheeLinkCheck
328-
linkcheck = pkgs.testers.lycheeLinkCheck {
329-
site = self.packages.${system}.nix-manual + "/share/doc/nix/manual";
330-
extraConfig = {
331-
exclude = [
332-
# Exclude auto-generated JSON schema documentation which has
333-
# auto-generated fragment IDs that don't match the link references
334-
".*/protocols/json/.*\\.html"
335-
# Exclude undocumented builtins
336-
".*/language/builtins\\.html#builtins-addErrorContext"
337-
".*/language/builtins\\.html#builtins-appendContext"
338-
];
339-
};
340-
};
341-
}
342-
// (import ./ci/gha/tests {
323+
(import ./ci/gha/tests {
343324
inherit system;
344325
pkgs = nixpkgsFor.${system}.native;
345326
nixFlake = self;
346327
}).topLevel
328+
// {
329+
inherit (self.packages.${system}.nix-manual.tests) linkcheck;
330+
}
347331
// (lib.optionalAttrs (builtins.elem system linux64BitSystems)) {
348332
dockerImage = self.hydraJobs.dockerImage.${system};
349333
}
@@ -504,10 +488,10 @@
504488
open-manual = {
505489
type = "app";
506490
program = "${pkgs.writeShellScript "open-nix-manual" ''
507-
manual_path="${self.packages.${system}.nix-manual}/share/doc/nix/manual/index.html"
508-
if ! ${opener} "$manual_path"; then
491+
path="${self.packages.${system}.nix-manual.site}/index.html"
492+
if ! ${opener} "$path"; then
509493
echo "Failed to open manual with ${opener}. Manual is located at:"
510-
echo "$manual_path"
494+
echo "$path"
511495
fi
512496
''}";
513497
meta.description = "Open the Nix manual in your browser";

0 commit comments

Comments
 (0)