Document dynamic attributes

Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
Shea Levy 2014-01-22 00:33:18 +00:00 committed by Eelco Dolstra
parent 42eb4afd7a
commit 733214144a
2 changed files with 23 additions and 4 deletions

View file

@ -21,6 +21,12 @@
<listitem><para><command>nix-setuid-helper</command> is <listitem><para><command>nix-setuid-helper</command> is
gone.</para></listitem> gone.</para></listitem>
<listitem><para>Now antiquotation is allowed inside of quoted
attribute names (e.g. <literal>set."${foo}"</literal>). In the
case where the attribute name is just a single antiquotation,
the quotes can be dropped (e.g. the above example can be written
<literal>set.${foo}</literal>).</para></listitem>
</itemizedlist> </itemizedlist>
</section> </section>

View file

@ -851,13 +851,26 @@ default value in an attribute selection using the
will evaluate to <literal>"Xyzzy"</literal> because there is no will evaluate to <literal>"Xyzzy"</literal> because there is no
<varname>c</varname> attribute in the set.</para> <varname>c</varname> attribute in the set.</para>
<para>You can use arbitrary string constants as attribute names by <para>You can use arbitrary double-quoted strings as attribute
enclosing them in quotes: names:
<programlisting> <programlisting>
{ "foo bar" = 123; "nix-1.0" = 456; }."foo bar" </programlisting> { "foo ${bar}" = 123; "nix-1.0" = 456; }."foo ${bar}"
</programlisting>
This will evaluate to <literal>123</literal> (Assuming
<literal>bar</literal> is antiquotable). In the case where an
attribute name is just a single antiquotation, the quotes can be
dropped:
<programlisting>
{ foo = 123; }.${bar} or 456 </programlisting>
This will evaluate to <literal>123</literal> if
<literal>bar</literal> evaluates to <literal>"foo"</literal> when
coerced to a string and <literal>456</literal> otherwise (again
assuming <literal>bar</literal> is antiquotable).</para>
This will evaluate to <literal>123</literal>.</para>
</simplesect> </simplesect>