[Nix-dev] joining attribute sets recursively

Florian Friesdorf flo at chaoflow.net
Wed Jan 18 17:33:35 CET 2012


On Mon, 16 Jan 2012 22:05:26 +0100, Nicolas Pierron <nicolas.b.pierron at gmail.com> wrote:
> > (..)
> > mkX [ {
> >  a = 1;
> >  b = 1;
> >  c.a = 1;
> > } {
> >  b = 2;
> >  c.b = 2;
> >  d = 2;
> > } ]
> >
> > possible results:
> > - error because of colliding b
> > - first value taken: { a = 1; b = 1; c = { a = 1; b = 2 }; d = 2}
> > - last value taken:  { a = 1; b = 2; c = { a = 1; b = 2 }; d = 2}
> > - both values taken: { a = 1; b = [1 2]; c = { a = 1; b = 2 }; d = 2}
> 
>  - both values taken: { a = 1; b = mkX [1 2]; c = mkX [ { a = 1; } { b
> = 2; } ]; d = 2}

+1

> Currently the cleanest way to do so is to duplicate the condition on
> the attributes, such as:
> 
> config = {
>   boot = mkIf cfg.enable { … };
>   services = mkIf cfg.aggressive { … };
> };
> 
> By the way, usually the enable condition is wrapping everything and
> what you want to do makes me wonder if the aggressive option does not
> deserve another name.

I would wrap everything with enable and additionally with aggressive you
can turn on more aggressive features.

Open for better suggestions.

-- 
Florian Friesdorf <flo at chaoflow.net>
  GPG FPR: 7A13 5EEE 1421 9FC2 108D  BAAF 38F8 99A3 0C45 F083
Jabber/XMPP: flo at chaoflow.net
IRC: chaoflow on freenode,ircnet,blafasel,OFTC
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
Url : http://lists.science.uu.nl/pipermail/nix-dev/attachments/20120118/aacf341f/attachment.bin 


More information about the nix-dev mailing list