mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 07:46:21 +02:00
complete example on attribute name interpolation
This commit is contained in:
parent
a67cee965a
commit
a7ba8c3f4a
1 changed files with 24 additions and 8 deletions
|
@ -63,16 +63,32 @@ you can instead write
|
||||||
|
|
||||||
### Attribute name
|
### Attribute name
|
||||||
|
|
||||||
Attribute names can be created dynamically with string interpolation:
|
<!--
|
||||||
|
FIXME: these examples are redundant with the main page on attribute sets.
|
||||||
|
figure out what to do about that
|
||||||
|
-->
|
||||||
|
|
||||||
```nix
|
Attribute names can be interpolated strings.
|
||||||
let name = "foo"; in
|
|
||||||
{
|
|
||||||
${name} = "bar";
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
{ foo = "bar"; }
|
> **Example**
|
||||||
|
>
|
||||||
|
> ```nix
|
||||||
|
> let name = "foo"; in
|
||||||
|
> { ${name} = 123; }
|
||||||
|
> ```
|
||||||
|
>
|
||||||
|
> { foo = 123; }
|
||||||
|
|
||||||
|
Attributes can be selected with interpolated strings.
|
||||||
|
|
||||||
|
> **Example**
|
||||||
|
>
|
||||||
|
> ```nix
|
||||||
|
> let name = "foo"; in
|
||||||
|
> { foo = 123; }.${name}
|
||||||
|
> ```
|
||||||
|
>
|
||||||
|
> 123
|
||||||
|
|
||||||
# Interpolated expression
|
# Interpolated expression
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue