[Nix-dev] Re: A standard function to handle deps

Yury G. Kudryashov urkud+nix at ya.ru
Mon Jun 21 18:17:42 CEST 2010


Evgeny Egorochkin wrote:

> Hi,
> 
> When handling optional deps, there's often a pattern similar to:
> 
> {..., depSupport ? false, dep ? null }:
> assert depSupport -> dep != null ;
> ......
> buildInputs = [...]
>   ++ stdenv.lib.optional depSupport dep
> 
> I propose to add a standard function like this:
> 
> optionalInput =
>   cond: elem: assert cond -> elem != null; if cond then [elem] else [];
cond: elem: if cond the assert elem != null; [elem] else [];
But I prefer to pass non-null anyway, and use
buildInputs = if cond then [elem] else [];
> 
> This removes a good deal of asserts clutter and is easy enough to use so
> that maintainers will actually specify asserts as a byproduct instead of
> letting things fail at buildtime or silently not compile in the needed
> functionality.
> 





More information about the nix-dev mailing list