diff options
author | pennae <github@quasiparticle.net> | 2021-11-19 00:26:27 +0100 |
---|---|---|
committer | pennae <github@quasiparticle.net> | 2022-01-02 19:46:13 +0100 |
commit | fc614c37c653637e5475a0b0a987489b4d1f351d (patch) | |
tree | 7b2470a3a67979ddcc51f18bb0d424f8e95908b1 /nixos/doc/manual/from_md/development | |
parent | 55daffc1c943bddb71dc89a606f8284f6d50f5bd (diff) | |
download | nixpkgs-fc614c37c653637e5475a0b0a987489b4d1f351d.tar nixpkgs-fc614c37c653637e5475a0b0a987489b4d1f351d.tar.gz nixpkgs-fc614c37c653637e5475a0b0a987489b4d1f351d.tar.bz2 nixpkgs-fc614c37c653637e5475a0b0a987489b4d1f351d.tar.lz nixpkgs-fc614c37c653637e5475a0b0a987489b4d1f351d.tar.xz nixpkgs-fc614c37c653637e5475a0b0a987489b4d1f351d.tar.zst nixpkgs-fc614c37c653637e5475a0b0a987489b4d1f351d.zip |
nixos/documentation: split options doc build
most modules can be evaluated for their documentation in a very restricted environment that doesn't include all of nixpkgs. this evaluation can then be cached and reused for subsequent builds, merging only documentation that has changed into the cached set. since nixos ships with a large number of modules of which only a few are used in any given config this can save evaluation a huge percentage of nixos options available in any given config. in tests of this caching, despite having to copy most of nixos/, saves about 80% of the time needed to build the system manual, or about two second on the machine used for testing. build time for a full system config shrank from 9.4s to 7.4s, while turning documentation off entirely shortened the build to 7.1s.
Diffstat (limited to 'nixos/doc/manual/from_md/development')
-rw-r--r-- | nixos/doc/manual/from_md/development/meta-attributes.section.xml | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/nixos/doc/manual/from_md/development/meta-attributes.section.xml b/nixos/doc/manual/from_md/development/meta-attributes.section.xml index f535d94602b..1eb6e0f3036 100644 --- a/nixos/doc/manual/from_md/development/meta-attributes.section.xml +++ b/nixos/doc/manual/from_md/development/meta-attributes.section.xml @@ -8,8 +8,8 @@ <para> <literal>meta</literal> is a top level attribute like <literal>options</literal> and <literal>config</literal>. Available - meta-attributes are <literal>maintainers</literal> and - <literal>doc</literal>. + meta-attributes are <literal>maintainers</literal>, + <literal>doc</literal>, and <literal>buildDocsInSandbox</literal>. </para> <para> Each of the meta-attributes must be defined at most once per module @@ -29,6 +29,7 @@ meta = { maintainers = with lib.maintainers; [ ericsagnes ]; doc = ./default.xml; + buildDocsInSandbox = true; }; } </programlisting> @@ -51,5 +52,44 @@ $ nix-build nixos/release.nix -A manual.x86_64-linux </programlisting> </listitem> + <listitem> + <para> + <literal>buildDocsInSandbox</literal> indicates whether the + option documentation for the module can be built in a derivation + sandbox. This option is currently only honored for modules + shipped by nixpkgs. User modules and modules taken from + <literal>NIXOS_EXTRA_MODULE_PATH</literal> are always built + outside of the sandbox, as has been the case in previous + releases. + </para> + <para> + Building NixOS option documentation in a sandbox allows caching + of the built documentation, which greatly decreases the amount + of time needed to evaluate a system configuration that has NixOS + documentation enabled. The sandbox also restricts which + attributes may be referenced by documentation attributes (such + as option descriptions) to the <literal>options</literal> and + <literal>lib</literal> module arguments and the + <literal>pkgs.formats</literal> attribute of the + <literal>pkgs</literal> argument, <literal>config</literal> and + the rest of <literal>pkgs</literal> are disallowed and will + cause doc build failures when used. This restriction is + necessary because we cannot reproduce the full nixpkgs + instantiation with configuration and overlays from a system + configuration inside the sandbox. The <literal>options</literal> + argument only includes options of modules that are also built + inside the sandbox, referencing an option of a module that isn’t + built in the sandbox is also forbidden. + </para> + <para> + The default is <literal>true</literal> and should usually not be + changed; set it to <literal>false</literal> only if the module + requires access to <literal>pkgs</literal> in its documentation + (e.g. because it loads information from a linked package to + build an option type) or if its documentation depends on other + modules that also aren’t sandboxed (e.g. by using types defined + in the other module). + </para> + </listitem> </itemizedlist> </section> |