Document attrsets.recurseIntoAttrs

This commit is contained in:
Robert Hensing 2019-09-11 14:51:28 +02:00
parent fc64cf65ab
commit a96f37db10
3 changed files with 47 additions and 2 deletions

View file

@ -1728,4 +1728,48 @@ recursiveUpdate
]]></programlisting>
</example>
</section>
<section xml:id="function-library-lib.attrsets.recurseIntoAttrs">
<title><function>lib.attrsets.recurseIntoAttrs</function></title>
<subtitle><literal>recurseIntoAttrs :: AttrSet -> AttrSet</literal>
</subtitle>
<xi:include href="./locations.xml" xpointer="lib.attrsets.recurseIntoAttrs" />
<para>
Make various Nix tools consider the contents of the resulting
attribute set when looking for what to build, find, etc.
</para>
<para>
This function only affects a single attribute set; it does not apply itself recursively for nested attribute sets.
</para>
<variablelist>
<varlistentry>
<term>
<varname>attrs</varname>
</term>
<listitem>
<para>
An attribute set to scan for derivations.
</para>
</listitem>
</varlistentry>
</variablelist>
<example xml:id="function-library-lib.attrsets.recurseIntoAttrs-example">
<title>Making Nix look inside an attribute set</title>
<programlisting><![CDATA[
{ pkgs ? import <nixpkgs> {} }:
{
myTools = pkgs.lib.recurseIntoAttrs {
inherit (pkgs) hello figlet;
};
}
]]></programlisting>
</example>
</section>
</section>

View file

@ -475,6 +475,9 @@ rec {
/* Make various Nix tools consider the contents of the resulting
attribute set when looking for what to build, find, etc.
This function only affects a single attribute set; it does not
apply itself recursively for nested attribute sets.
*/
recurseIntoAttrs =
attrs: attrs // { recurseForDerivations = true; };

View file

@ -62,8 +62,6 @@ in
inherit (lib) lowPrio hiPrio appendToName makeOverridable;
# Make various Nix tools consider the contents of the resulting
# attribute set when looking for what to build, find, etc.
inherit (lib) recurseIntoAttrs;
# This is intended to be the reverse of recurseIntoAttrs, as it is