diff options
author | Luca Bruno <lethalman88@gmail.com> | 2015-06-30 12:19:49 +0200 |
---|---|---|
committer | Luca Bruno <lethalman88@gmail.com> | 2015-06-30 12:19:49 +0200 |
commit | e06f494a81d65177404cf9b1d28a5fbffda0f146 (patch) | |
tree | 6daf18c7489f5118e4de5c3ad5ab3aa0b1dc2747 /doc/functions.xml | |
parent | 01ce5ce0501327d37aa123c0ded432a5b87cea4b (diff) | |
download | nixlib-e06f494a81d65177404cf9b1d28a5fbffda0f146.tar nixlib-e06f494a81d65177404cf9b1d28a5fbffda0f146.tar.gz nixlib-e06f494a81d65177404cf9b1d28a5fbffda0f146.tar.bz2 nixlib-e06f494a81d65177404cf9b1d28a5fbffda0f146.tar.lz nixlib-e06f494a81d65177404cf9b1d28a5fbffda0f146.tar.xz nixlib-e06f494a81d65177404cf9b1d28a5fbffda0f146.tar.zst nixlib-e06f494a81d65177404cf9b1d28a5fbffda0f146.zip |
doc: document lib.makeOverridable
Diffstat (limited to 'doc/functions.xml')
-rw-r--r-- | doc/functions.xml | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/doc/functions.xml b/doc/functions.xml index 89f2fda0ad4b..2aae3cfb2aec 100644 --- a/doc/functions.xml +++ b/doc/functions.xml @@ -85,4 +85,36 @@ in ...</programlisting> </section> +<section xml:id="sec-lib-makeOverridable"> + <title>lib.makeOverridable</title> + + <para> + The function <varname>lib.makeOverridable</varname> is used make the result + of a function easily customizable. This utility only makes sense for functions + that accept an argument set and return an attribute set. + </para> + + <para> + Example usage: + + <programlisting>f = { a, b }: { result = a+b; } +c = lib.makeOverridable f { a = 1; b = 2; }</programlisting> + + </para> + + <para> + The variable <varname>c</varname> is the value of the <varname>f</varname> function + applied with some default arguments. Hence the value of <varname>c.result</varname> + is <literal>3</literal>, in this example. + </para> + + <para> + The variable <varname>c</varname> however also has some additional functions, like + <link linkend="sec-pkg-override">c.override</link> which can be used to + override the default arguments. In this example the value of + <varname>(c.override { a = 4; }).result</varname> is 6. + </para> + +</section> + </chapter> |