Hi all,

Fairly frequently (especially when trying to get packages to build on 
non-Linux platforms without affecting the build for Linux), I find 
myself wishing for easier syntax for conditionally-existent attributes. 
Right now, we have to do something like

{
  a = 1;
} // (if condition then { b = 2; } else {})

whereas I would prefer to write something like (I'm not wed to this syntax)

{
   a = 1;
   b ?= condition 2;
}

Which would just be syntactic sugar for the first. For a recursive 
attribute set, I imagine it we could have desugaring like this:

rec {
   a = 1;
   b ?= condition a;
}

to

let
first = rec { a = 1; }
second = rec { b = first.a; }
in first // (if condition then second else {})

Thoughts?
_______________________________________________
nix-dev mailing list
[email protected]
http://lists.science.uu.nl/mailman/listinfo/nix-dev

Reply via email to