Add setAttrByPath:
- used to defined an attribute with its path as a list of attribute names. svn path=/nixpkgs/trunk/; revision=17480
This commit is contained in:
parent
7ff2778cc6
commit
b3b40ebf79
@ -22,6 +22,14 @@ rec {
|
|||||||
then attrByPath (tail attrPath) default (getAttr attr e)
|
then attrByPath (tail attrPath) default (getAttr attr e)
|
||||||
else default;
|
else default;
|
||||||
|
|
||||||
|
/* Return nested attribute set in which an attribute is set. For instance
|
||||||
|
["x" "y"] applied with some value v returns `x.y = v;' */
|
||||||
|
setAttrByPath = attrPath: value:
|
||||||
|
if attrPath == [] then value
|
||||||
|
else listToAttrs [(
|
||||||
|
nameValuePair (head attrPath) (setAttrByPath (tail attrPath) value)
|
||||||
|
)];
|
||||||
|
|
||||||
|
|
||||||
/* Backwards compatibility hack: lib.attrByPath used to be called
|
/* Backwards compatibility hack: lib.attrByPath used to be called
|
||||||
lib.getAttr, which was confusing given that there was also a
|
lib.getAttr, which was confusing given that there was also a
|
||||||
|
Loading…
Reference in New Issue
Block a user