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. >
_______________________________________________ nix-dev mailing list nix-dev@cs.uu.nl https://mail.cs.uu.nl/mailman/listinfo/nix-dev