[Nix-dev] A standard function to handle deps

Evgeny Egorochkin phreedom.stdin at gmail.com
Mon Jun 21 17:58:24 CEST 2010


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 [];

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.

-- 
Evgeny



More information about the nix-dev mailing list