@@ -8,252 +8,295 @@
88 The nixpkgs repository has several utility functions to manipulate Nix expressions.
99</para>
1010
11−<section xml:id="sec-pkgs-overridePackages">
12− <title>pkgs.overridePackages</title>
11+<section xml:id="sec-overrides">
12+ <title>Overriding</title>
1313
1414 <para>
15− This function inside the nixpkgs expression (<varname>pkgs</varname>)
16− can be used to override the set of packages itself.
17− </para>
18− <para>
19− Warning: this function is expensive and must not be used from within
20− the nixpkgs repository.
21− </para>
22− <para>
23− Example usage:
24−
25− <programlisting>let
26− pkgs = import <nixpkgs> {};
27− newpkgs = pkgs.overridePackages (self: super: {
28− foo = super.foo.override { ... };
29− };
30−in ...</programlisting>
15+ Sometimes one wants to override parts of
16+ <literal>nixpkgs</literal>, e.g. derivation attributes, the results of
17+ derivations or even the whole package set.
3118 </para>
3219
33− <para>
34− The resulting <varname>newpkgs</varname> will have the new <varname>foo</varname>
35− expression, and all other expressions depending on <varname>foo</varname> will also
36− use the new <varname>foo</varname> expression.
37− </para>
20+ <section xml:id="sec-pkgs-overridePackages">
21+ <title>pkgs.overridePackages</title>
3822
39− <para>
40− The behavior of this function is similar to <link
41− linkend="sec-modify-via-packageOverrides">config.packageOverrides</link>.
42− </para>
23+ <para>
24+ This function inside the nixpkgs expression (<varname>pkgs</varname>)
25+ can be used to override the set of packages itself.
26+ </para>
27+ <para>
28+ Warning: this function is expensive and must not be used from within
29+ the nixpkgs repository.
30+ </para>
31+ <para>
32+ Example usage:
4333
44− <para>
45− The <varname>self</varname> parameter refers to the final package set with the
46− applied overrides. Using this parameter may lead to infinite recursion if not
47− used consciously.
48− </para>
34+ <programlisting>let
35+ pkgs = import <nixpkgs> {};
36+ newpkgs = pkgs.overridePackages (self: super: {
37+ foo = super.foo.override { ... };
38+ };
39+ in ...</programlisting>
40+ </para>
4941
50− <para>
51− The <varname>super</varname> parameter refers to the old package set.
52− It's equivalent to <varname>pkgs</varname> in the above example.
53− </para>
42+ <para>
43+ The resulting <varname>newpkgs</varname> will have the new <varname>foo</varname>
44+ expression, and all other expressions depending on <varname>foo</varname> will also
45+ use the new <varname>foo</varname> expression.
46+ </para>
5447
55− <para>
56− Note that in previous versions of nixpkgs, this method replaced any changes from <link
57− linkend="sec-modify-via-packageOverrides">config.packageOverrides</link>,
58− along with that from previous calls if this function was called repeatedly.
59− Now those previous changes will be preserved so this function can be "chained" meaningfully.
60− To recover the old behavior, make sure <varname>config.packageOverrides</varname> is unset,
61− and call this only once off a "freshly" imported nixpkgs:
62−
63− <programlisting>let
64− pkgs = import <nixpkgs> { config: {}; };
65− newpkgs = pkgs.overridePackages ...;
66−in ...</programlisting>
67− </para>
48+ <para>
49+ The behavior of this function is similar to <link
50+ linkend="sec-modify-via-packageOverrides">config.packageOverrides</link>.
51+ </para>
6852
69−</section>
53+ <para>
54+ The <varname>self</varname> parameter refers to the final package set with the
55+ applied overrides. Using this parameter may lead to infinite recursion if not
56+ used consciously.
57+ </para>
7058
71−<section xml:id="sec-pkg-override">
72− <title><pkg>.override</title>
59+ <para>
60+ The <varname>super</varname> parameter refers to the old package set.
61+ It's equivalent to <varname>pkgs</varname> in the above example.
62+ </para>
7363
74− <para>
75− The function <varname>override</varname> is usually available for all the
76− derivations in the nixpkgs expression (<varname>pkgs</varname>).
77− </para>
78− <para>
79− It is used to override the arguments passed to a function.
80− </para>
81− <para>
82− Example usages:
83−
84− <programlisting>pkgs.foo.override { arg1 = val1; arg2 = val2; ... }</programlisting>
85− <programlisting>pkgs.overridePackages (self: super: {
86− foo = super.foo.override { barSupport = true ; };
87−})</programlisting>
88− <programlisting>mypkg = pkgs.callPackage ./mypkg.nix {
89− mydep = pkgs.mydep.override { ... };
90−})</programlisting>
91− </para>
64+ <para>
65+ Note that in previous versions of nixpkgs, this method replaced any changes from <link
66+ linkend="sec-modify-via-packageOverrides">config.packageOverrides</link>,
67+ along with that from previous calls if this function was called repeatedly.
68+ Now those previous changes will be preserved so this function can be "chained" meaningfully.
69+ To recover the old behavior, make sure <varname>config.packageOverrides</varname> is unset,
70+ and call this only once off a "freshly" imported nixpkgs:
71+
72+ <programlisting>let
73+ pkgs = import <nixpkgs> { config: {}; };
74+ newpkgs = pkgs.overridePackages ...;
75+ in ...</programlisting>
76+ </para>
9277
93− <para>
94− In the first example, <varname>pkgs.foo</varname> is the result of a function call
95− with some default arguments, usually a derivation.
96− Using <varname>pkgs.foo.override</varname> will call the same function with
97− the given new arguments.
98− </para>
78+ </section>
9979
100−</section>
80+ <section xml:id="sec-pkg-override">
81+ <title><pkg>.override</title>
10182
102−<section xml:id="sec-pkg-overrideAttrs">
103− <title><pkg>.overrideAttrs</title>
83+ <para>
84+ The function <varname>override</varname> is usually available for all the
85+ derivations in the nixpkgs expression (<varname>pkgs</varname>).
86+ </para>
87+ <para>
88+ It is used to override the arguments passed to a function.
89+ </para>
90+ <para>
91+ Example usages:
92+
93+ <programlisting>pkgs.foo.override { arg1 = val1; arg2 = val2; ... }</programlisting>
94+ <programlisting>pkgs.overridePackages (self: super: {
95+ foo = super.foo.override { barSupport = true ; };
96+ })</programlisting>
97+ <programlisting>mypkg = pkgs.callPackage ./mypkg.nix {
98+ mydep = pkgs.mydep.override { ... };
99+ })</programlisting>
100+ </para>
104101
105− <para>
106− The function <varname>overrideAttrs</varname> allows overriding the
107− attribute set passed to a <varname>stdenv.mkDerivation</varname> call,
108− producing a new derivation based on the original one.
109− This function is available on all derivations produced by the
110− <varname>stdenv.mkDerivation</varname> function, which is most packages
111− in the nixpkgs expression <varname>pkgs</varname>.
112− </para>
102+ <para>
103+ In the first example, <varname>pkgs.foo</varname> is the result of a function call
104+ with some default arguments, usually a derivation.
105+ Using <varname>pkgs.foo.override</varname> will call the same function with
106+ the given new arguments.
107+ </para>
113108
114− <para>
115− Example usage:
109+ </section>
116110
117− <programlisting>helloWithDebug = pkgs.hello.overrideAttrs (oldAttrs: rec {
118− separateDebugInfo = true;
119−});</programlisting>
120− </para>
111+ <section xml:id="sec-pkg-overrideAttrs">
112+ <title><pkg>.overrideAttrs</title>
121113
122− <para>
123− In the above example, the <varname>separateDebugInfo</varname> attribute is
124− overriden to be true, thus building debug info for
125− <varname>helloWithDebug</varname>, while all other attributes will be
126− retained from the original <varname>hello</varname> package.
127− </para>
114+ <para>
115+ The function <varname>overrideAttrs</varname> allows overriding the
116+ attribute set passed to a <varname>stdenv.mkDerivation</varname> call,
117+ producing a new derivation based on the original one.
118+ This function is available on all derivations produced by the
119+ <varname>stdenv.mkDerivation</varname> function, which is most packages
120+ in the nixpkgs expression <varname>pkgs</varname>.
121+ </para>
128122
129− <para>
130− The argument <varname>oldAttrs</varname> is conventionally used to refer to
131− the attr set originally passed to <varname>stdenv.mkDerivation</varname>.
132− </para>
123+ <para>
124+ Example usage:
125+
126+ <programlisting>helloWithDebug = pkgs.hello.overrideAttrs (oldAttrs: rec {
127+ separateDebugInfo = true;
128+ });</programlisting>
129+ </para>
133130
134− <note>
135131 <para>
136− Note that <varname>separateDebugInfo</varname> is processed only by the
137− <varname>stdenv.mkDerivation</varname> function, not the generated, raw
138− Nix derivation. Thus, using <varname>overrideDerivation</varname> will
139− not work in this case, as it overrides only the attributes of the final
140− derivation. It is for this reason that <varname>overrideAttrs</varname>
141− should be preferred in (almost) all cases to
142− <varname>overrideDerivation</varname>, i.e. to allow using
143− <varname>sdenv.mkDerivation</varname> to process input arguments, as well
144− as the fact that it is easier to use (you can use the same attribute
145− names you see in your Nix code, instead of the ones generated (e.g.
146− <varname>buildInputs</varname> vs <varname>nativeBuildInputs</varname>,
147− and involves less typing.
132+ In the above example, the <varname>separateDebugInfo</varname> attribute is
133+ overriden to be true, thus building debug info for
134+ <varname>helloWithDebug</varname>, while all other attributes will be
135+ retained from the original <varname>hello</varname> package.
148136 </para>
149− </note>
150137
151−</section>
138+ <para>
139+ The argument <varname>oldAttrs</varname> is conventionally used to refer to
140+ the attr set originally passed to <varname>stdenv.mkDerivation</varname>.
141+ </para>
142+
143+ <note>
144+ <para>
145+ Note that <varname>separateDebugInfo</varname> is processed only by the
146+ <varname>stdenv.mkDerivation</varname> function, not the generated, raw
147+ Nix derivation. Thus, using <varname>overrideDerivation</varname> will
148+ not work in this case, as it overrides only the attributes of the final
149+ derivation. It is for this reason that <varname>overrideAttrs</varname>
150+ should be preferred in (almost) all cases to
151+ <varname>overrideDerivation</varname>, i.e. to allow using
152+ <varname>sdenv.mkDerivation</varname> to process input arguments, as well
153+ as the fact that it is easier to use (you can use the same attribute
154+ names you see in your Nix code, instead of the ones generated (e.g.
155+ <varname>buildInputs</varname> vs <varname>nativeBuildInputs</varname>,
156+ and involves less typing.
157+ </para>
158+ </note>
159+
160+ </section>
152161
153162
154−<section xml:id="sec-pkg-overrideDerivation">
155− <title><pkg>.overrideDerivation</title>
163+ <section xml:id="sec-pkg-overrideDerivation">
164+ <title><pkg>.overrideDerivation</title>
156165
157− <warning>
158− <para>You should prefer <varname>overrideAttrs</varname> in almost all
159− cases, see its documentation for the reasons why.
160− <varname>overrideDerivation</varname> is not deprecated and will continue
161− to work, but is less nice to use and does not have as many abilities as
162− <varname>overrideAttrs</varname>.
166+ <warning>
167+ <para>You should prefer <varname>overrideAttrs</varname> in almost all
168+ cases, see its documentation for the reasons why.
169+ <varname>overrideDerivation</varname> is not deprecated and will continue
170+ to work, but is less nice to use and does not have as many abilities as
171+ <varname>overrideAttrs</varname>.
172+ </para>
173+ </warning>
174+
175+ <warning>
176+ <para>Do not use this function in Nixpkgs as it evaluates a Derivation
177+ before modifying it, which breaks package abstraction and removes
178+ error-checking of function arguments. In addition, this
179+ evaluation-per-function application incurs a performance penalty,
180+ which can become a problem if many overrides are used.
181+ It is only intended for ad-hoc customisation, such as in
182+ <filename>~/.nixpkgs/config.nix</filename>.
163183 </para>
164− </warning>
184+ </warning>
165185
166− <warning>
167− <para>Do not use this function in Nixpkgs as it evaluates a Derivation
168− before modifying it, which breaks package abstraction and removes
169− error-checking of function arguments. In addition, this
170− evaluation-per-function application incurs a performance penalty,
171− which can become a problem if many overrides are used.
172− It is only intended for ad-hoc customisation, such as in
173− <filename>~/.nixpkgs/config.nix</filename>.
174− </para>
175− </warning>
186+ <para>
187+ The function <varname>overrideDerivation</varname> creates a new derivation
188+ based on an existing one by overriding the original's attributes with
189+ the attribute set produced by the specified function.
190+ This function is available on all
191+ derivations defined using the <varname>makeOverridable</varname> function.
192+ Most standard derivation-producing functions, such as
193+ <varname>stdenv.mkDerivation</varname>, are defined using this
194+ function, which means most packages in the nixpkgs expression,
195+ <varname>pkgs</varname>, have this function.
196+ </para>
176197
177− <para>
178− The function <varname>overrideDerivation</varname> creates a new derivation
179− based on an existing one by overriding the original's attributes with
180− the attribute set produced by the specified function.
181− This function is available on all
182− derivations defined using the <varname>makeOverridable</varname> function.
183− Most standard derivation-producing functions, such as
184− <varname>stdenv.mkDerivation</varname>, are defined using this
185− function, which means most packages in the nixpkgs expression,
186− <varname>pkgs</varname>, have this function.
187− </para>
198+ <para>
199+ Example usage:
188200
189− <para>
190− Example usage:
191−
192− <programlisting>mySed = pkgs.gnused.overrideDerivation (oldAttrs: {
193− name = "sed-4.2.2-pre";
194− src = fetchurl {
195− url = ftp://alpha.gnu.org/gnu/sed/sed-4.2.2-pre.tar.bz2;
196− sha256 = "11nq06d131y4wmf3drm0yk502d2xc6n5qy82cg88rb9nqd2lj41k";
197− };
198− patches = [];
199−});</programlisting>
200− </para>
201+ <programlisting>mySed = pkgs.gnused.overrideDerivation (oldAttrs: {
202+ name = "sed-4.2.2-pre";
203+ src = fetchurl {
204+ url = ftp://alpha.gnu.org/gnu/sed/sed-4.2.2-pre.tar.bz2;
205+ sha256 = "11nq06d131y4wmf3drm0yk502d2xc6n5qy82cg88rb9nqd2lj41k";
206+ };
207+ patches = [];
208+ });</programlisting>
209+ </para>
201210
202− <para>
203− In the above example, the <varname>name</varname>, <varname>src</varname>,
204− and <varname>patches</varname> of the derivation will be overridden, while
205− all other attributes will be retained from the original derivation.
206− </para>
211+ <para>
212+ In the above example, the <varname>name</varname>, <varname>src</varname>,
213+ and <varname>patches</varname> of the derivation will be overridden, while
214+ all other attributes will be retained from the original derivation.
215+ </para>
207216
208− <para>
209− The argument <varname>oldAttrs</varname> is used to refer to the attribute set of
210− the original derivation.
211− </para>
217+ <para>
218+ The argument <varname>oldAttrs</varname> is used to refer to the attribute set of
219+ the original derivation.
220+ </para>
221+
222+ <note>
223+ <para>
224+ A package's attributes are evaluated *before* being modified by
225+ the <varname>overrideDerivation</varname> function.
226+ For example, the <varname>name</varname> attribute reference
227+ in <varname>url = "mirror://gnu/hello/${name}.tar.gz";</varname>
228+ is filled-in *before* the <varname>overrideDerivation</varname> function
229+ modifies the attribute set. This means that overriding the
230+ <varname>name</varname> attribute, in this example, *will not* change the
231+ value of the <varname>url</varname> attribute. Instead, we need to override
232+ both the <varname>name</varname> *and* <varname>url</varname> attributes.
233+ </para>
234+ </note>
235+
236+ </section>
237+
238+ <section xml:id="sec-lib-makeOverridable">
239+ <title>lib.makeOverridable</title>
212240
213− <note>
214241 <para>
215− A package's attributes are evaluated *before* being modified by
216− the <varname>overrideDerivation</varname> function.
217− For example, the <varname>name</varname> attribute reference
218− in <varname>url = "mirror://gnu/hello/${name}.tar.gz";</varname>
219− is filled-in *before* the <varname>overrideDerivation</varname> function
220− modifies the attribute set. This means that overriding the
221− <varname>name</varname> attribute, in this example, *will not* change the
222− value of the <varname>url</varname> attribute. Instead, we need to override
223− both the <varname>name</varname> *and* <varname>url</varname> attributes.
242+ The function <varname>lib.makeOverridable</varname> is used to make the result
243+ of a function easily customizable. This utility only makes sense for functions
244+ that accept an argument set and return an attribute set.
224245 </para>
225− </note>
226246
227−</section>
247+ <para>
248+ Example usage:
228249
229−<section xml:id="sec-lib-makeOverridable">
230− <title>lib.makeOverridable</title>
250+ <programlisting>f = { a, b }: { result = a+b; }
251+ c = lib.makeOverridable f { a = 1; b = 2; }</programlisting>
231252
232− <para>
233− The function <varname>lib.makeOverridable</varname> is used to make the result
234− of a function easily customizable. This utility only makes sense for functions
235− that accept an argument set and return an attribute set.
236− </para>
253+ </para>
237254
238− <para>
239− Example usage:
255+ <para>
256+ The variable <varname>c</varname> is the value of the <varname>f</varname> function
257+ applied with some default arguments. Hence the value of <varname>c.result</varname>
258+ is <literal>3</literal>, in this example.
259+ </para>
240260
241− <programlisting>f = { a, b }: { result = a+b; }
242−c = lib.makeOverridable f { a = 1; b = 2; }</programlisting>
261+ <para>
262+ The variable <varname>c</varname> however also has some additional functions, like
263+ <link linkend="sec-pkg-override">c.override</link> which can be used to
264+ override the default arguments. In this example the value of
265+ <varname>(c.override { a = 4; }).result</varname> is 6.
266+ </para>
267+
268+ </section>
269+
270+</section>
243271
272+<section xml:id="sec-generators">
273+ <title>Generators</title>
274+
275+ <para>
276+ Generators are functions that create file formats from nix
277+ data structures, e. g. for configuration files.
278+ There are generators available for: <literal>INI</literal>,
279+ <literal>JSON</literal> and <literal>YAML</literal>
244280 </para>
245281
246282 <para>
247− The variable <varname>c</varname> is the value of the <varname>f</varname> function
248− applied with some default arguments. Hence the value of <varname>c.result</varname>
249− is <literal>3</literal>, in this example.
283+ All generators follow a similar call interface: <code>generatorName
284+ configFunctions data</code>, where <literal>configFunctions</literal> is a
285+ set of user-defined functions that format variable parts of the content.
286+ They each have common defaults, so often they do not need to be set
287+ manually. An example is <code>mkSectionName ? (name: libStr.escape [ "[" "]"
288+ ] name)</code> from the <literal>INI</literal> generator. It gets the name
289+ of a section and returns a sanitized name. The default
290+ <literal>mkSectionName</literal> escapes <literal>[</literal> and
291+ <literal>]</literal> with a backslash.
250292 </para>
251293
294+ <note><para>Nix store paths can be converted to strings by enclosing a
295+ derivation attribute like so: <code>"${drv}"</code>.</para></note>
296+
252297 <para>
253− The variable <varname>c</varname> however also has some additional functions, like
254− <link linkend="sec-pkg-override">c.override</link> which can be used to
255− override the default arguments. In this example the value of
256− <varname>(c.override { a = 4; }).result</varname> is 6.
298+ Detailed documentation for each generator can be found in
299+ <literal>lib/generators.nix</literal>.
257300 </para>
258301
259302</section>
@@ -370,37 +413,37 @@ c = lib.makeOverridable f { a = 1; b = 2; }</programlisting>
370413</section>
371414
372415<section xml:id="sec-pkgs-dockerTools">
373− <title>pkgs.dockerTools</title>
416+<title>pkgs.dockerTools</title>
374417
375− <para>
418+<para>
376419 <varname>pkgs.dockerTools</varname> is a set of functions for creating and
377420 manipulating Docker images according to the
378421 <link xlink:href="https://github.com/docker/docker/blob/master/image/spec/v1.md#docker-image-specification-v100">
379− Docker Image Specification v1.0.0
422+ Docker Image Specification v1.0.0
380423 </link>. Docker itself is not used to perform any of the operations done by these
381424 functions.
382− </para>
425+</para>
383426
384− <warning>
427+<warning>
385428 <para>
386− The <varname>dockerTools</varname> API is unstable and may be subject to
387− backwards-incompatible changes in the future.
429+ The <varname>dockerTools</varname> API is unstable and may be subject to
430+ backwards-incompatible changes in the future.
388431 </para>
389− </warning>
432+</warning>
390433
391− <section xml:id="ssec-pkgs-dockerTools-buildImage">
434+<section xml:id="ssec-pkgs-dockerTools-buildImage">
392435 <title>buildImage</title>
393436
394437 <para>
395− This function is analogous to the <command>docker build</command> command,
396− in that can used to build a Docker-compatible repository tarball containing
397− a single image with one or multiple layers. As such, the result
398− is suitable for being loaded in Docker with <command>docker load</command>.
438+ This function is analogous to the <command>docker build</command> command,
439+ in that can used to build a Docker-compatible repository tarball containing
440+ a single image with one or multiple layers. As such, the result
441+ is suitable for being loaded in Docker with <command>docker load</command>.
399442 </para>
400443
401444 <para>
402− The parameters of <varname>buildImage</varname> with relative example values are
403− described below:
445+ The parameters of <varname>buildImage</varname> with relative example values are
446+ described below:
404447 </para>
405448
406449 <example xml:id='ex-dockerTools-buildImage'><title>Docker build</title>
@@ -408,11 +451,11 @@ c = lib.makeOverridable f { a = 1; b = 2; }</programlisting>
408451 buildImage {
409452 name = "redis"; <co xml:id='ex-dockerTools-buildImage-1' />
410453 tag = "latest"; <co xml:id='ex-dockerTools-buildImage-2' />
411−
454+
412455 fromImage = someBaseImage; <co xml:id='ex-dockerTools-buildImage-3' />
413456 fromImageName = null; <co xml:id='ex-dockerTools-buildImage-4' />
414457 fromImageTag = "latest"; <co xml:id='ex-dockerTools-buildImage-5' />
415−
458+
416459 contents = pkgs.redis; <co xml:id='ex-dockerTools-buildImage-6' />
417460 runAsRoot = '' <co xml:id='ex-dockerTools-buildImage-runAsRoot' />
418461 #!${stdenv.shell}
@@ -431,131 +474,131 @@ c = lib.makeOverridable f { a = 1; b = 2; }</programlisting>
431474 </example>
432475
433476 <para>The above example will build a Docker image <literal>redis/latest</literal>
434− from the given base image. Loading and running this image in Docker results in
435− <literal>redis-server</literal> being started automatically.
477+ from the given base image. Loading and running this image in Docker results in
478+ <literal>redis-server</literal> being started automatically.
436479 </para>
437480
438481 <calloutlist>
439− <callout arearefs='ex-dockerTools-buildImage-1'>
482+ <callout arearefs='ex-dockerTools-buildImage-1'>
440483 <para>
441− <varname>name</varname> specifies the name of the resulting image.
442− This is the only required argument for <varname>buildImage</varname>.
484+ <varname>name</varname> specifies the name of the resulting image.
485+ This is the only required argument for <varname>buildImage</varname>.
443486 </para>
444− </callout>
487+ </callout>
445488
446− <callout arearefs='ex-dockerTools-buildImage-2'>
489+ <callout arearefs='ex-dockerTools-buildImage-2'>
447490 <para>
448− <varname>tag</varname> specifies the tag of the resulting image.
449− By default it's <literal>latest</literal>.
491+ <varname>tag</varname> specifies the tag of the resulting image.
492+ By default it's <literal>latest</literal>.
450493 </para>
451− </callout>
494+ </callout>
452495
453− <callout arearefs='ex-dockerTools-buildImage-3'>
496+ <callout arearefs='ex-dockerTools-buildImage-3'>
454497 <para>
455− <varname>fromImage</varname> is the repository tarball containing the base image.
456− It must be a valid Docker image, such as exported by <command>docker save</command>.
457− By default it's <literal>null</literal>, which can be seen as equivalent
458− to <literal>FROM scratch</literal> of a <filename>Dockerfile</filename>.
498+ <varname>fromImage</varname> is the repository tarball containing the base image.
499+ It must be a valid Docker image, such as exported by <command>docker save</command>.
500+ By default it's <literal>null</literal>, which can be seen as equivalent
501+ to <literal>FROM scratch</literal> of a <filename>Dockerfile</filename>.
459502 </para>
460− </callout>
461−
462− <callout arearefs='ex-dockerTools-buildImage-4'>
503+ </callout>
504+
505+ <callout arearefs='ex-dockerTools-buildImage-4'>
463506 <para>
464− <varname>fromImageName</varname> can be used to further specify
465− the base image within the repository, in case it contains multiple images.
466− By default it's <literal>null</literal>, in which case
467− <varname>buildImage</varname> will peek the first image available
468− in the repository.
507+ <varname>fromImageName</varname> can be used to further specify
508+ the base image within the repository, in case it contains multiple images.
509+ By default it's <literal>null</literal>, in which case
510+ <varname>buildImage</varname> will peek the first image available
511+ in the repository.
469512 </para>
470− </callout>
513+ </callout>
471514
472− <callout arearefs='ex-dockerTools-buildImage-5'>
515+ <callout arearefs='ex-dockerTools-buildImage-5'>
473516 <para>
474− <varname>fromImageTag</varname> can be used to further specify the tag
475− of the base image within the repository, in case an image contains multiple tags.
476− By default it's <literal>null</literal>, in which case
477− <varname>buildImage</varname> will peek the first tag available for the base image.
517+ <varname>fromImageTag</varname> can be used to further specify the tag
518+ of the base image within the repository, in case an image contains multiple tags.
519+ By default it's <literal>null</literal>, in which case
520+ <varname>buildImage</varname> will peek the first tag available for the base image.
478521 </para>
479− </callout>
522+ </callout>
480523
481− <callout arearefs='ex-dockerTools-buildImage-6'>
524+ <callout arearefs='ex-dockerTools-buildImage-6'>
482525 <para>
483− <varname>contents</varname> is a derivation that will be copied in the new
484− layer of the resulting image. This can be similarly seen as
485− <command>ADD contents/ /</command> in a <filename>Dockerfile</filename>.
486− By default it's <literal>null</literal>.
526+ <varname>contents</varname> is a derivation that will be copied in the new
527+ layer of the resulting image. This can be similarly seen as
528+ <command>ADD contents/ /</command> in a <filename>Dockerfile</filename>.
529+ By default it's <literal>null</literal>.
487530 </para>
488− </callout>
531+ </callout>
489532
490− <callout arearefs='ex-dockerTools-buildImage-runAsRoot'>
533+ <callout arearefs='ex-dockerTools-buildImage-runAsRoot'>
491534 <para>
492− <varname>runAsRoot</varname> is a bash script that will run as root
493− in an environment that overlays the existing layers of the base image with
494− the new resulting layer, including the previously copied
495− <varname>contents</varname> derivation.
496− This can be similarly seen as
497− <command>RUN ...</command> in a <filename>Dockerfile</filename>.
498−
499− <note>
535+ <varname>runAsRoot</varname> is a bash script that will run as root
536+ in an environment that overlays the existing layers of the base image with
537+ the new resulting layer, including the previously copied
538+ <varname>contents</varname> derivation.
539+ This can be similarly seen as
540+ <command>RUN ...</command> in a <filename>Dockerfile</filename>.
541+
542+ <note>
500543 <para>
501− Using this parameter requires the <literal>kvm</literal>
502− device to be available.
544+ Using this parameter requires the <literal>kvm</literal>
545+ device to be available.
503546 </para>
504− </note>
547+ </note>
505548 </para>
506− </callout>
549+ </callout>
507550
508− <callout arearefs='ex-dockerTools-buildImage-8'>
551+ <callout arearefs='ex-dockerTools-buildImage-8'>
509552 <para>
510− <varname>config</varname> is used to specify the configuration of the
511− containers that will be started off the built image in Docker.
512− The available options are listed in the
513− <link xlink:href="https://github.com/docker/docker/blob/master/image/spec/v1.md#container-runconfig-field-descriptions">
553+ <varname>config</varname> is used to specify the configuration of the
554+ containers that will be started off the built image in Docker.
555+ The available options are listed in the
556+ <link xlink:href="https://github.com/docker/docker/blob/master/image/spec/v1.md#container-runconfig-field-descriptions">
514557 Docker Image Specification v1.0.0
515− </link>.
558+ </link>.
516559 </para>
517− </callout>
560+ </callout>
518561
519562 </calloutlist>
520563
521564 <para>
522− After the new layer has been created, its closure
523− (to which <varname>contents</varname>, <varname>config</varname> and
524− <varname>runAsRoot</varname> contribute) will be copied in the layer itself.
525− Only new dependencies that are not already in the existing layers will be copied.
565+ After the new layer has been created, its closure
566+ (to which <varname>contents</varname>, <varname>config</varname> and
567+ <varname>runAsRoot</varname> contribute) will be copied in the layer itself.
568+ Only new dependencies that are not already in the existing layers will be copied.
526569 </para>
527570
528571 <para>
529− At the end of the process, only one new single layer will be produced and
530− added to the resulting image.
572+ At the end of the process, only one new single layer will be produced and
573+ added to the resulting image.
531574 </para>
532575
533576 <para>
534− The resulting repository will only list the single image
535− <varname>image/tag</varname>. In the case of <xref linkend='ex-dockerTools-buildImage'/>
536− it would be <varname>redis/latest</varname>.
577+ The resulting repository will only list the single image
578+ <varname>image/tag</varname>. In the case of <xref linkend='ex-dockerTools-buildImage'/>
579+ it would be <varname>redis/latest</varname>.
537580 </para>
538581
539582 <para>
540− It is possible to inspect the arguments with which an image was built
541− using its <varname>buildArgs</varname> attribute.
583+ It is possible to inspect the arguments with which an image was built
584+ using its <varname>buildArgs</varname> attribute.
542585 </para>
543586
544− </section>
587+</section>
545588
546− <section xml:id="ssec-pkgs-dockerTools-fetchFromRegistry">
589+<section xml:id="ssec-pkgs-dockerTools-fetchFromRegistry">
547590 <title>pullImage</title>
548591
549592 <para>
550− This function is analogous to the <command>docker pull</command> command,
551− in that can be used to fetch a Docker image from a Docker registry.
552− Currently only registry <literal>v1</literal> is supported.
553− By default <link xlink:href="https://hub.docker.com/">Docker Hub</link>
554− is used to pull images.
593+ This function is analogous to the <command>docker pull</command> command,
594+ in that can be used to fetch a Docker image from a Docker registry.
595+ Currently only registry <literal>v1</literal> is supported.
596+ By default <link xlink:href="https://hub.docker.com/">Docker Hub</link>
597+ is used to pull images.
555598 </para>
556599
557600 <para>
558− Its parameters are described in the example below:
601+ Its parameters are described in the example below:
559602 </para>
560603
561604 <example xml:id='ex-dockerTools-pullImage'><title>Docker pull</title>
@@ -573,73 +616,73 @@ c = lib.makeOverridable f { a = 1; b = 2; }</programlisting>
573616 </example>
574617
575618 <calloutlist>
576− <callout arearefs='ex-dockerTools-pullImage-1'>
619+ <callout arearefs='ex-dockerTools-pullImage-1'>
577620 <para>
578− <varname>imageName</varname> specifies the name of the image to be downloaded,
579− which can also include the registry namespace (e.g. <literal>library/debian</literal>).
580− This argument is required.
621+ <varname>imageName</varname> specifies the name of the image to be downloaded,
622+ which can also include the registry namespace (e.g. <literal>library/debian</literal>).
623+ This argument is required.
581624 </para>
582− </callout>
583−
584− <callout arearefs='ex-dockerTools-pullImage-2'>
625+ </callout>
626+
627+ <callout arearefs='ex-dockerTools-pullImage-2'>
585628 <para>
586− <varname>imageTag</varname> specifies the tag of the image to be downloaded.
587− By default it's <literal>latest</literal>.
629+ <varname>imageTag</varname> specifies the tag of the image to be downloaded.
630+ By default it's <literal>latest</literal>.
588631 </para>
589− </callout>
632+ </callout>
590633
591− <callout arearefs='ex-dockerTools-pullImage-3'>
634+ <callout arearefs='ex-dockerTools-pullImage-3'>
592635 <para>
593− <varname>imageId</varname>, if specified this exact image will be fetched, instead
594− of <varname>imageName/imageTag</varname>. However, the resulting repository
595− will still be named <varname>imageName/imageTag</varname>.
596− By default it's <literal>null</literal>.
636+ <varname>imageId</varname>, if specified this exact image will be fetched, instead
637+ of <varname>imageName/imageTag</varname>. However, the resulting repository
638+ will still be named <varname>imageName/imageTag</varname>.
639+ By default it's <literal>null</literal>.
597640 </para>
598− </callout>
641+ </callout>
599642
600− <callout arearefs='ex-dockerTools-pullImage-4'>
643+ <callout arearefs='ex-dockerTools-pullImage-4'>
601644 <para>
602− <varname>sha256</varname> is the checksum of the whole fetched image.
603− This argument is required.
645+ <varname>sha256</varname> is the checksum of the whole fetched image.
646+ This argument is required.
604647 </para>
605648
606649 <note>
607− <para>The checksum is computed on the unpacked directory, not on the final tarball.</para>
650+ <para>The checksum is computed on the unpacked directory, not on the final tarball.</para>
608651 </note>
609652
610− </callout>
653+ </callout>
611654
612− <callout arearefs='ex-dockerTools-pullImage-5'>
655+ <callout arearefs='ex-dockerTools-pullImage-5'>
613656 <para>
614− In the above example the default values are shown for the variables
615− <varname>indexUrl</varname> and <varname>registryVersion</varname>.
616− Hence by default the Docker.io registry is used to pull the images.
657+ In the above example the default values are shown for the variables
658+ <varname>indexUrl</varname> and <varname>registryVersion</varname>.
659+ Hence by default the Docker.io registry is used to pull the images.
617660 </para>
618− </callout>
661+ </callout>
619662 </calloutlist>
620−
621− </section>
622−
623− <section xml:id="ssec-pkgs-dockerTools-exportImage">
663+
664+</section>
665+
666+<section xml:id="ssec-pkgs-dockerTools-exportImage">
624667 <title>exportImage</title>
625668
626669 <para>
627− This function is analogous to the <command>docker export</command> command,
628− in that can used to flatten a Docker image that contains multiple layers.
629− It is in fact the result of the merge of all the layers of the image.
630− As such, the result is suitable for being imported in Docker
631− with <command>docker import</command>.
670+ This function is analogous to the <command>docker export</command> command,
671+ in that can used to flatten a Docker image that contains multiple layers.
672+ It is in fact the result of the merge of all the layers of the image.
673+ As such, the result is suitable for being imported in Docker
674+ with <command>docker import</command>.
632675 </para>
633676
634677 <note>
635− <para>
678+ <para>
636679 Using this function requires the <literal>kvm</literal>
637680 device to be available.
638− </para>
681+ </para>
639682 </note>
640683
641684 <para>
642− The parameters of <varname>exportImage</varname> are the following:
685+ The parameters of <varname>exportImage</varname> are the following:
643686 </para>
644687
645688 <example xml:id='ex-dockerTools-exportImage'><title>Docker export</title>
@@ -648,35 +691,35 @@ c = lib.makeOverridable f { a = 1; b = 2; }</programlisting>
648691 fromImage = someLayeredImage;
649692 fromImageName = null;
650693 fromImageTag = null;
651−
694+
652695 name = someLayeredImage.name;
653696 }
654697 </programlisting>
655698 </example>
656699
657700 <para>
658− The parameters relative to the base image have the same synopsis as
659− described in <xref linkend='ssec-pkgs-dockerTools-buildImage'/>, except that
660− <varname>fromImage</varname> is the only required argument in this case.
701+ The parameters relative to the base image have the same synopsis as
702+ described in <xref linkend='ssec-pkgs-dockerTools-buildImage'/>, except that
703+ <varname>fromImage</varname> is the only required argument in this case.
661704 </para>
662705
663706 <para>
664− The <varname>name</varname> argument is the name of the derivation output,
665− which defaults to <varname>fromImage.name</varname>.
707+ The <varname>name</varname> argument is the name of the derivation output,
708+ which defaults to <varname>fromImage.name</varname>.
666709 </para>
667− </section>
710+</section>
668711
669− <section xml:id="ssec-pkgs-dockerTools-shadowSetup">
712+<section xml:id="ssec-pkgs-dockerTools-shadowSetup">
670713 <title>shadowSetup</title>
671714
672715 <para>
673− This constant string is a helper for setting up the base files for managing
674− users and groups, only if such files don't exist already.
675− It is suitable for being used in a
676− <varname>runAsRoot</varname> <xref linkend='ex-dockerTools-buildImage-runAsRoot'/> script for cases like
677− in the example below:
716+ This constant string is a helper for setting up the base files for managing
717+ users and groups, only if such files don't exist already.
718+ It is suitable for being used in a
719+ <varname>runAsRoot</varname> <xref linkend='ex-dockerTools-buildImage-runAsRoot'/> script for cases like
720+ in the example below:
678721 </para>
679−
722+
680723 <example xml:id='ex-dockerTools-shadowSetup'><title>Shadow base files</title>
681724 <programlisting>
682725 buildImage {
@@ -695,13 +738,13 @@ c = lib.makeOverridable f { a = 1; b = 2; }</programlisting>
695738 </example>
696739
697740 <para>
698− Creating base files like <literal>/etc/passwd</literal> or
699− <literal>/etc/login.defs</literal> are necessary for shadow-utils to
700− manipulate users and groups.
741+ Creating base files like <literal>/etc/passwd</literal> or
742+ <literal>/etc/login.defs</literal> are necessary for shadow-utils to
743+ manipulate users and groups.
701744 </para>
702−
703− </section>
704−
745+
746+</section>
747+
705748</section>
706749
707750</chapter>