diff options
author | Nicolas Pierron <nicolas.b.pierron@gmail.com> | 2008-11-23 00:19:06 +0000 |
---|---|---|
committer | Nicolas Pierron <nicolas.b.pierron@gmail.com> | 2008-11-23 00:19:06 +0000 |
commit | b62298f7c777fb966b05cbc327615fdfe53d57c2 (patch) | |
tree | 5caf2d4016d5dc0194b7c6dd0f722b48927ac473 /pkgs/lib/default.nix | |
parent | 26212b62c702dd890db750cfdb5cee152259bf3a (diff) | |
download | nixlib-b62298f7c777fb966b05cbc327615fdfe53d57c2.tar nixlib-b62298f7c777fb966b05cbc327615fdfe53d57c2.tar.gz nixlib-b62298f7c777fb966b05cbc327615fdfe53d57c2.tar.bz2 nixlib-b62298f7c777fb966b05cbc327615fdfe53d57c2.tar.lz nixlib-b62298f7c777fb966b05cbc327615fdfe53d57c2.tar.xz nixlib-b62298f7c777fb966b05cbc327615fdfe53d57c2.tar.zst nixlib-b62298f7c777fb966b05cbc327615fdfe53d57c2.zip |
Add a common pattern used in jobs definition.
svn path=/nixpkgs/trunk/; revision=13370
Diffstat (limited to 'pkgs/lib/default.nix')
-rw-r--r-- | pkgs/lib/default.nix | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix index e5247c57267b..95fe7ae9c465 100644 --- a/pkgs/lib/default.nix +++ b/pkgs/lib/default.nix @@ -233,6 +233,16 @@ rec { 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'. range = first: last: if builtins.lessThan last first |