git.iko.soy/typeable/nixpkgs
on master help sign in
doc: document lib.makeOverridable
commite06f494a81d65177404cf9b1d28a5fbffda0f146 authorLuca Bruno <lethalman88@gmail.com> dateTue 30 Jun 2015, 12:19 (11 years ago) parent01ce5ce
1 file changed+32
doc/functions.xml+32
doc/functions.xml+32
@@ -85,4 +85,36 @@ in ...</programlisting>
8585
8686</section>
8787
88+<section xml:id="sec-lib-makeOverridable">
89+ <title>lib.makeOverridable</title>
90+
91+ <para>
92+ The function <varname>lib.makeOverridable</varname> is used make the result
93+ of a function easily customizable. This utility only makes sense for functions
94+ that accept an argument set and return an attribute set.
95+ </para>
96+
97+ <para>
98+ Example usage:
99+
100+ <programlisting>f = { a, b }: { result = a+b; }
101+c = lib.makeOverridable f { a = 1; b = 2; }</programlisting>
102+
103+ </para>
104+
105+ <para>
106+ The variable <varname>c</varname> is the value of the <varname>f</varname> function
107+ applied with some default arguments. Hence the value of <varname>c.result</varname>
108+ is <literal>3</literal>, in this example.
109+ </para>
110+
111+ <para>
112+ The variable <varname>c</varname> however also has some additional functions, like
113+ <link linkend="sec-pkg-override">c.override</link> which can be used to
114+ override the default arguments. In this example the value of
115+ <varname>(c.override { a = 4; }).result</varname> is 6.
116+ </para>
117+
118+</section>
119+
88120</chapter>