[Nix-dev] Small Question on Strings, Attributes & Functions

Kevin Cox kevincox at kevincox.ca
Thu Aug 25 22:40:17 CEST 2016


On 25/08/16 21:31, Vladimír Čunát wrote:
> On 08/24/2016 01:04 PM, Matan Shenhav wrote:
>> Is there a resource covering the rules for variables, values and
>> functions? I am still somewhat confused because if I define func = x:
>> x=="x" I do not need to antiquote with ${}.
> 

You only need to antiquote when doing attribute access (and a few other
oddball situations). For example config.networking.hostName is is
equivalent to config."networking"."hostname". This makes attribute much
easier in the general case. So if you want to do dynamic attribute
access you need to antiquote systemd.services."${srv-name}" or if it is
solely one variable as in that example you can drop the quotes.

Note that in you example that x is always treated as a variable as it is
not in an attribute lookup. Much the same that `config` didn't need to
be quoted in the above examples.

Hope that helps, Kevin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: OpenPGP digital signature
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160825/9dc00d22/attachment.sig>


More information about the nix-dev mailing list