Add a common pattern used in jobs definition.
svn path=/nixpkgs/trunk/; revision=13370
This commit is contained in:
parent
26212b62c7
commit
b62298f7c7
|
@ -233,6 +233,16 @@ rec {
|
||||||
|
|
||||||
optionalString = cond: string: if cond then string else "";
|
optionalString = cond: string: if cond then string else "";
|
||||||
|
|
||||||
|
# Return the second argument if the first one is true or the empty version
|
||||||
|
# of the second argument.
|
||||||
|
ifEnable = cond: val:
|
||||||
|
if cond then val
|
||||||
|
else if builtins.isList val then []
|
||||||
|
else if builtins.isAttrs val then {}
|
||||||
|
# else if builtins.isString val then ""
|
||||||
|
# else if builtins.isBoolean val then false
|
||||||
|
else null;
|
||||||
|
|
||||||
# Return a list of integers from `first' up to and including `last'.
|
# Return a list of integers from `first' up to and including `last'.
|
||||||
range = first: last:
|
range = first: last:
|
||||||
if builtins.lessThan last first
|
if builtins.lessThan last first
|
||||||
|
|
Loading…
Reference in a new issue