nixos/doc: Wire up the test options reference
This commit is contained in:
parent
6205d37747
commit
ac03757eb2
@ -38,6 +38,33 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nixos-lib = import ../../lib { };
|
||||||
|
|
||||||
|
testOptionsDoc = let
|
||||||
|
eval = nixos-lib.evalTest {
|
||||||
|
# Avoid evaluating a NixOS config prototype.
|
||||||
|
config.node.type = lib.types.deferredModule;
|
||||||
|
options._module.args = lib.mkOption { internal = true; };
|
||||||
|
};
|
||||||
|
in buildPackages.nixosOptionsDoc {
|
||||||
|
inherit (eval) options;
|
||||||
|
inherit (revision);
|
||||||
|
transformOptions = opt: opt // {
|
||||||
|
# Clean up declaration sites to not refer to the NixOS source tree.
|
||||||
|
declarations =
|
||||||
|
map
|
||||||
|
(decl:
|
||||||
|
if hasPrefix (toString ../../..) (toString decl)
|
||||||
|
then
|
||||||
|
let subpath = removePrefix "/" (removePrefix (toString ../../..) (toString decl));
|
||||||
|
in { url = "https://github.com/NixOS/nixpkgs/blob/master/${subpath}"; name = subpath; }
|
||||||
|
else decl)
|
||||||
|
opt.declarations;
|
||||||
|
};
|
||||||
|
documentType = "none";
|
||||||
|
variablelistId = "test-options-list";
|
||||||
|
};
|
||||||
|
|
||||||
sources = lib.sourceFilesBySuffices ./. [".xml"];
|
sources = lib.sourceFilesBySuffices ./. [".xml"];
|
||||||
|
|
||||||
modulesDoc = builtins.toFile "modules.xml" ''
|
modulesDoc = builtins.toFile "modules.xml" ''
|
||||||
@ -52,6 +79,7 @@ let
|
|||||||
mkdir $out
|
mkdir $out
|
||||||
ln -s ${modulesDoc} $out/modules.xml
|
ln -s ${modulesDoc} $out/modules.xml
|
||||||
ln -s ${optionsDoc.optionsDocBook} $out/options-db.xml
|
ln -s ${optionsDoc.optionsDocBook} $out/options-db.xml
|
||||||
|
ln -s ${testOptionsDoc.optionsDocBook} $out/test-options-db.xml
|
||||||
printf "%s" "${version}" > $out/version
|
printf "%s" "${version}" > $out/version
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -52,7 +52,6 @@ Tests that are part of NixOS are added to [`nixos/tests/all-tests.nix`](https://
|
|||||||
```
|
```
|
||||||
|
|
||||||
Overrides can be added by defining an anonymous module in `all-tests.nix`.
|
Overrides can be added by defining an anonymous module in `all-tests.nix`.
|
||||||
For the purpose of constructing a test matrix, use the `matrix` options instead.
|
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
hostname = runTest { imports = [ ./hostname.nix ]; defaults.networking.firewall.enable = false; };
|
hostname = runTest { imports = [ ./hostname.nix ]; defaults.networking.firewall.enable = false; };
|
||||||
@ -476,3 +475,11 @@ added using the parameter `extraPythonPackages`. For example, you could add
|
|||||||
```
|
```
|
||||||
|
|
||||||
In that case, `numpy` is chosen from the generic `python3Packages`.
|
In that case, `numpy` is chosen from the generic `python3Packages`.
|
||||||
|
|
||||||
|
## Test Options Reference {#sec-test-options-reference}
|
||||||
|
|
||||||
|
The following options can be used when writing tests.
|
||||||
|
|
||||||
|
```{=docbook}
|
||||||
|
<xi:include href="../../generated/test-options-db.xml" xpointer="test-options-list"/>
|
||||||
|
```
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-writing-nixos-tests">
|
<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="sec-writing-nixos-tests">
|
||||||
<title>Writing Tests</title>
|
<title>Writing Tests</title>
|
||||||
<para>
|
<para>
|
||||||
A NixOS test is a module that has the following structure:
|
A NixOS test is a module that has the following structure:
|
||||||
@ -67,9 +67,7 @@
|
|||||||
</programlisting>
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
Overrides can be added by defining an anonymous module in
|
Overrides can be added by defining an anonymous module in
|
||||||
<literal>all-tests.nix</literal>. For the purpose of
|
<literal>all-tests.nix</literal>.
|
||||||
constructing a test matrix, use the <literal>matrix</literal>
|
|
||||||
options instead.
|
|
||||||
</para>
|
</para>
|
||||||
<programlisting language="bash">
|
<programlisting language="bash">
|
||||||
hostname = runTest { imports = [ ./hostname.nix ]; defaults.networking.firewall.enable = false; };
|
hostname = runTest { imports = [ ./hostname.nix ]; defaults.networking.firewall.enable = false; };
|
||||||
@ -770,4 +768,11 @@ def foo_running():
|
|||||||
<literal>python3Packages</literal>.
|
<literal>python3Packages</literal>.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
|
<section xml:id="sec-test-options-reference">
|
||||||
|
<title>Test Options Reference</title>
|
||||||
|
<para>
|
||||||
|
The following options can be used when writing tests.
|
||||||
|
</para>
|
||||||
|
<xi:include href="../../generated/test-options-db.xml" xpointer="test-options-list"/>
|
||||||
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
Loading…
Reference in New Issue
Block a user