query
On this page

getAttrFromPath

lib.attrsets.getAttrFromPath

Docs pulled from | This Revision | 39 minutes ago


Like attrByPath, but without a default value. If it doesn't find the path it will throw an error.

Nix has an attribute selection operator which is sufficient for such queries, as long as the number of attributes is static. For example:

x.a.b == getAttrByPath ["a" "b"] x
# and
x.${f p}."example.com" == getAttrByPath [ (f p) "example.com" ] x

Inputs

attrPath

A list of strings representing the attribute path to get from set

set

The nested attribute set to find the value in.

Type

getAttrFromPath :: [String] -> AttrSet -> Any

Examples

lib.attrsets.getAttrFromPath usage example

x = { a = { b = 3; }; }
getAttrFromPath ["a" "b"] x
=> 3
getAttrFromPath ["z" "z"] x
=> error: cannot find attribute `z.z'

Noogle also knows

Aliases