[Nix-dev] [***SPAM***] Proposal: Conditional attribute syntax sugar

Eelco Dolstra e.dolstra at tudelft.nl
Sat Jan 7 19:21:40 CET 2012


Hi,

On 07/01/12 18:24, Shea Levy wrote:

> 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 {})

I've been thinking about a special ‘ignore’ value:

derivation {
  CFLAGS = if system == "i686-darwin" then "bla" else ignore;
}

This value would be like ‘null’, except that if a derivation attribute evaluates
to ‘ignore’, it wouldn't be added to the environment of the builder.

-- 
Eelco Dolstra | http://www.st.ewi.tudelft.nl/~dolstra/


More information about the nix-dev mailing list