From 9f322398b4fbfcd3dbcbbec2257307cb65b9defd Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 4 Nov 2025 01:10:02 +0100 Subject: [PATCH] Run linkcheck as regular passthru test ... and add nix-manual.site attribute for a nice and DRY aftertaste. --- doc/manual/package.nix | 26 ++++++++++++++++++++++++++ flake.nix | 30 +++++++----------------------- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/doc/manual/package.nix b/doc/manual/package.nix index 7d29df3c3..3a201c2f1 100644 --- a/doc/manual/package.nix +++ b/doc/manual/package.nix @@ -18,6 +18,9 @@ # Configuration Options version, + + # `tests` attribute + testers, }: let @@ -87,6 +90,29 @@ mkMesonDerivation (finalAttrs: { echo "doc manual ''$out/share/doc/nix/manual" >> ''$out/nix-support/hydra-build-products ''; + /** + The root of the HTML manual. + E.g. "${nix-manual.site}/index.html" exists. + */ + passthru.site = finalAttrs.finalPackage + "/share/doc/nix/manual"; + + passthru.tests = { + # https://nixos.org/manual/nixpkgs/stable/index.html#tester-lycheeLinkCheck + linkcheck = testers.lycheeLinkCheck { + inherit (finalAttrs.finalPackage) site; + extraConfig = { + exclude = [ + # Exclude auto-generated JSON schema documentation which has + # auto-generated fragment IDs that don't match the link references + ".*/protocols/json/.*\\.html" + # Exclude undocumented builtins + ".*/language/builtins\\.html#builtins-addErrorContext" + ".*/language/builtins\\.html#builtins-appendContext" + ]; + }; + }; + }; + meta = { platforms = lib.platforms.all; }; diff --git a/flake.nix b/flake.nix index 37a51a575..44749f621 100644 --- a/flake.nix +++ b/flake.nix @@ -320,30 +320,14 @@ checks = forAllSystems ( system: - let - pkgs = nixpkgsFor.${system}.native; - in - { - # https://nixos.org/manual/nixpkgs/stable/index.html#tester-lycheeLinkCheck - linkcheck = pkgs.testers.lycheeLinkCheck { - site = self.packages.${system}.nix-manual + "/share/doc/nix/manual"; - extraConfig = { - exclude = [ - # Exclude auto-generated JSON schema documentation which has - # auto-generated fragment IDs that don't match the link references - ".*/protocols/json/.*\\.html" - # Exclude undocumented builtins - ".*/language/builtins\\.html#builtins-addErrorContext" - ".*/language/builtins\\.html#builtins-appendContext" - ]; - }; - }; - } - // (import ./ci/gha/tests { + (import ./ci/gha/tests { inherit system; pkgs = nixpkgsFor.${system}.native; nixFlake = self; }).topLevel + // { + inherit (self.packages.${system}.nix-manual.tests) linkcheck; + } // (lib.optionalAttrs (builtins.elem system linux64BitSystems)) { dockerImage = self.hydraJobs.dockerImage.${system}; } @@ -504,10 +488,10 @@ open-manual = { type = "app"; program = "${pkgs.writeShellScript "open-nix-manual" '' - manual_path="${self.packages.${system}.nix-manual}/share/doc/nix/manual/index.html" - if ! ${opener} "$manual_path"; then + path="${self.packages.${system}.nix-manual.site}/index.html" + if ! ${opener} "$path"; then echo "Failed to open manual with ${opener}. Manual is located at:" - echo "$manual_path" + echo "$path" fi ''}"; meta.description = "Open the Nix manual in your browser";