git.iko.soy/typeable/nixpkgs
on master help sign in
nixpkgs docs: Reformat
commitc07ba7c8560250d1b184698e6453b6d5ca11846f authorGraham Christensen <graham@grahamc.com> dateTue 2 Oct 2018, 15:59 (8 years ago) parent444e04b
8 files changed+778−767
doc/cross-compilation.xml+4−3 doc/functions/debug.xml+15−15 doc/functions/dockertools.xml+412−414 doc/functions/fhs-environments.xml+113−115 doc/functions/generators.xml+36−37 doc/functions/overrides.xml+142−144 doc/functions/shell.xml+10−11 doc/package-notes.xml+46−28
doc/cross-compilation.xml+4−3
@@ -47,9 +47,10 @@
4747
4848 <para>
4949 In Nixpkgs, these three platforms are defined as attribute sets under the
50− names <literal>buildPlatform</literal>, <literal>hostPlatform</literal>, and
51− <literal>targetPlatform</literal>. They are always defined as attributes in
52− the standard environment. That means one can access them like:
50+ names <literal>buildPlatform</literal>, <literal>hostPlatform</literal>,
51+ and <literal>targetPlatform</literal>. They are always defined as
52+ attributes in the standard environment. That means one can access them
53+ like:
5354<programlisting>{ stdenv, fooDep, barDep, .. }: ...stdenv.buildPlatform...</programlisting>
5455 .
5556 </para>
doc/functions/debug.xml+15−15
@@ -2,20 +2,20 @@
22 xmlns:xlink="http://www.w3.org/1999/xlink"
33 xmlns:xi="http://www.w3.org/2001/XInclude"
44 xml:id="sec-debug">
5− <title>Debugging Nix Expressions</title>
5+ <title>Debugging Nix Expressions</title>
66
7− <para>
8− Nix is a unityped, dynamic language, this means every value can potentially
9− appear anywhere. Since it is also non-strict, evaluation order and what
10− ultimately is evaluated might surprise you. Therefore it is important to be
11− able to debug nix expressions.
12− </para>
7+ <para>
8+ Nix is a unityped, dynamic language, this means every value can potentially
9+ appear anywhere. Since it is also non-strict, evaluation order and what
10+ ultimately is evaluated might surprise you. Therefore it is important to be
11+ able to debug nix expressions.
12+ </para>
1313
14− <para>
15− In the <literal>lib/debug.nix</literal> file you will find a number of
16− functions that help (pretty-)printing values while evaluation is runnnig.
17− You can even specify how deep these values should be printed recursively,
18− and transform them on the fly. Please consult the docstrings in
19− <literal>lib/debug.nix</literal> for usage information.
20− </para>
21− </section>
14+ <para>
15+ In the <literal>lib/debug.nix</literal> file you will find a number of
16+ functions that help (pretty-)printing values while evaluation is runnnig. You
17+ can even specify how deep these values should be printed recursively, and
18+ transform them on the fly. Please consult the docstrings in
19+ <literal>lib/debug.nix</literal> for usage information.
20+ </para>
21+</section>
doc/functions/dockertools.xml+412−414
@@ -2,40 +2,40 @@
22 xmlns:xlink="http://www.w3.org/1999/xlink"
33 xmlns:xi="http://www.w3.org/2001/XInclude"
44 xml:id="sec-pkgs-dockerTools">
5− <title>pkgs.dockerTools</title>
5+ <title>pkgs.dockerTools</title>
66
7+ <para>
8+ <varname>pkgs.dockerTools</varname> is a set of functions for creating and
9+ manipulating Docker images according to the
10+ <link xlink:href="https://github.com/moby/moby/blob/master/image/spec/v1.2.md#docker-image-specification-v120">
11+ Docker Image Specification v1.2.0 </link>. Docker itself is not used to
12+ perform any of the operations done by these functions.
13+ </para>
14+
15+ <warning>
716 <para>
8− <varname>pkgs.dockerTools</varname> is a set of functions for creating and
9− manipulating Docker images according to the
10− <link xlink:href="https://github.com/moby/moby/blob/master/image/spec/v1.2.md#docker-image-specification-v120">
11− Docker Image Specification v1.2.0 </link>. Docker itself is not used to
12− perform any of the operations done by these functions.
17+ The <varname>dockerTools</varname> API is unstable and may be subject to
18+ backwards-incompatible changes in the future.
1319 </para>
20+ </warning>
1421
15− <warning>
16− <para>
17− The <varname>dockerTools</varname> API is unstable and may be subject to
18− backwards-incompatible changes in the future.
19− </para>
20− </warning>
21−
22− <section xml:id="ssec-pkgs-dockerTools-buildImage">
23− <title>buildImage</title>
22+ <section xml:id="ssec-pkgs-dockerTools-buildImage">
23+ <title>buildImage</title>
2424
25− <para>
26− This function is analogous to the <command>docker build</command> command,
27− in that can used to build a Docker-compatible repository tarball containing
28− a single image with one or multiple layers. As such, the result is suitable
29− for being loaded in Docker with <command>docker load</command>.
30− </para>
25+ <para>
26+ This function is analogous to the <command>docker build</command> command,
27+ in that can used to build a Docker-compatible repository tarball containing
28+ a single image with one or multiple layers. As such, the result is suitable
29+ for being loaded in Docker with <command>docker load</command>.
30+ </para>
3131
32− <para>
33− The parameters of <varname>buildImage</varname> with relative example
34− values are described below:
35− </para>
32+ <para>
33+ The parameters of <varname>buildImage</varname> with relative example values
34+ are described below:
35+ </para>
3636
37− <example xml:id='ex-dockerTools-buildImage'>
38− <title>Docker build</title>
37+ <example xml:id='ex-dockerTools-buildImage'>
38+ <title>Docker build</title>
3939<programlisting>
4040buildImage {
4141 name = "redis"; <co xml:id='ex-dockerTools-buildImage-1' />
@@ -60,151 +60,150 @@ buildImage {
6060 };
6161}
6262</programlisting>
63− </example>
63+ </example>
6464
65− <para>
66− The above example will build a Docker image <literal>redis/latest</literal>
67− from the given base image. Loading and running this image in Docker results
68− in <literal>redis-server</literal> being started automatically.
69− </para>
65+ <para>
66+ The above example will build a Docker image <literal>redis/latest</literal>
67+ from the given base image. Loading and running this image in Docker results
68+ in <literal>redis-server</literal> being started automatically.
69+ </para>
7070
71− <calloutlist>
72− <callout arearefs='ex-dockerTools-buildImage-1'>
73− <para>
74− <varname>name</varname> specifies the name of the resulting image. This
75− is the only required argument for <varname>buildImage</varname>.
76− </para>
77− </callout>
78− <callout arearefs='ex-dockerTools-buildImage-2'>
79− <para>
80− <varname>tag</varname> specifies the tag of the resulting image. By
81− default it's <literal>null</literal>, which indicates that the nix output
82− hash will be used as tag.
83− </para>
84− </callout>
85− <callout arearefs='ex-dockerTools-buildImage-3'>
86− <para>
87− <varname>fromImage</varname> is the repository tarball containing the
88− base image. It must be a valid Docker image, such as exported by
89− <command>docker save</command>. By default it's <literal>null</literal>,
90− which can be seen as equivalent to <literal>FROM scratch</literal> of a
91− <filename>Dockerfile</filename>.
92− </para>
93− </callout>
94− <callout arearefs='ex-dockerTools-buildImage-4'>
95− <para>
96− <varname>fromImageName</varname> can be used to further specify the base
97− image within the repository, in case it contains multiple images. By
98− default it's <literal>null</literal>, in which case
99− <varname>buildImage</varname> will peek the first image available in the
100− repository.
101− </para>
102− </callout>
103− <callout arearefs='ex-dockerTools-buildImage-5'>
104− <para>
105− <varname>fromImageTag</varname> can be used to further specify the tag of
106− the base image within the repository, in case an image contains multiple
107− tags. By default it's <literal>null</literal>, in which case
108− <varname>buildImage</varname> will peek the first tag available for the
109− base image.
110− </para>
111− </callout>
112− <callout arearefs='ex-dockerTools-buildImage-6'>
113− <para>
114− <varname>contents</varname> is a derivation that will be copied in the
115− new layer of the resulting image. This can be similarly seen as
116− <command>ADD contents/ /</command> in a <filename>Dockerfile</filename>.
117− By default it's <literal>null</literal>.
118− </para>
119− </callout>
120− <callout arearefs='ex-dockerTools-buildImage-runAsRoot'>
121− <para>
122− <varname>runAsRoot</varname> is a bash script that will run as root in an
123− environment that overlays the existing layers of the base image with the
124− new resulting layer, including the previously copied
125− <varname>contents</varname> derivation. This can be similarly seen as
126− <command>RUN ...</command> in a <filename>Dockerfile</filename>.
127− <note>
128− <para>
129− Using this parameter requires the <literal>kvm</literal> device to be
130− available.
131− </para>
132− </note>
133− </para>
134− </callout>
135− <callout arearefs='ex-dockerTools-buildImage-8'>
136− <para>
137− <varname>config</varname> is used to specify the configuration of the
138− containers that will be started off the built image in Docker. The
139− available options are listed in the
140− <link xlink:href="https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions">
141− Docker Image Specification v1.2.0 </link>.
142− </para>
143− </callout>
144− </calloutlist>
71+ <calloutlist>
72+ <callout arearefs='ex-dockerTools-buildImage-1'>
73+ <para>
74+ <varname>name</varname> specifies the name of the resulting image. This is
75+ the only required argument for <varname>buildImage</varname>.
76+ </para>
77+ </callout>
78+ <callout arearefs='ex-dockerTools-buildImage-2'>
79+ <para>
80+ <varname>tag</varname> specifies the tag of the resulting image. By
81+ default it's <literal>null</literal>, which indicates that the nix output
82+ hash will be used as tag.
83+ </para>
84+ </callout>
85+ <callout arearefs='ex-dockerTools-buildImage-3'>
86+ <para>
87+ <varname>fromImage</varname> is the repository tarball containing the base
88+ image. It must be a valid Docker image, such as exported by
89+ <command>docker save</command>. By default it's <literal>null</literal>,
90+ which can be seen as equivalent to <literal>FROM scratch</literal> of a
91+ <filename>Dockerfile</filename>.
92+ </para>
93+ </callout>
94+ <callout arearefs='ex-dockerTools-buildImage-4'>
95+ <para>
96+ <varname>fromImageName</varname> can be used to further specify the base
97+ image within the repository, in case it contains multiple images. By
98+ default it's <literal>null</literal>, in which case
99+ <varname>buildImage</varname> will peek the first image available in the
100+ repository.
101+ </para>
102+ </callout>
103+ <callout arearefs='ex-dockerTools-buildImage-5'>
104+ <para>
105+ <varname>fromImageTag</varname> can be used to further specify the tag of
106+ the base image within the repository, in case an image contains multiple
107+ tags. By default it's <literal>null</literal>, in which case
108+ <varname>buildImage</varname> will peek the first tag available for the
109+ base image.
110+ </para>
111+ </callout>
112+ <callout arearefs='ex-dockerTools-buildImage-6'>
113+ <para>
114+ <varname>contents</varname> is a derivation that will be copied in the new
115+ layer of the resulting image. This can be similarly seen as <command>ADD
116+ contents/ /</command> in a <filename>Dockerfile</filename>. By default
117+ it's <literal>null</literal>.
118+ </para>
119+ </callout>
120+ <callout arearefs='ex-dockerTools-buildImage-runAsRoot'>
121+ <para>
122+ <varname>runAsRoot</varname> is a bash script that will run as root in an
123+ environment that overlays the existing layers of the base image with the
124+ new resulting layer, including the previously copied
125+ <varname>contents</varname> derivation. This can be similarly seen as
126+ <command>RUN ...</command> in a <filename>Dockerfile</filename>.
127+ <note>
128+ <para>
129+ Using this parameter requires the <literal>kvm</literal> device to be
130+ available.
131+ </para>
132+ </note>
133+ </para>
134+ </callout>
135+ <callout arearefs='ex-dockerTools-buildImage-8'>
136+ <para>
137+ <varname>config</varname> is used to specify the configuration of the
138+ containers that will be started off the built image in Docker. The
139+ available options are listed in the
140+ <link xlink:href="https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions">
141+ Docker Image Specification v1.2.0 </link>.
142+ </para>
143+ </callout>
144+ </calloutlist>
145145
146− <para>
147− After the new layer has been created, its closure (to which
148− <varname>contents</varname>, <varname>config</varname> and
149− <varname>runAsRoot</varname> contribute) will be copied in the layer
150− itself. Only new dependencies that are not already in the existing layers
151− will be copied.
152− </para>
146+ <para>
147+ After the new layer has been created, its closure (to which
148+ <varname>contents</varname>, <varname>config</varname> and
149+ <varname>runAsRoot</varname> contribute) will be copied in the layer itself.
150+ Only new dependencies that are not already in the existing layers will be
151+ copied.
152+ </para>
153+
154+ <para>
155+ At the end of the process, only one new single layer will be produced and
156+ added to the resulting image.
157+ </para>
158+
159+ <para>
160+ The resulting repository will only list the single image
161+ <varname>image/tag</varname>. In the case of
162+ <xref linkend='ex-dockerTools-buildImage'/> it would be
163+ <varname>redis/latest</varname>.
164+ </para>
165+
166+ <para>
167+ It is possible to inspect the arguments with which an image was built using
168+ its <varname>buildArgs</varname> attribute.
169+ </para>
153170
171+ <note>
154172 <para>
155− At the end of the process, only one new single layer will be produced and
156− added to the resulting image.
173+ If you see errors similar to <literal>getProtocolByName: does not exist (no
174+ such protocol name: tcp)</literal> you may need to add
175+ <literal>pkgs.iana-etc</literal> to <varname>contents</varname>.
157176 </para>
177+ </note>
158178
179+ <note>
159180 <para>
160− The resulting repository will only list the single image
161− <varname>image/tag</varname>. In the case of
162− <xref linkend='ex-dockerTools-buildImage'/> it would be
163− <varname>redis/latest</varname>.
181+ If you see errors similar to <literal>Error_Protocol ("certificate has
182+ unknown CA",True,UnknownCa)</literal> you may need to add
183+ <literal>pkgs.cacert</literal> to <varname>contents</varname>.
164184 </para>
185+ </note>
165186
187+ <example xml:id="example-pkgs-dockerTools-buildImage-creation-date">
188+ <title>Impurely Defining a Docker Layer's Creation Date</title>
166189 <para>
167− It is possible to inspect the arguments with which an image was built using
168− its <varname>buildArgs</varname> attribute.
190+ By default <function>buildImage</function> will use a static date of one
191+ second past the UNIX Epoch. This allows <function>buildImage</function> to
192+ produce binary reproducible images. When listing images with
193+ <command>docker list images</command>, the newly created images will be
194+ listed like this:
169195 </para>
170−
171− <note>
172− <para>
173− If you see errors similar to <literal>getProtocolByName: does not exist
174− (no such protocol name: tcp)</literal> you may need to add
175− <literal>pkgs.iana-etc</literal> to <varname>contents</varname>.
176− </para>
177− </note>
178−
179− <note>
180− <para>
181− If you see errors similar to <literal>Error_Protocol ("certificate has
182− unknown CA",True,UnknownCa)</literal> you may need to add
183− <literal>pkgs.cacert</literal> to <varname>contents</varname>.
184− </para>
185− </note>
186−
187− <example xml:id="example-pkgs-dockerTools-buildImage-creation-date">
188− <title>Impurely Defining a Docker Layer's Creation Date</title>
189− <para>
190− By default <function>buildImage</function> will use a static
191− date of one second past the UNIX Epoch. This allows
192− <function>buildImage</function> to produce binary reproducible
193− images. When listing images with <command>docker list
194− images</command>, the newly created images will be listed like
195− this:
196− </para>
197− <screen><![CDATA[
196+<screen><![CDATA[
198197$ docker image list
199198REPOSITORY TAG IMAGE ID CREATED SIZE
200199hello latest 08c791c7846e 48 years ago 25.2MB
201200]]></screen>
202− <para>
203− You can break binary reproducibility but have a sorted,
204− meaningful <literal>CREATED</literal> column by setting
205− <literal>created</literal> to <literal>now</literal>.
206− </para>
207− <programlisting><![CDATA[
201+ <para>
202+ You can break binary reproducibility but have a sorted, meaningful
203+ <literal>CREATED</literal> column by setting <literal>created</literal> to
204+ <literal>now</literal>.
205+ </para>
206+<programlisting><![CDATA[
208207pkgs.dockerTools.buildImage {
209208 name = "hello";
210209 tag = "latest";
@@ -214,206 +213,206 @@ pkgs.dockerTools.buildImage {
214213 config.Cmd = [ "/bin/hello" ];
215214}
216215]]></programlisting>
217− <para>
218− and now the Docker CLI will display a reasonable date and
219− sort the images as expected:
220− <screen><![CDATA[
216+ <para>
217+ and now the Docker CLI will display a reasonable date and sort the images
218+ as expected:
219+<screen><![CDATA[
221220$ docker image list
222221REPOSITORY TAG IMAGE ID CREATED SIZE
223222hello latest de2bf4786de6 About a minute ago 25.2MB
224223]]></screen>
225− however, the produced images will not be binary reproducible.
226− </para>
227− </example>
228− </section>
224+ however, the produced images will not be binary reproducible.
225+ </para>
226+ </example>
227+ </section>
229228
230− <section xml:id="ssec-pkgs-dockerTools-buildLayeredImage">
231− <title>buildLayeredImage</title>
229+ <section xml:id="ssec-pkgs-dockerTools-buildLayeredImage">
230+ <title>buildLayeredImage</title>
232231
233− <para>
234− Create a Docker image with many of the store paths being on their own layer
235− to improve sharing between images.
236− </para>
232+ <para>
233+ Create a Docker image with many of the store paths being on their own layer
234+ to improve sharing between images.
235+ </para>
237236
238− <variablelist>
239− <varlistentry>
240− <term>
241− <varname>name</varname>
242− </term>
243− <listitem>
244− <para>
245− The name of the resulting image.
246− </para>
247− </listitem>
248− </varlistentry>
249− <varlistentry>
250− <term>
251− <varname>tag</varname> <emphasis>optional</emphasis>
252− </term>
253− <listitem>
254− <para>
255− Tag of the generated image.
256− </para>
257− <para>
258− <emphasis>Default:</emphasis> the output path's hash
259− </para>
260− </listitem>
261− </varlistentry>
262− <varlistentry>
263− <term>
264− <varname>contents</varname> <emphasis>optional</emphasis>
265− </term>
266− <listitem>
267− <para>
268− Top level paths in the container. Either a single derivation, or a list
269− of derivations.
270− </para>
271− <para>
272− <emphasis>Default:</emphasis> <literal>[]</literal>
273− </para>
274− </listitem>
275− </varlistentry>
276− <varlistentry>
277− <term>
278− <varname>config</varname> <emphasis>optional</emphasis>
279− </term>
280− <listitem>
281− <para>
282− Run-time configuration of the container. A full list of the options are
283− available at in the
284− <link xlink:href="https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions">
285− Docker Image Specification v1.2.0 </link>.
286− </para>
287− <para>
288− <emphasis>Default:</emphasis> <literal>{}</literal>
289− </para>
290− </listitem>
291− </varlistentry>
292− <varlistentry>
293− <term>
294− <varname>created</varname> <emphasis>optional</emphasis>
295− </term>
296− <listitem>
297− <para>
298− Date and time the layers were created. Follows the same
299− <literal>now</literal> exception supported by
300− <literal>buildImage</literal>.
301− </para>
302− <para>
303− <emphasis>Default:</emphasis> <literal>1970-01-01T00:00:01Z</literal>
304− </para>
305− </listitem>
306− </varlistentry>
307− <varlistentry>
308− <term>
309− <varname>maxLayers</varname> <emphasis>optional</emphasis>
310− </term>
311− <listitem>
312− <para>
313− Maximum number of layers to create.
314− </para>
315− <para>
316− <emphasis>Default:</emphasis> <literal>24</literal>
317− </para>
318− </listitem>
319− </varlistentry>
320− </variablelist>
237+ <variablelist>
238+ <varlistentry>
239+ <term>
240+ <varname>name</varname>
241+ </term>
242+ <listitem>
243+ <para>
244+ The name of the resulting image.
245+ </para>
246+ </listitem>
247+ </varlistentry>
248+ <varlistentry>
249+ <term>
250+ <varname>tag</varname> <emphasis>optional</emphasis>
251+ </term>
252+ <listitem>
253+ <para>
254+ Tag of the generated image.
255+ </para>
256+ <para>
257+ <emphasis>Default:</emphasis> the output path's hash
258+ </para>
259+ </listitem>
260+ </varlistentry>
261+ <varlistentry>
262+ <term>
263+ <varname>contents</varname> <emphasis>optional</emphasis>
264+ </term>
265+ <listitem>
266+ <para>
267+ Top level paths in the container. Either a single derivation, or a list
268+ of derivations.
269+ </para>
270+ <para>
271+ <emphasis>Default:</emphasis> <literal>[]</literal>
272+ </para>
273+ </listitem>
274+ </varlistentry>
275+ <varlistentry>
276+ <term>
277+ <varname>config</varname> <emphasis>optional</emphasis>
278+ </term>
279+ <listitem>
280+ <para>
281+ Run-time configuration of the container. A full list of the options are
282+ available at in the
283+ <link xlink:href="https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions">
284+ Docker Image Specification v1.2.0 </link>.
285+ </para>
286+ <para>
287+ <emphasis>Default:</emphasis> <literal>{}</literal>
288+ </para>
289+ </listitem>
290+ </varlistentry>
291+ <varlistentry>
292+ <term>
293+ <varname>created</varname> <emphasis>optional</emphasis>
294+ </term>
295+ <listitem>
296+ <para>
297+ Date and time the layers were created. Follows the same
298+ <literal>now</literal> exception supported by
299+ <literal>buildImage</literal>.
300+ </para>
301+ <para>
302+ <emphasis>Default:</emphasis> <literal>1970-01-01T00:00:01Z</literal>
303+ </para>
304+ </listitem>
305+ </varlistentry>
306+ <varlistentry>
307+ <term>
308+ <varname>maxLayers</varname> <emphasis>optional</emphasis>
309+ </term>
310+ <listitem>
311+ <para>
312+ Maximum number of layers to create.
313+ </para>
314+ <para>
315+ <emphasis>Default:</emphasis> <literal>24</literal>
316+ </para>
317+ </listitem>
318+ </varlistentry>
319+ </variablelist>
321320
322− <section xml:id="dockerTools-buildLayeredImage-arg-contents">
323− <title>Behavior of <varname>contents</varname> in the final image</title>
321+ <section xml:id="dockerTools-buildLayeredImage-arg-contents">
322+ <title>Behavior of <varname>contents</varname> in the final image</title>
324323
325− <para>
326− Each path directly listed in <varname>contents</varname> will have a
327− symlink in the root of the image.
328− </para>
324+ <para>
325+ Each path directly listed in <varname>contents</varname> will have a
326+ symlink in the root of the image.
327+ </para>
329328
330− <para>
331− For example:
329+ <para>
330+ For example:
332331<programlisting><![CDATA[
333332pkgs.dockerTools.buildLayeredImage {
334333 name = "hello";
335334 contents = [ pkgs.hello ];
336335}
337336]]></programlisting>
338− will create symlinks for all the paths in the <literal>hello</literal>
339− package:
337+ will create symlinks for all the paths in the <literal>hello</literal>
338+ package:
340339<screen><![CDATA[
341340/bin/hello -> /nix/store/h1zb1padqbbb7jicsvkmrym3r6snphxg-hello-2.10/bin/hello
342341/share/info/hello.info -> /nix/store/h1zb1padqbbb7jicsvkmrym3r6snphxg-hello-2.10/share/info/hello.info
343342/share/locale/bg/LC_MESSAGES/hello.mo -> /nix/store/h1zb1padqbbb7jicsvkmrym3r6snphxg-hello-2.10/share/locale/bg/LC_MESSAGES/hello.mo
344343]]></screen>
345− </para>
346− </section>
344+ </para>
345+ </section>
347346
348− <section xml:id="dockerTools-buildLayeredImage-arg-config">
349− <title>Automatic inclusion of <varname>config</varname> references</title>
347+ <section xml:id="dockerTools-buildLayeredImage-arg-config">
348+ <title>Automatic inclusion of <varname>config</varname> references</title>
350349
351− <para>
352− The closure of <varname>config</varname> is automatically included in the
353− closure of the final image.
354− </para>
350+ <para>
351+ The closure of <varname>config</varname> is automatically included in the
352+ closure of the final image.
353+ </para>
355354
356− <para>
357− This allows you to make very simple Docker images with very little code.
358− This container will start up and run <command>hello</command>:
355+ <para>
356+ This allows you to make very simple Docker images with very little code.
357+ This container will start up and run <command>hello</command>:
359358<programlisting><![CDATA[
360359pkgs.dockerTools.buildLayeredImage {
361360 name = "hello";
362361 config.Cmd = [ "${pkgs.hello}/bin/hello" ];
363362}
364363]]></programlisting>
365− </para>
366− </section>
367−
368− <section xml:id="dockerTools-buildLayeredImage-arg-maxLayers">
369− <title>Adjusting <varname>maxLayers</varname></title>
370−
371− <para>
372− Increasing the <varname>maxLayers</varname> increases the number of layers
373− which have a chance to be shared between different images.
374− </para>
375−
376− <para>
377− Modern Docker installations support up to 128 layers, however older
378− versions support as few as 42.
379− </para>
364+ </para>
365+ </section>
380366
381− <para>
382− If the produced image will not be extended by other Docker builds, it is
383− safe to set <varname>maxLayers</varname> to <literal>128</literal>.
384− However it will be impossible to extend the image further.
385− </para>
367+ <section xml:id="dockerTools-buildLayeredImage-arg-maxLayers">
368+ <title>Adjusting <varname>maxLayers</varname></title>
386369
387− <para>
388− The first (<literal>maxLayers-2</literal>) most "popular" paths will have
389− their own individual layers, then layer #<literal>maxLayers-1</literal>
390− will contain all the remaining "unpopular" paths, and finally layer
391− #<literal>maxLayers</literal> will contain the Image configuration.
392− </para>
370+ <para>
371+ Increasing the <varname>maxLayers</varname> increases the number of layers
372+ which have a chance to be shared between different images.
373+ </para>
393374
394− <para>
395− Docker's Layers are not inherently ordered, they are content-addressable
396− and are not explicitly layered until they are composed in to an Image.
397− </para>
398− </section>
399− </section>
375+ <para>
376+ Modern Docker installations support up to 128 layers, however older
377+ versions support as few as 42.
378+ </para>
400379
401− <section xml:id="ssec-pkgs-dockerTools-fetchFromRegistry">
402− <title>pullImage</title>
380+ <para>
381+ If the produced image will not be extended by other Docker builds, it is
382+ safe to set <varname>maxLayers</varname> to <literal>128</literal>. However
383+ it will be impossible to extend the image further.
384+ </para>
403385
404386 <para>
405− This function is analogous to the <command>docker pull</command> command,
406− in that can be used to pull a Docker image from a Docker registry. By
407− default <link xlink:href="https://hub.docker.com/">Docker Hub</link> is
408− used to pull images.
387+ The first (<literal>maxLayers-2</literal>) most "popular" paths will have
388+ their own individual layers, then layer #<literal>maxLayers-1</literal>
389+ will contain all the remaining "unpopular" paths, and finally layer
390+ #<literal>maxLayers</literal> will contain the Image configuration.
409391 </para>
410392
411393 <para>
412− Its parameters are described in the example below:
394+ Docker's Layers are not inherently ordered, they are content-addressable
395+ and are not explicitly layered until they are composed in to an Image.
413396 </para>
397+ </section>
398+ </section>
414399
415− <example xml:id='ex-dockerTools-pullImage'>
416− <title>Docker pull</title>
400+ <section xml:id="ssec-pkgs-dockerTools-fetchFromRegistry">
401+ <title>pullImage</title>
402+
403+ <para>
404+ This function is analogous to the <command>docker pull</command> command, in
405+ that can be used to pull a Docker image from a Docker registry. By default
406+ <link xlink:href="https://hub.docker.com/">Docker Hub</link> is used to pull
407+ images.
408+ </para>
409+
410+ <para>
411+ Its parameters are described in the example below:
412+ </para>
413+
414+ <example xml:id='ex-dockerTools-pullImage'>
415+ <title>Docker pull</title>
417416<programlisting>
418417pullImage {
419418 imageName = "nixos/nix"; <co xml:id='ex-dockerTools-pullImage-1' />
@@ -424,86 +423,86 @@ pullImage {
424423 arch = "x86_64"; <co xml:id='ex-dockerTools-pullImage-6' />
425424}
426425</programlisting>
427− </example>
426+ </example>
428427
429− <calloutlist>
430− <callout arearefs='ex-dockerTools-pullImage-1'>
431− <para>
432− <varname>imageName</varname> specifies the name of the image to be
433− downloaded, which can also include the registry namespace (e.g.
434− <literal>nixos</literal>). This argument is required.
435− </para>
436− </callout>
437− <callout arearefs='ex-dockerTools-pullImage-2'>
438− <para>
439− <varname>imageDigest</varname> specifies the digest of the image to be
440− downloaded. Skopeo can be used to get the digest of an image, with its
441− <varname>inspect</varname> subcommand. Since a given
442− <varname>imageName</varname> may transparently refer to a manifest list
443− of images which support multiple architectures and/or operating systems,
444− supply the `--override-os` and `--override-arch` arguments to specify
445− exactly which image you want. By default it will match the OS and
446− architecture of the host the command is run on.
428+ <calloutlist>
429+ <callout arearefs='ex-dockerTools-pullImage-1'>
430+ <para>
431+ <varname>imageName</varname> specifies the name of the image to be
432+ downloaded, which can also include the registry namespace (e.g.
433+ <literal>nixos</literal>). This argument is required.
434+ </para>
435+ </callout>
436+ <callout arearefs='ex-dockerTools-pullImage-2'>
437+ <para>
438+ <varname>imageDigest</varname> specifies the digest of the image to be
439+ downloaded. Skopeo can be used to get the digest of an image, with its
440+ <varname>inspect</varname> subcommand. Since a given
441+ <varname>imageName</varname> may transparently refer to a manifest list of
442+ images which support multiple architectures and/or operating systems,
443+ supply the `--override-os` and `--override-arch` arguments to specify
444+ exactly which image you want. By default it will match the OS and
445+ architecture of the host the command is run on.
447446<programlisting>
448447$ nix-shell --packages skopeo jq --command "skopeo --override-os linux --override-arch x86_64 inspect docker://docker.io/nixos/nix:1.11 | jq -r '.Digest'"
449448sha256:20d9485b25ecfd89204e843a962c1bd70e9cc6858d65d7f5fadc340246e2116b
450449</programlisting>
451− This argument is required.
452− </para>
453− </callout>
454− <callout arearefs='ex-dockerTools-pullImage-3'>
455− <para>
456− <varname>finalImageTag</varname>, if specified, this is the tag of the
457− image to be created. Note it is never used to fetch the image since we
458− prefer to rely on the immutable digest ID. By default it's
459− <literal>latest</literal>.
460− </para>
461− </callout>
462− <callout arearefs='ex-dockerTools-pullImage-4'>
463− <para>
464− <varname>sha256</varname> is the checksum of the whole fetched image.
465− This argument is required.
466− </para>
467− </callout>
468− <callout arearefs='ex-dockerTools-pullImage-5'>
469− <para>
470− <varname>os</varname>, if specified, is the operating system of the
471− fetched image. By default it's <literal>linux</literal>.
472− </para>
473− </callout>
474− <callout arearefs='ex-dockerTools-pullImage-6'>
475− <para>
476− <varname>arch</varname>, if specified, is the cpu architecture of the
477− fetched image. By default it's <literal>x86_64</literal>.
478− </para>
479− </callout>
480− </calloutlist>
481− </section>
482−
483− <section xml:id="ssec-pkgs-dockerTools-exportImage">
484− <title>exportImage</title>
485−
486− <para>
487− This function is analogous to the <command>docker export</command> command,
488− in that can used to flatten a Docker image that contains multiple layers.
489− It is in fact the result of the merge of all the layers of the image. As
490− such, the result is suitable for being imported in Docker with
491− <command>docker import</command>.
492− </para>
493−
494− <note>
450+ This argument is required.
451+ </para>
452+ </callout>
453+ <callout arearefs='ex-dockerTools-pullImage-3'>
454+ <para>
455+ <varname>finalImageTag</varname>, if specified, this is the tag of the
456+ image to be created. Note it is never used to fetch the image since we
457+ prefer to rely on the immutable digest ID. By default it's
458+ <literal>latest</literal>.
459+ </para>
460+ </callout>
461+ <callout arearefs='ex-dockerTools-pullImage-4'>
462+ <para>
463+ <varname>sha256</varname> is the checksum of the whole fetched image. This
464+ argument is required.
465+ </para>
466+ </callout>
467+ <callout arearefs='ex-dockerTools-pullImage-5'>
495468 <para>
496− Using this function requires the <literal>kvm</literal> device to be
497− available.
469+ <varname>os</varname>, if specified, is the operating system of the
470+ fetched image. By default it's <literal>linux</literal>.
498471 </para>
499− </note>
472+ </callout>
473+ <callout arearefs='ex-dockerTools-pullImage-6'>
474+ <para>
475+ <varname>arch</varname>, if specified, is the cpu architecture of the
476+ fetched image. By default it's <literal>x86_64</literal>.
477+ </para>
478+ </callout>
479+ </calloutlist>
480+ </section>
481+
482+ <section xml:id="ssec-pkgs-dockerTools-exportImage">
483+ <title>exportImage</title>
500484
485+ <para>
486+ This function is analogous to the <command>docker export</command> command,
487+ in that can used to flatten a Docker image that contains multiple layers. It
488+ is in fact the result of the merge of all the layers of the image. As such,
489+ the result is suitable for being imported in Docker with <command>docker
490+ import</command>.
491+ </para>
492+
493+ <note>
501494 <para>
502− The parameters of <varname>exportImage</varname> are the following:
495+ Using this function requires the <literal>kvm</literal> device to be
496+ available.
503497 </para>
498+ </note>
504499
505− <example xml:id='ex-dockerTools-exportImage'>
506− <title>Docker export</title>
500+ <para>
501+ The parameters of <varname>exportImage</varname> are the following:
502+ </para>
503+
504+ <example xml:id='ex-dockerTools-exportImage'>
505+ <title>Docker export</title>
507506<programlisting>
508507exportImage {
509508 fromImage = someLayeredImage;
@@ -513,34 +512,33 @@ exportImage {
513512 name = someLayeredImage.name;
514513}
515514 </programlisting>
516− </example>
515+ </example>
517516
518− <para>
519− The parameters relative to the base image have the same synopsis as
520− described in <xref linkend='ssec-pkgs-dockerTools-buildImage'/>, except
521− that <varname>fromImage</varname> is the only required argument in this
522− case.
523− </para>
517+ <para>
518+ The parameters relative to the base image have the same synopsis as
519+ described in <xref linkend='ssec-pkgs-dockerTools-buildImage'/>, except that
520+ <varname>fromImage</varname> is the only required argument in this case.
521+ </para>
524522
525− <para>
526− The <varname>name</varname> argument is the name of the derivation output,
527− which defaults to <varname>fromImage.name</varname>.
528− </para>
529− </section>
523+ <para>
524+ The <varname>name</varname> argument is the name of the derivation output,
525+ which defaults to <varname>fromImage.name</varname>.
526+ </para>
527+ </section>
530528
531− <section xml:id="ssec-pkgs-dockerTools-shadowSetup">
532− <title>shadowSetup</title>
529+ <section xml:id="ssec-pkgs-dockerTools-shadowSetup">
530+ <title>shadowSetup</title>
533531
534− <para>
535− This constant string is a helper for setting up the base files for managing
536− users and groups, only if such files don't exist already. It is suitable
537− for being used in a <varname>runAsRoot</varname>
538− <xref linkend='ex-dockerTools-buildImage-runAsRoot'/> script for cases like
539− in the example below:
540− </para>
532+ <para>
533+ This constant string is a helper for setting up the base files for managing
534+ users and groups, only if such files don't exist already. It is suitable for
535+ being used in a <varname>runAsRoot</varname>
536+ <xref linkend='ex-dockerTools-buildImage-runAsRoot'/> script for cases like
537+ in the example below:
538+ </para>
541539
542− <example xml:id='ex-dockerTools-shadowSetup'>
543− <title>Shadow base files</title>
540+ <example xml:id='ex-dockerTools-shadowSetup'>
541+ <title>Shadow base files</title>
544542<programlisting>
545543buildImage {
546544 name = "shadow-basic";
@@ -555,12 +553,12 @@ buildImage {
555553 '';
556554}
557555</programlisting>
558− </example>
556+ </example>
559557
560− <para>
561− Creating base files like <literal>/etc/passwd</literal> or
562− <literal>/etc/login.defs</literal> are necessary for shadow-utils to
563− manipulate users and groups.
564− </para>
565− </section>
558+ <para>
559+ Creating base files like <literal>/etc/passwd</literal> or
560+ <literal>/etc/login.defs</literal> are necessary for shadow-utils to
561+ manipulate users and groups.
562+ </para>
566563 </section>
564+</section>
doc/functions/fhs-environments.xml+113−115
@@ -2,116 +2,114 @@
22 xmlns:xlink="http://www.w3.org/1999/xlink"
33 xmlns:xi="http://www.w3.org/2001/XInclude"
44 xml:id="sec-fhs-environments">
5− <title>buildFHSUserEnv</title>
5+ <title>buildFHSUserEnv</title>
66
7− <para>
8− <function>buildFHSUserEnv</function> provides a way to build and run
9− FHS-compatible lightweight sandboxes. It creates an isolated root with bound
10− <filename>/nix/store</filename>, so its footprint in terms of disk space
11− needed is quite small. This allows one to run software which is hard or
12− unfeasible to patch for NixOS -- 3rd-party source trees with FHS
13− assumptions, games distributed as tarballs, software with integrity checking
14− and/or external self-updated binaries. It uses Linux namespaces feature to
15− create temporary lightweight environments which are destroyed after all
16− child processes exit, without root user rights requirement. Accepted
17− arguments are:
18− </para>
7+ <para>
8+ <function>buildFHSUserEnv</function> provides a way to build and run
9+ FHS-compatible lightweight sandboxes. It creates an isolated root with bound
10+ <filename>/nix/store</filename>, so its footprint in terms of disk space
11+ needed is quite small. This allows one to run software which is hard or
12+ unfeasible to patch for NixOS -- 3rd-party source trees with FHS assumptions,
13+ games distributed as tarballs, software with integrity checking and/or
14+ external self-updated binaries. It uses Linux namespaces feature to create
15+ temporary lightweight environments which are destroyed after all child
16+ processes exit, without root user rights requirement. Accepted arguments are:
17+ </para>
1918
20− <variablelist>
21− <varlistentry>
22− <term>
23− <literal>name</literal>
24− </term>
25− <listitem>
26− <para>
27− Environment name.
28− </para>
29− </listitem>
30− </varlistentry>
31− <varlistentry>
32− <term>
33− <literal>targetPkgs</literal>
34− </term>
35− <listitem>
36− <para>
37− Packages to be installed for the main host's architecture (i.e. x86_64 on
38− x86_64 installations). Along with libraries binaries are also installed.
39− </para>
40− </listitem>
41− </varlistentry>
42− <varlistentry>
43− <term>
44− <literal>multiPkgs</literal>
45− </term>
46− <listitem>
47− <para>
48− Packages to be installed for all architectures supported by a host (i.e.
49− i686 and x86_64 on x86_64 installations). Only libraries are installed by
50− default.
51− </para>
52− </listitem>
53− </varlistentry>
54− <varlistentry>
55− <term>
56− <literal>extraBuildCommands</literal>
57− </term>
58− <listitem>
59− <para>
60− Additional commands to be executed for finalizing the directory
61− structure.
62− </para>
63− </listitem>
64− </varlistentry>
65− <varlistentry>
66− <term>
67− <literal>extraBuildCommandsMulti</literal>
68− </term>
69− <listitem>
70− <para>
71− Like <literal>extraBuildCommands</literal>, but executed only on multilib
72− architectures.
73− </para>
74− </listitem>
75− </varlistentry>
76− <varlistentry>
77− <term>
78− <literal>extraOutputsToInstall</literal>
79− </term>
80− <listitem>
81− <para>
82− Additional derivation outputs to be linked for both target and
83− multi-architecture packages.
84− </para>
85− </listitem>
86− </varlistentry>
87− <varlistentry>
88− <term>
89− <literal>extraInstallCommands</literal>
90− </term>
91− <listitem>
92− <para>
93− Additional commands to be executed for finalizing the derivation with
94− runner script.
95− </para>
96− </listitem>
97− </varlistentry>
98− <varlistentry>
99− <term>
100− <literal>runScript</literal>
101− </term>
102− <listitem>
103− <para>
104− A command that would be executed inside the sandbox and passed all the
105− command line arguments. It defaults to <literal>bash</literal>.
106− </para>
107− </listitem>
108− </varlistentry>
109− </variablelist>
19+ <variablelist>
20+ <varlistentry>
21+ <term>
22+ <literal>name</literal>
23+ </term>
24+ <listitem>
25+ <para>
26+ Environment name.
27+ </para>
28+ </listitem>
29+ </varlistentry>
30+ <varlistentry>
31+ <term>
32+ <literal>targetPkgs</literal>
33+ </term>
34+ <listitem>
35+ <para>
36+ Packages to be installed for the main host's architecture (i.e. x86_64 on
37+ x86_64 installations). Along with libraries binaries are also installed.
38+ </para>
39+ </listitem>
40+ </varlistentry>
41+ <varlistentry>
42+ <term>
43+ <literal>multiPkgs</literal>
44+ </term>
45+ <listitem>
46+ <para>
47+ Packages to be installed for all architectures supported by a host (i.e.
48+ i686 and x86_64 on x86_64 installations). Only libraries are installed by
49+ default.
50+ </para>
51+ </listitem>
52+ </varlistentry>
53+ <varlistentry>
54+ <term>
55+ <literal>extraBuildCommands</literal>
56+ </term>
57+ <listitem>
58+ <para>
59+ Additional commands to be executed for finalizing the directory structure.
60+ </para>
61+ </listitem>
62+ </varlistentry>
63+ <varlistentry>
64+ <term>
65+ <literal>extraBuildCommandsMulti</literal>
66+ </term>
67+ <listitem>
68+ <para>
69+ Like <literal>extraBuildCommands</literal>, but executed only on multilib
70+ architectures.
71+ </para>
72+ </listitem>
73+ </varlistentry>
74+ <varlistentry>
75+ <term>
76+ <literal>extraOutputsToInstall</literal>
77+ </term>
78+ <listitem>
79+ <para>
80+ Additional derivation outputs to be linked for both target and
81+ multi-architecture packages.
82+ </para>
83+ </listitem>
84+ </varlistentry>
85+ <varlistentry>
86+ <term>
87+ <literal>extraInstallCommands</literal>
88+ </term>
89+ <listitem>
90+ <para>
91+ Additional commands to be executed for finalizing the derivation with
92+ runner script.
93+ </para>
94+ </listitem>
95+ </varlistentry>
96+ <varlistentry>
97+ <term>
98+ <literal>runScript</literal>
99+ </term>
100+ <listitem>
101+ <para>
102+ A command that would be executed inside the sandbox and passed all the
103+ command line arguments. It defaults to <literal>bash</literal>.
104+ </para>
105+ </listitem>
106+ </varlistentry>
107+ </variablelist>
110108
111− <para>
112− One can create a simple environment using a <literal>shell.nix</literal>
113− like that:
114− </para>
109+ <para>
110+ One can create a simple environment using a <literal>shell.nix</literal> like
111+ that:
112+ </para>
115113
116114<programlisting><![CDATA[
117115{ pkgs ? import <nixpkgs> {} }:
@@ -134,11 +132,11 @@
134132}).env
135133]]></programlisting>
136134
137− <para>
138− Running <literal>nix-shell</literal> would then drop you into a shell with
139− these libraries and binaries available. You can use this to run
140− closed-source applications which expect FHS structure without hassles:
141− simply change <literal>runScript</literal> to the application path, e.g.
142− <filename>./bin/start.sh</filename> -- relative paths are supported.
143− </para>
144− </section>
135+ <para>
136+ Running <literal>nix-shell</literal> would then drop you into a shell with
137+ these libraries and binaries available. You can use this to run closed-source
138+ applications which expect FHS structure without hassles: simply change
139+ <literal>runScript</literal> to the application path, e.g.
140+ <filename>./bin/start.sh</filename> -- relative paths are supported.
141+ </para>
142+</section>
doc/functions/generators.xml+36−37
@@ -2,33 +2,32 @@
22 xmlns:xlink="http://www.w3.org/1999/xlink"
33 xmlns:xi="http://www.w3.org/2001/XInclude"
44 xml:id="sec-generators">
5− <title>Generators</title>
5+ <title>Generators</title>
66
7− <para>
8− Generators are functions that create file formats from nix data structures,
9− e. g. for configuration files. There are generators available for:
10− <literal>INI</literal>, <literal>JSON</literal> and <literal>YAML</literal>
11− </para>
7+ <para>
8+ Generators are functions that create file formats from nix data structures,
9+ e. g. for configuration files. There are generators available for:
10+ <literal>INI</literal>, <literal>JSON</literal> and <literal>YAML</literal>
11+ </para>
1212
13− <para>
14− All generators follow a similar call interface: <code>generatorName
15− configFunctions data</code>, where <literal>configFunctions</literal> is an
16− attrset of user-defined functions that format nested parts of the content.
17− They each have common defaults, so often they do not need to be set
18− manually. An example is <code>mkSectionName ? (name: libStr.escape [ "[" "]"
19− ] name)</code> from the <literal>INI</literal> generator. It receives the
20− name of a section and sanitizes it. The default
21− <literal>mkSectionName</literal> escapes <literal>[</literal> and
22− <literal>]</literal> with a backslash.
23− </para>
13+ <para>
14+ All generators follow a similar call interface: <code>generatorName
15+ configFunctions data</code>, where <literal>configFunctions</literal> is an
16+ attrset of user-defined functions that format nested parts of the content.
17+ They each have common defaults, so often they do not need to be set manually.
18+ An example is <code>mkSectionName ? (name: libStr.escape [ "[" "]" ]
19+ name)</code> from the <literal>INI</literal> generator. It receives the name
20+ of a section and sanitizes it. The default <literal>mkSectionName</literal>
21+ escapes <literal>[</literal> and <literal>]</literal> with a backslash.
22+ </para>
2423
25− <para>
26− Generators can be fine-tuned to produce exactly the file format required by
27− your application/service. One example is an INI-file format which uses
28− <literal>: </literal> as separator, the strings
29− <literal>"yes"</literal>/<literal>"no"</literal> as boolean values and
30− requires all string values to be quoted:
31− </para>
24+ <para>
25+ Generators can be fine-tuned to produce exactly the file format required by
26+ your application/service. One example is an INI-file format which uses
27+ <literal>: </literal> as separator, the strings
28+ <literal>"yes"</literal>/<literal>"no"</literal> as boolean values and
29+ requires all string values to be quoted:
30+ </para>
3231
3332<programlisting>
3433with lib;
@@ -60,9 +59,9 @@ in customToINI {
6059}
6160</programlisting>
6261
63− <para>
64− This will produce the following INI file as nix string:
65− </para>
62+ <para>
63+ This will produce the following INI file as nix string:
64+ </para>
6665
6766<programlisting>
6867[main]
@@ -76,15 +75,15 @@ str\:ange:"very::strange"
7675merge:"diff3"
7776</programlisting>
7877
79− <note>
80− <para>
81− Nix store paths can be converted to strings by enclosing a derivation
82− attribute like so: <code>"${drv}"</code>.
83− </para>
84− </note>
85−
78+ <note>
8679 <para>
87− Detailed documentation for each generator can be found in
88− <literal>lib/generators.nix</literal>.
80+ Nix store paths can be converted to strings by enclosing a derivation
81+ attribute like so: <code>"${drv}"</code>.
8982 </para>
90− </section>
83+ </note>
84+
85+ <para>
86+ Detailed documentation for each generator can be found in
87+ <literal>lib/generators.nix</literal>.
88+ </para>
89+</section>
doc/functions/overrides.xml+142−144
@@ -2,28 +2,28 @@
22 xmlns:xlink="http://www.w3.org/1999/xlink"
33 xmlns:xi="http://www.w3.org/2001/XInclude"
44 xml:id="sec-overrides">
5− <title>Overriding</title>
5+ <title>Overriding</title>
66
7− <para>
8− Sometimes one wants to override parts of <literal>nixpkgs</literal>, e.g.
9− derivation attributes, the results of derivations or even the whole package
10− set.
11− </para>
7+ <para>
8+ Sometimes one wants to override parts of <literal>nixpkgs</literal>, e.g.
9+ derivation attributes, the results of derivations or even the whole package
10+ set.
11+ </para>
1212
13− <section xml:id="sec-pkg-override">
14− <title>&lt;pkg&gt;.override</title>
13+ <section xml:id="sec-pkg-override">
14+ <title>&lt;pkg&gt;.override</title>
1515
16− <para>
17− The function <varname>override</varname> is usually available for all the
18− derivations in the nixpkgs expression (<varname>pkgs</varname>).
19− </para>
16+ <para>
17+ The function <varname>override</varname> is usually available for all the
18+ derivations in the nixpkgs expression (<varname>pkgs</varname>).
19+ </para>
2020
21− <para>
22− It is used to override the arguments passed to a function.
23− </para>
21+ <para>
22+ It is used to override the arguments passed to a function.
23+ </para>
2424
25− <para>
26− Example usages:
25+ <para>
26+ Example usages:
2727<programlisting>pkgs.foo.override { arg1 = val1; arg2 = val2; ... }</programlisting>
2828<programlisting>
2929import pkgs.path { overlays = [ (self: super: {
@@ -35,105 +35,103 @@ mypkg = pkgs.callPackage ./mypkg.nix {
3535 mydep = pkgs.mydep.override { ... };
3636 }
3737</programlisting>
38− </para>
38+ </para>
3939
40− <para>
41− In the first example, <varname>pkgs.foo</varname> is the result of a
42− function call with some default arguments, usually a derivation. Using
43− <varname>pkgs.foo.override</varname> will call the same function with the
44− given new arguments.
45− </para>
46− </section>
40+ <para>
41+ In the first example, <varname>pkgs.foo</varname> is the result of a
42+ function call with some default arguments, usually a derivation. Using
43+ <varname>pkgs.foo.override</varname> will call the same function with the
44+ given new arguments.
45+ </para>
46+ </section>
4747
48− <section xml:id="sec-pkg-overrideAttrs">
49− <title>&lt;pkg&gt;.overrideAttrs</title>
48+ <section xml:id="sec-pkg-overrideAttrs">
49+ <title>&lt;pkg&gt;.overrideAttrs</title>
5050
51− <para>
52− The function <varname>overrideAttrs</varname> allows overriding the
53− attribute set passed to a <varname>stdenv.mkDerivation</varname> call,
54− producing a new derivation based on the original one. This function is
55− available on all derivations produced by the
56− <varname>stdenv.mkDerivation</varname> function, which is most packages in
57− the nixpkgs expression <varname>pkgs</varname>.
58− </para>
51+ <para>
52+ The function <varname>overrideAttrs</varname> allows overriding the
53+ attribute set passed to a <varname>stdenv.mkDerivation</varname> call,
54+ producing a new derivation based on the original one. This function is
55+ available on all derivations produced by the
56+ <varname>stdenv.mkDerivation</varname> function, which is most packages in
57+ the nixpkgs expression <varname>pkgs</varname>.
58+ </para>
5959
60− <para>
61− Example usage:
60+ <para>
61+ Example usage:
6262<programlisting>
6363helloWithDebug = pkgs.hello.overrideAttrs (oldAttrs: rec {
6464 separateDebugInfo = true;
6565});
6666</programlisting>
67− </para>
67+ </para>
6868
69− <para>
70− In the above example, the <varname>separateDebugInfo</varname> attribute is
71− overridden to be true, thus building debug info for
72− <varname>helloWithDebug</varname>, while all other attributes will be
73− retained from the original <varname>hello</varname> package.
74− </para>
69+ <para>
70+ In the above example, the <varname>separateDebugInfo</varname> attribute is
71+ overridden to be true, thus building debug info for
72+ <varname>helloWithDebug</varname>, while all other attributes will be
73+ retained from the original <varname>hello</varname> package.
74+ </para>
7575
76− <para>
77− The argument <varname>oldAttrs</varname> is conventionally used to refer to
78− the attr set originally passed to <varname>stdenv.mkDerivation</varname>.
79− </para>
76+ <para>
77+ The argument <varname>oldAttrs</varname> is conventionally used to refer to
78+ the attr set originally passed to <varname>stdenv.mkDerivation</varname>.
79+ </para>
8080
81− <note>
82− <para>
83− Note that <varname>separateDebugInfo</varname> is processed only by the
84− <varname>stdenv.mkDerivation</varname> function, not the generated, raw
85− Nix derivation. Thus, using <varname>overrideDerivation</varname> will not
86− work in this case, as it overrides only the attributes of the final
87− derivation. It is for this reason that <varname>overrideAttrs</varname>
88− should be preferred in (almost) all cases to
89− <varname>overrideDerivation</varname>, i.e. to allow using
90− <varname>sdenv.mkDerivation</varname> to process input arguments, as well
91− as the fact that it is easier to use (you can use the same attribute names
92− you see in your Nix code, instead of the ones generated (e.g.
93− <varname>buildInputs</varname> vs <varname>nativeBuildInputs</varname>,
94− and involves less typing.
95− </para>
96− </note>
97− </section>
98−
99− <section xml:id="sec-pkg-overrideDerivation">
100− <title>&lt;pkg&gt;.overrideDerivation</title>
101−
102− <warning>
103− <para>
104− You should prefer <varname>overrideAttrs</varname> in almost all cases,
105− see its documentation for the reasons why.
106− <varname>overrideDerivation</varname> is not deprecated and will continue
107− to work, but is less nice to use and does not have as many abilities as
108− <varname>overrideAttrs</varname>.
109− </para>
110− </warning>
111−
112− <warning>
113− <para>
114− Do not use this function in Nixpkgs as it evaluates a Derivation before
115− modifying it, which breaks package abstraction and removes error-checking
116− of function arguments. In addition, this evaluation-per-function
117− application incurs a performance penalty, which can become a problem if
118− many overrides are used. It is only intended for ad-hoc customisation,
119− such as in <filename>~/.config/nixpkgs/config.nix</filename>.
120− </para>
121− </warning>
81+ <note>
82+ <para>
83+ Note that <varname>separateDebugInfo</varname> is processed only by the
84+ <varname>stdenv.mkDerivation</varname> function, not the generated, raw Nix
85+ derivation. Thus, using <varname>overrideDerivation</varname> will not work
86+ in this case, as it overrides only the attributes of the final derivation.
87+ It is for this reason that <varname>overrideAttrs</varname> should be
88+ preferred in (almost) all cases to <varname>overrideDerivation</varname>,
89+ i.e. to allow using <varname>sdenv.mkDerivation</varname> to process input
90+ arguments, as well as the fact that it is easier to use (you can use the
91+ same attribute names you see in your Nix code, instead of the ones
92+ generated (e.g. <varname>buildInputs</varname> vs
93+ <varname>nativeBuildInputs</varname>, and involves less typing.
94+ </para>
95+ </note>
96+ </section>
97+
98+ <section xml:id="sec-pkg-overrideDerivation">
99+ <title>&lt;pkg&gt;.overrideDerivation</title>
122100
101+ <warning>
123102 <para>
124− The function <varname>overrideDerivation</varname> creates a new derivation
125− based on an existing one by overriding the original's attributes with the
126− attribute set produced by the specified function. This function is
127− available on all derivations defined using the
128− <varname>makeOverridable</varname> function. Most standard
129− derivation-producing functions, such as
130− <varname>stdenv.mkDerivation</varname>, are defined using this function,
131− which means most packages in the nixpkgs expression,
132− <varname>pkgs</varname>, have this function.
103+ You should prefer <varname>overrideAttrs</varname> in almost all cases, see
104+ its documentation for the reasons why.
105+ <varname>overrideDerivation</varname> is not deprecated and will continue
106+ to work, but is less nice to use and does not have as many abilities as
107+ <varname>overrideAttrs</varname>.
133108 </para>
109+ </warning>
134110
111+ <warning>
135112 <para>
136− Example usage:
113+ Do not use this function in Nixpkgs as it evaluates a Derivation before
114+ modifying it, which breaks package abstraction and removes error-checking
115+ of function arguments. In addition, this evaluation-per-function
116+ application incurs a performance penalty, which can become a problem if
117+ many overrides are used. It is only intended for ad-hoc customisation, such
118+ as in <filename>~/.config/nixpkgs/config.nix</filename>.
119+ </para>
120+ </warning>
121+
122+ <para>
123+ The function <varname>overrideDerivation</varname> creates a new derivation
124+ based on an existing one by overriding the original's attributes with the
125+ attribute set produced by the specified function. This function is available
126+ on all derivations defined using the <varname>makeOverridable</varname>
127+ function. Most standard derivation-producing functions, such as
128+ <varname>stdenv.mkDerivation</varname>, are defined using this function,
129+ which means most packages in the nixpkgs expression,
130+ <varname>pkgs</varname>, have this function.
131+ </para>
132+
133+ <para>
134+ Example usage:
137135<programlisting>
138136mySed = pkgs.gnused.overrideDerivation (oldAttrs: {
139137 name = "sed-4.2.2-pre";
@@ -144,62 +142,62 @@ mySed = pkgs.gnused.overrideDerivation (oldAttrs: {
144142 patches = [];
145143});
146144</programlisting>
147− </para>
145+ </para>
148146
149− <para>
150− In the above example, the <varname>name</varname>, <varname>src</varname>,
151− and <varname>patches</varname> of the derivation will be overridden, while
152− all other attributes will be retained from the original derivation.
153− </para>
147+ <para>
148+ In the above example, the <varname>name</varname>, <varname>src</varname>,
149+ and <varname>patches</varname> of the derivation will be overridden, while
150+ all other attributes will be retained from the original derivation.
151+ </para>
152+
153+ <para>
154+ The argument <varname>oldAttrs</varname> is used to refer to the attribute
155+ set of the original derivation.
156+ </para>
154157
158+ <note>
155159 <para>
156− The argument <varname>oldAttrs</varname> is used to refer to the attribute
157− set of the original derivation.
160+ A package's attributes are evaluated *before* being modified by the
161+ <varname>overrideDerivation</varname> function. For example, the
162+ <varname>name</varname> attribute reference in <varname>url =
163+ "mirror://gnu/hello/${name}.tar.gz";</varname> is filled-in *before* the
164+ <varname>overrideDerivation</varname> function modifies the attribute set.
165+ This means that overriding the <varname>name</varname> attribute, in this
166+ example, *will not* change the value of the <varname>url</varname>
167+ attribute. Instead, we need to override both the <varname>name</varname>
168+ *and* <varname>url</varname> attributes.
158169 </para>
170+ </note>
171+ </section>
159172
160− <note>
161− <para>
162− A package's attributes are evaluated *before* being modified by the
163− <varname>overrideDerivation</varname> function. For example, the
164− <varname>name</varname> attribute reference in <varname>url =
165− "mirror://gnu/hello/${name}.tar.gz";</varname> is filled-in *before* the
166− <varname>overrideDerivation</varname> function modifies the attribute set.
167− This means that overriding the <varname>name</varname> attribute, in this
168− example, *will not* change the value of the <varname>url</varname>
169− attribute. Instead, we need to override both the <varname>name</varname>
170− *and* <varname>url</varname> attributes.
171− </para>
172− </note>
173− </section>
174−
175− <section xml:id="sec-lib-makeOverridable">
176− <title>lib.makeOverridable</title>
173+ <section xml:id="sec-lib-makeOverridable">
174+ <title>lib.makeOverridable</title>
177175
178− <para>
179− The function <varname>lib.makeOverridable</varname> is used to make the
180− result of a function easily customizable. This utility only makes sense for
181− functions that accept an argument set and return an attribute set.
182− </para>
176+ <para>
177+ The function <varname>lib.makeOverridable</varname> is used to make the
178+ result of a function easily customizable. This utility only makes sense for
179+ functions that accept an argument set and return an attribute set.
180+ </para>
183181
184− <para>
185− Example usage:
182+ <para>
183+ Example usage:
186184<programlisting>
187185f = { a, b }: { result = a+b; };
188186c = lib.makeOverridable f { a = 1; b = 2; };
189187</programlisting>
190− </para>
188+ </para>
191189
192− <para>
193− The variable <varname>c</varname> is the value of the <varname>f</varname>
194− function applied with some default arguments. Hence the value of
195− <varname>c.result</varname> is <literal>3</literal>, in this example.
196− </para>
190+ <para>
191+ The variable <varname>c</varname> is the value of the <varname>f</varname>
192+ function applied with some default arguments. Hence the value of
193+ <varname>c.result</varname> is <literal>3</literal>, in this example.
194+ </para>
197195
198− <para>
199− The variable <varname>c</varname> however also has some additional
200− functions, like <link linkend="sec-pkg-override">c.override</link> which
201− can be used to override the default arguments. In this example the value of
202− <varname>(c.override { a = 4; }).result</varname> is 6.
203− </para>
204− </section>
196+ <para>
197+ The variable <varname>c</varname> however also has some additional
198+ functions, like <link linkend="sec-pkg-override">c.override</link> which can
199+ be used to override the default arguments. In this example the value of
200+ <varname>(c.override { a = 4; }).result</varname> is 6.
201+ </para>
205202 </section>
203+</section>
doc/functions/shell.xml+10−11
@@ -2,19 +2,18 @@
22 xmlns:xlink="http://www.w3.org/1999/xlink"
33 xmlns:xi="http://www.w3.org/2001/XInclude"
44 xml:id="sec-pkgs-mkShell">
5− <title>pkgs.mkShell</title>
5+ <title>pkgs.mkShell</title>
66
7− <para>
8− <function>pkgs.mkShell</function> is a special kind of derivation
9− that is only useful when using it combined with
10− <command>nix-shell</command>. It will in fact fail to instantiate
11− when invoked with <command>nix-build</command>.
12− </para>
7+ <para>
8+ <function>pkgs.mkShell</function> is a special kind of derivation that is
9+ only useful when using it combined with <command>nix-shell</command>. It will
10+ in fact fail to instantiate when invoked with <command>nix-build</command>.
11+ </para>
1312
14− <section xml:id="sec-pkgs-mkShell-usage">
15− <title>Usage</title>
13+ <section xml:id="sec-pkgs-mkShell-usage">
14+ <title>Usage</title>
1615
17− <programlisting><![CDATA[
16+<programlisting><![CDATA[
1817{ pkgs ? import <nixpkgs> {} }:
1918pkgs.mkShell {
2019 # this will make all the build inputs from hello and gnutar
@@ -23,5 +22,5 @@ pkgs.mkShell {
2322 buildInputs = [ pkgs.gnumake ];
2423}
2524]]></programlisting>
26− </section>
25+ </section>
2726</section>
doc/package-notes.xml+46−28
@@ -671,8 +671,9 @@ overrides = self: super: rec {
671671 plugins = with availablePlugins; [ python perl ];
672672 }
673673}</programlisting>
674− If the <literal>configure</literal> function returns an attrset without the <literal>plugins</literal>
675− attribute, <literal>availablePlugins</literal> will be used automatically.
674+ If the <literal>configure</literal> function returns an attrset without the
675+ <literal>plugins</literal> attribute, <literal>availablePlugins</literal>
676+ will be used automatically.
676677 </para>
677678
678679 <para>
@@ -706,9 +707,11 @@ overrides = self: super: rec {
706707}; }
707708</programlisting>
708709 </para>
710+
709711 <para>
710− WeeChat allows to set defaults on startup using the <literal>--run-command</literal>.
711− The <literal>configure</literal> method can be used to pass commands to the program:
712+ WeeChat allows to set defaults on startup using the
713+ <literal>--run-command</literal>. The <literal>configure</literal> method
714+ can be used to pass commands to the program:
712715<programlisting>weechat.override {
713716 configure = { availablePlugins, ... }: {
714717 init = ''
@@ -717,12 +720,14 @@ overrides = self: super: rec {
717720 '';
718721 };
719722}</programlisting>
720− Further values can be added to the list of commands when running
721− <literal>weechat --run-command "your-commands"</literal>.
723+ Further values can be added to the list of commands when running
724+ <literal>weechat --run-command "your-commands"</literal>.
722725 </para>
726+
723727 <para>
724− Additionally it's possible to specify scripts to be loaded when starting <literal>weechat</literal>.
725− These will be loaded before the commands from <literal>init</literal>:
728+ Additionally it's possible to specify scripts to be loaded when starting
729+ <literal>weechat</literal>. These will be loaded before the commands from
730+ <literal>init</literal>:
726731<programlisting>weechat.override {
727732 configure = { availablePlugins, ... }: {
728733 scripts = with pkgs.weechatScripts; [
@@ -734,11 +739,13 @@ overrides = self: super: rec {
734739 };
735740}</programlisting>
736741 </para>
742+
737743 <para>
738− In <literal>nixpkgs</literal> there's a subpackage which contains derivations for
739− WeeChat scripts. Such derivations expect a <literal>passthru.scripts</literal> attribute
740− which contains a list of all scripts inside the store path. Furthermore all scripts
741− have to live in <literal>$out/share</literal>. An exemplary derivation looks like this:
744+ In <literal>nixpkgs</literal> there's a subpackage which contains
745+ derivations for WeeChat scripts. Such derivations expect a
746+ <literal>passthru.scripts</literal> attribute which contains a list of all
747+ scripts inside the store path. Furthermore all scripts have to live in
748+ <literal>$out/share</literal>. An exemplary derivation looks like this:
742749<programlisting>{ stdenv, fetchurl }:
743750
744751stdenv.mkDerivation {
@@ -817,20 +824,26 @@ citrix_receiver.override {
817824 <section xml:id="sec-ibus-typing-booster">
818825 <title>ibus-engines.typing-booster</title>
819826
820− <para>This package is an ibus-based completion method to speed up typing.</para>
827+ <para>
828+ This package is an ibus-based completion method to speed up typing.
829+ </para>
821830
822831 <section xml:id="sec-ibus-typing-booster-activate">
823832 <title>Activating the engine</title>
824833
825834 <para>
826− IBus needs to be configured accordingly to activate <literal>typing-booster</literal>. The configuration
827− depends on the desktop manager in use. For detailed instructions, please refer to the
828− <link xlink:href="https://mike-fabian.github.io/ibus-typing-booster/documentation.html">upstream docs</link>.
835+ IBus needs to be configured accordingly to activate
836+ <literal>typing-booster</literal>. The configuration depends on the desktop
837+ manager in use. For detailed instructions, please refer to the
838+ <link xlink:href="https://mike-fabian.github.io/ibus-typing-booster/documentation.html">upstream
839+ docs</link>.
829840 </para>
841+
830842 <para>
831− On NixOS you need to explicitly enable <literal>ibus</literal> with given engines
832− before customizing your desktop to use <literal>typing-booster</literal>. This can be achieved
833− using the <literal>ibus</literal> module:
843+ On NixOS you need to explicitly enable <literal>ibus</literal> with given
844+ engines before customizing your desktop to use
845+ <literal>typing-booster</literal>. This can be achieved using the
846+ <literal>ibus</literal> module:
834847<programlisting>{ pkgs, ... }: {
835848 i18n.inputMethod = {
836849 enabled = "ibus";
@@ -844,17 +857,20 @@ citrix_receiver.override {
844857 <title>Using custom hunspell dictionaries</title>
845858
846859 <para>
847− The IBus engine is based on <literal>hunspell</literal> to support completion in many languages.
848− By default the dictionaries <literal>de-de</literal>, <literal>en-us</literal>, <literal>es-es</literal>,
849− <literal>it-it</literal>, <literal>sv-se</literal> and <literal>sv-fi</literal>
850− are in use. To add another dictionary, the package can be overridden like this:
860+ The IBus engine is based on <literal>hunspell</literal> to support
861+ completion in many languages. By default the dictionaries
862+ <literal>de-de</literal>, <literal>en-us</literal>,
863+ <literal>es-es</literal>, <literal>it-it</literal>,
864+ <literal>sv-se</literal> and <literal>sv-fi</literal> are in use. To add
865+ another dictionary, the package can be overridden like this:
851866<programlisting>ibus-engines.typing-booster.override {
852867 langs = [ "de-at" "en-gb" ];
853868}</programlisting>
854869 </para>
870+
855871 <para>
856− <emphasis>Note: each language passed to <literal>langs</literal> must be an attribute name in
857− <literal>pkgs.hunspellDicts</literal>.</emphasis>
872+ <emphasis>Note: each language passed to <literal>langs</literal> must be an
873+ attribute name in <literal>pkgs.hunspellDicts</literal>.</emphasis>
858874 </para>
859875 </section>
860876
@@ -862,10 +878,12 @@ citrix_receiver.override {
862878 <title>Built-in emoji picker</title>
863879
864880 <para>
865− The <literal>ibus-engines.typing-booster</literal> package contains a program
866− named <literal>emoji-picker</literal>. To display all emojis correctly,
867− a special font such as <literal>noto-fonts-emoji</literal> is needed:
881+ The <literal>ibus-engines.typing-booster</literal> package contains a
882+ program named <literal>emoji-picker</literal>. To display all emojis
883+ correctly, a special font such as <literal>noto-fonts-emoji</literal> is
884+ needed:
868885 </para>
886+
869887 <para>
870888 On NixOS it can be installed using the following expression:
871889<programlisting>{ pkgs, ... }: {