{nixpkgs-manual, nixos-manual}: add new test check-nix-code-blocks

This commit is contained in:
Pol Dellaiera 2025-04-11 09:31:45 +02:00 committed by Valentin Gagarin
parent 4d9f964794
commit 58cdd4e315
3 changed files with 41 additions and 1 deletions

View file

@ -12,6 +12,7 @@
nixos-render-docs-redirects,
writeShellScriptBin,
nixpkgs ? { },
markdown-code-runner,
}:
stdenvNoCC.mkDerivation (
@ -119,10 +120,14 @@ stdenvNoCC.mkDerivation (
packages = [
devmode'
nixos-render-docs-redirects'
markdown-code-runner
];
};
tests.manpage-urls = callPackage ../tests/manpage-urls.nix { };
tests = {
manpage-urls = callPackage ../tests/manpage-urls.nix { };
check-nix-code-blocks = callPackage ../tests/check-nix-code-blocks.nix { };
};
};
}
)

View file

@ -0,0 +1,32 @@
{
runCommand,
markdown-code-runner,
nixfmt-rfc-style,
}:
runCommand "manual_check-nix-code-blocks"
{
nativeBuildInputs = [
markdown-code-runner
nixfmt-rfc-style
];
}
''
set +e
mdcr --check --config ${./mdcr-config.toml} ${./..}
if [ $? -ne 0 ]; then
cat <<EOF
Error: `mdcr` command failed. Please make sure the Nix code snippets in Markdown files are correctly formatted.
Run this command from the Nixpkgs repository root for automatic formatting:
mdcr --log debug --config ${toString ./..}/tests/mdcr-config.toml ${toString ./..}
EOF
exit 1
fi
touch "$out"
''

View file

@ -0,0 +1,3 @@
[presets.nixfmt]
language = "nix"
command = ["nixfmt"]