[Nix-dev] concatAttrs :: [attrSet] -> attrSet ?

Tomasz Czyż tomasz.czyz at gmail.com
Mon May 29 15:26:59 CEST 2017


https://github.com/NixOS/nixpkgs/blob/master/lib/attrsets.nix#L413 is also
handy

2017-05-29 13:36 GMT+01:00 Domen Kožar <domen at dev.si>:

> mkMerge can be used only with NixOS modules.
>
> I do remember some recursive merge function, but can't find it now.
>
> On Mon, May 29, 2017 at 2:29 PM, Volth <volth at volth.com> wrote:
>
>> there is also lib.mkMerge to handle nested attrs
>>
>> On 5/29/17, Domen Kožar <domen at dev.si> wrote:
>> > Note that this will fail if you'll nest the attributes, one will
>> override
>> > the other.
>> >
>> > nix-repl> :p concatAttrs [ {x={a =3;};} {x={ b= 4;};} ]
>> > { x = { b = 4; }; }
>> >
>> >
>> > On Sun, May 28, 2017 at 5:23 PM, Sergiu Ivanov <sivanov at colimite.fr>
>> wrote:
>> >
>> >> Hey Leo,
>> >>
>> >> Thus quoth  Leo Gaspard  at 13:05 on Sun, May 28 2017:
>> >> > On 05/28/2017 02:58 PM, Sergiu Ivanov wrote:
>> >> >> My use case is quite specific. I do this, approximately:
>> >> >>
>> >> >>   let func name = { "${name}" = something name; };
>> >> >>   in concatAttrs (map func [ "name1" "name2" ])
>> >> >
>> >> > If this is your use case, you could also be interested in `genAttrs`
>> >> > defined in `lib/attrsets.nix` ;)
>> >>
>> >> Excellent!  Worked like a charm, thanks a lot!  (After I realised I had
>> >> to use it like pkgs.lib.genAttrs in my context :-) )
>> >>
>> >> --
>> >> Sergiu
>> >>
>> >> _______________________________________________
>> >> nix-dev mailing list
>> >> nix-dev at lists.science.uu.nl
>> >> https://mailman.science.uu.nl/mailman/listinfo/nix-dev
>> >>
>> >>
>> >
>>
>
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> https://mailman.science.uu.nl/mailman/listinfo/nix-dev
>
>


-- 
Tomasz Czyż
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.science.uu.nl/pipermail/nix-dev/attachments/20170529/ae56ca93/attachment.html>


More information about the nix-dev mailing list