[Nix-dev] Function to look up symbols dynamically?

Domen Kožar domen at dev.si
Wed Mar 15 14:01:30 CET 2017


nix-repl> a = "foo"

nix-repl> { ${a}.b = "bar"; }
{ foo = { ... }; }


On Tue, Mar 7, 2017 at 9:51 PM, Bryan Ferris <primummoven at gmail.com> wrote:

> Hello,
>
> I see in the Nix manual that hasAttr and getAttr exist to allow developers
> to dynamically access elements of sets. However, I could not find any
> equivalent function for dynamically getting a variable. For example, being
> able to say:
>
> (lookup "programs").zsh = { enable = true; }
>
> Of course, the above usage is not useful, but it becomes useful if you
> replace the "programs" string with a variable.
>
> Is there any way to achieve this in Nix?
>
> Thanks,
> Bryan
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20170315/8d2f6d3a/attachment.html>


More information about the nix-dev mailing list