Update overlay documentation by following nits from aneeshusa.

This commit is contained in:
Nicolas B. Pierron 2017-01-15 15:07:29 +00:00 committed by Nicolas B. Pierron
parent ae7e893de1
commit 2d6532b330
3 changed files with 42 additions and 42 deletions

View File

@ -4,56 +4,53 @@
<title>Overlays</title> <title>Overlays</title>
<para>This chapter describes how to extend and change Nixpkgs content using <para>This chapter describes how to extend and change Nixpkgs packages using
overlays. Overlays are used to add layers in the fix-point used by Nixpkgs overlays. Overlays are used to add layers in the fix-point used by Nixpkgs
to bind the dependencies of all packages.</para> to compose the set of all packages.</para>
<!--============================================================--> <!--============================================================-->
<section xml:id="sec-overlays-install"> <section xml:id="sec-overlays-install">
<title>Installing Overlays</title> <title>Installing Overlays</title>
<para>The set of overlays are looked for in the following order, only the <para>The set of overlays is looked for in the following places. The
first one present is considered, and all the rest are ignored: first one present is considered, and all the rest are ignored:
<orderedlist> <orderedlist>
<listitem> <listitem>
<para>As argument of the imported attribute set. When importing Nixpkgs, <para>As an argument of the imported attribute set. When importing Nixpkgs,
the <varname>overlays</varname> attribute argument can be set to a list of the <varname>overlays</varname> attribute argument can be set to a list of
functions, which would be describe in <xref linkend="sec-overlays-layout"/>.</para> functions, which is described in <xref linkend="sec-overlays-layout"/>.</para>
</listitem> </listitem>
<listitem> <listitem>
<para>As a directory pointed by the environment variable named <para>In the directory pointed by the environment variable
<varname>NIXPKGS_OVERLAYS</varname>. This directory can contain symbolic <varname>NIXPKGS_OVERLAYS</varname>.
links to Nix expressions.
</listitem> </listitem>
<listitem> <listitem>
<para>As the directory located at <para>In the directory <filename>~/.nixpkgs/overlays/</filename>.
<filename>~/.nixpkgs/overlays/</filename>. This directory can contain
symbolic links to Nix expressions.
</listitem> </listitem>
</orderedlist> </orderedlist>
</para> </para>
<para>For the second and third option, the directory contains either <para>For the second and third option, the directory should contain Nix expressions defining the
directories providing a default.nix expression, or files, or symbolic links overlays. Each overlay can be a file, a directory containing a
to the entry Nix expression of the overlay. These Nix expressions are <filename>default.nix</filename>, or a symlink to one of those. The expressions should follow
following the syntax described in <xref the syntax described in <xref linkend="sec-overlays-layout"/>.</para>
linkend="sec-overlays-layout"/>.</para>
<para>To install an overlay, using the last option. Clone the repository of <para>The order of the overlay layers can influence the recipe of packages if multiple layers override
the overlay, and add a symbolic link to it in the the same recipe. In the case where overlays are loaded from a directory, these are loaded in
<filename>~/.nixpkgs/overlays/</filename> directory.</para> alphabetical order.</para>
<para>To install an overlay using the last option, you can clone the overlay's repository and add
a symbolic link to in the <filename>~/.nixpkgs/overlays/</filename> directory.</para>
</section> </section>
@ -62,37 +59,40 @@ the overlay, and add a symbolic link to it in the
<section xml:id="sec-overlays-layout"> <section xml:id="sec-overlays-layout">
<title>Overlays Layout</title> <title>Overlays Layout</title>
<para>An overlay is a Nix expression, which is a function which accepts 2 <para>Overlays are expressed as Nix functions which accept 2 arguments and return a set of
arguments.</para> packages</para>
<programlisting> <programlisting>
self: super: self: super:
{ {
foo = super.foo.override { ... }; boost = super.boost.override {
bar = import ./pkgs/bar { python = self.python3;
inherit (self) stdenv fetchurl; };
inherit (self) ninja crawl dwarf-fortress; rr = super.callPackage ./pkgs/rr {
stdenv = self.stdenv_32bit;
}; };
} }
</programlisting> </programlisting>
<para>The first argument, usualy named <varname>self</varname>, corresponds <para>The first argument, usually named <varname>self</varname>, corresponds to the final package
to the final package set. You should use this set to inherit all the set. You should use this set for the dependencies of all packages specified in your
dependencies needed by your package expression.</para> overlay. For example, all the dependencies of <varname>rr</varname> in the example above come
from <varname>self</varname>, as well as the overriden dependencies used in the
<varname>boost</varname> override.</para>
<para>The second argument, usualy named <varname>super</varname>, <para>The second argument, usually named <varname>super</varname>,
corresponds to the result of the evaluation of the previous stages of corresponds to the result of the evaluation of the previous stages of
Nixpkgs, it does not contain any of the packages added by the current Nixpkgs. It does not contain any of the packages added by the current
overlay nor any of the following overlays. This set is used in to override overlay nor any of the following overlays. This set should be used either
existing packages, either by changing their dependencies or their to refer to packages you wish to override, or to access functions defined
recipes.</para> in Nixpkgs. For example, the original recipe of <varname>boost</varname>
in the above example, comes from <varname>super</varname>, as well as the
<varname>callPackage</varname> function.</para>
<para>The value returned by this function should be a set similar to <para>The value returned by this function should be a set similar to
<filename>pkgs/top-level/all-packages.nix</filename>, which contains either <filename>pkgs/top-level/all-packages.nix</filename>, which contains
extra packages defined by the overlay, or which overwrite Nixpkgs packages overridden and/or new packages.</para>
with other custom defaults. This is similar to <xref
linkend="sec-modify-via-packageOverrides"/>.</para>
</section> </section>

View File

@ -113,7 +113,7 @@ following incompatible changes:</para>
pkgs.overridePackages (self: super: ...) pkgs.overridePackages (self: super: ...)
</programlisting> </programlisting>
Should be replaced by: should be replaced by:
<programlisting> <programlisting>
let let

View File

@ -69,7 +69,7 @@ in
openssh = super.openssh.override { openssh = super.openssh.override {
hpnSupport = true; hpnSupport = true;
withKerberos = true; withKerberos = true;
kerberos = self.libkrb5 kerberos = self.libkrb5;
}; };
}; };
) ] ) ]