Merge master into staging-next

This commit is contained in:
github-actions[bot] 2025-01-15 00:14:20 +00:00 committed by GitHub
commit 9129b13110
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
84 changed files with 2639 additions and 672 deletions

View file

@ -1,3 +1,5 @@
# Tests: ./tests.nix
/**
Generates documentation for [nix modules](https://nix.dev/tutorials/module-system/index.html).
@ -193,12 +195,16 @@ rec {
optionsCommonMark =
pkgs.runCommand "options.md"
{
__structuredAttrs = true;
nativeBuildInputs = [ pkgs.nixos-render-docs ];
# For overriding
extraArgs = [ ];
}
''
nixos-render-docs -j $NIX_BUILD_CORES options commonmark \
--manpage-urls ${pkgs.path + "/doc/manpage-urls.json"} \
--revision ${lib.escapeShellArg revision} \
''${extraArgs[@]} \
${optionsJSON}/share/doc/nixos/options.json \
$out
'';

View file

@ -0,0 +1,59 @@
# Run tests: nix-build -A tests.nixosOptionsDoc
{
lib,
nixosOptionsDoc,
runCommand,
}:
let
inherit (lib) mkOption types;
eval = lib.evalModules {
modules = [
{
options.foo.bar.enable = mkOption {
type = types.bool;
default = false;
description = ''
Enable the foo bar feature.
'';
};
}
];
};
doc = nixosOptionsDoc {
inherit (eval) options;
};
in
{
/**
Test that
- the `nixosOptionsDoc` function can be invoked
- integration of the module system and `nixosOptionsDoc` (limited coverage)
The more interesting tests happen in the `nixos-render-docs` package.
*/
commonMark =
runCommand "test-nixosOptionsDoc-commonMark"
{
commonMarkDefault = doc.optionsCommonMark;
commonMarkAnchors = doc.optionsCommonMark.overrideAttrs {
extraArgs = [
"--anchor-prefix"
"my-opt-"
"--anchor-style"
"legacy"
];
};
}
''
env | grep ^commonMark | sed -e 's/=/ = /'
(
set -x
grep -F 'foo\.bar\.enable' $commonMarkDefault >/dev/null
grep -F '{#my-opt-foo.bar.enable}' $commonMarkAnchors >/dev/null
)
touch $out
'';
}