From 5b7f46ea43c1f1630f4647cd467e4206315d6eee Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 10 Sep 2009 10:52:51 +0000 Subject: [PATCH] * A utility function `optionalAttrs', similar to optional and optionalString but for attribute sets. svn path=/nixpkgs/trunk/; revision=17002 --- pkgs/lib/attrsets.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/lib/attrsets.nix b/pkgs/lib/attrsets.nix index 9d10c179afd..9f911299f1b 100644 --- a/pkgs/lib/attrsets.nix +++ b/pkgs/lib/attrsets.nix @@ -161,4 +161,9 @@ rec { /* Check whether the argument is a derivation. */ isDerivation = x: isAttrs x && x ? type && x.type == "derivation"; + + /* If the Boolean `cond' is true, return the attribute set `as', + otherwise an empty attribute set. */ + optionalAttrs = cond: as: if cond then as else {}; + }