2016-12-17 11:05:21 -07:00
|
|
|
<chapter xmlns="http://docbook.org/ns/docbook"
|
|
|
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
|
|
xml:id="chap-overlays">
|
|
|
|
|
|
|
|
<title>Overlays</title>
|
|
|
|
|
2017-01-15 08:07:29 -07:00
|
|
|
<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
|
|
|
|
to compose the set of all packages.</para>
|
2016-12-17 11:05:21 -07:00
|
|
|
|
|
|
|
<!--============================================================-->
|
|
|
|
|
|
|
|
<section xml:id="sec-overlays-install">
|
|
|
|
<title>Installing Overlays</title>
|
|
|
|
|
2017-01-15 08:07:29 -07:00
|
|
|
<para>The set of overlays is looked for in the following places. The
|
2016-12-26 12:26:24 -07:00
|
|
|
first one present is considered, and all the rest are ignored:
|
2016-12-17 11:05:21 -07:00
|
|
|
|
|
|
|
<orderedlist>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
|
2017-01-15 08:07:29 -07:00
|
|
|
<para>As an argument of the imported attribute set. When importing Nixpkgs,
|
2016-12-17 11:05:21 -07:00
|
|
|
the <varname>overlays</varname> attribute argument can be set to a list of
|
2017-01-15 08:07:29 -07:00
|
|
|
functions, which is described in <xref linkend="sec-overlays-layout"/>.</para>
|
2016-12-17 11:05:21 -07:00
|
|
|
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
|
2017-02-01 07:56:02 -07:00
|
|
|
<para>In the directory pointed to by the Nix search path entry
|
|
|
|
<literal><nixpkgs-overlays></literal>.</para>
|
2016-12-17 11:05:21 -07:00
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
|
2017-04-02 02:11:01 -06:00
|
|
|
<para>In the directory <filename>~/.config/nixpkgs/overlays/</filename>.</para>
|
2016-12-17 11:05:21 -07:00
|
|
|
</listitem>
|
|
|
|
|
|
|
|
</orderedlist>
|
|
|
|
</para>
|
|
|
|
|
2017-01-15 11:58:26 -07:00
|
|
|
<para>For the second and third options, the directory should contain Nix expressions defining the
|
2017-01-15 08:07:29 -07:00
|
|
|
overlays. Each overlay can be a file, a directory containing a
|
|
|
|
<filename>default.nix</filename>, or a symlink to one of those. The expressions should follow
|
|
|
|
the syntax described in <xref linkend="sec-overlays-layout"/>.</para>
|
2016-12-17 11:05:21 -07:00
|
|
|
|
2017-01-15 08:07:29 -07:00
|
|
|
<para>The order of the overlay layers can influence the recipe of packages if multiple layers override
|
2017-01-15 11:58:26 -07:00
|
|
|
the same recipe. In the case where overlays are loaded from a directory, they are loaded in
|
2017-01-15 08:07:29 -07:00
|
|
|
alphabetical order.</para>
|
|
|
|
|
|
|
|
<para>To install an overlay using the last option, you can clone the overlay's repository and add
|
2017-04-02 02:11:01 -06:00
|
|
|
a symbolic link to it in <filename>~/.config/nixpkgs/overlays/</filename> directory.</para>
|
2016-12-17 11:05:21 -07:00
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<!--============================================================-->
|
|
|
|
|
|
|
|
<section xml:id="sec-overlays-layout">
|
|
|
|
<title>Overlays Layout</title>
|
|
|
|
|
2017-01-15 08:07:29 -07:00
|
|
|
<para>Overlays are expressed as Nix functions which accept 2 arguments and return a set of
|
2017-01-15 11:58:26 -07:00
|
|
|
packages.</para>
|
2016-12-17 11:05:21 -07:00
|
|
|
|
|
|
|
<programlisting>
|
|
|
|
self: super:
|
|
|
|
|
|
|
|
{
|
2017-01-15 08:07:29 -07:00
|
|
|
boost = super.boost.override {
|
|
|
|
python = self.python3;
|
|
|
|
};
|
|
|
|
rr = super.callPackage ./pkgs/rr {
|
|
|
|
stdenv = self.stdenv_32bit;
|
2016-12-17 11:05:21 -07:00
|
|
|
};
|
|
|
|
}
|
|
|
|
</programlisting>
|
|
|
|
|
2017-01-15 08:07:29 -07:00
|
|
|
<para>The first argument, usually named <varname>self</varname>, corresponds to the final package
|
|
|
|
set. You should use this set for the dependencies of all packages specified in your
|
|
|
|
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>
|
2016-12-17 11:05:21 -07:00
|
|
|
|
2017-01-15 08:07:29 -07:00
|
|
|
<para>The second argument, usually named <varname>super</varname>,
|
2016-12-17 11:05:21 -07:00
|
|
|
corresponds to the result of the evaluation of the previous stages of
|
2017-01-15 08:07:29 -07:00
|
|
|
Nixpkgs. It does not contain any of the packages added by the current
|
|
|
|
overlay nor any of the following overlays. This set should be used either
|
|
|
|
to refer to packages you wish to override, or to access functions defined
|
|
|
|
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>
|
2016-12-17 11:05:21 -07:00
|
|
|
|
|
|
|
<para>The value returned by this function should be a set similar to
|
2017-01-15 08:07:29 -07:00
|
|
|
<filename>pkgs/top-level/all-packages.nix</filename>, which contains
|
|
|
|
overridden and/or new packages.</para>
|
2016-12-17 11:05:21 -07:00
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
</chapter>
|