@@ -17,42 +17,68 @@ if multiple layers override the same package.</para>
1717<section xml:id="sec-overlays-install">
1818<title>Installing overlays</title>
1919
20−<para>The list of overlays is determined as follows:
20+<para>The list of overlays is determined as follows.</para>
21+
22+<para>If the <varname>overlays</varname> argument is not provided explicitly, we look for overlays in a path. The path
23+is determined as follows:
2124
2225<orderedlist>
2326
2427 <listitem>
2528 <para>First, if an <varname>overlays</varname> argument to the nixpkgs function itself is given,
26− then that is used. This can be passed explicitly when importing nipxkgs, for example
27− <literal>import <nixpkgs> { overlays = [ overlay1 overlay2 ] }</literal>.</para>
29+ then that is used.</para>
2830
29− <para>On a NixOS system the value of the <literal>nixpkgs.overlays</literal> option, if present,
30− is passed to the system Nixpkgs in this way. Note that this does not affect the overlays for
31− non-NixOS operations (e.g. <literal>nix-env</literal>), which are looked up independently.</para>
31+ <para>This can be passed explicitly when importing nipxkgs, for example
32+ <literal>import <nixpkgs> { overlays = [ overlay1 overlay2 ]; }</literal>.</para>
3233 </listitem>
3334
3435 <listitem>
35− <para>Otherwise, if the Nix path entry <literal><nixpkgs-overlays></literal> exists and is a
36− directory, then the result is the set of overlays found in that directory, ordered lexicographically.</para>
36+ <para>Otherwise, if the Nix path entry <literal><nixpkgs-overlays></literal> exists, we look for overlays
37+ at that path, as described below.</para>
3738
3839 <para>See the section on <literal>NIX_PATH</literal> in the Nix manual for more details on how to
3940 set a value for <literal><nixpkgs-overlays>.</literal></para>
4041 </listitem>
4142
4243 <listitem>
43− <para>Otherwise, if <filename>~/.config/nixpkgs/overlays/</filename> exists and is a directory, then
44− the result is the set of overlays found in that directory, ordered lexicographically.</para>
44+ <para>If one of <filename>~/.config/nixpkgs/overlays.nix</filename> and
45+ <filename>~/.config/nixpkgs/overlays/</filename> exists, then we look for overlays at that path, as
46+ described below. It is an error if both exist.</para>
4547 </listitem>
4648
4749</orderedlist>
4850</para>
4951
50−<para>For the second and third options, overlays are extracted from the given directory as files,
51−directories containing a <filename>default.nix</filename>, or symlinks to one of those.</para>
52+<para>If we are looking for overlays at a path, then there are two cases:
53+<itemizedlist>
54+ <listitem>
55+ <para>If the path is a file, then the file is imported as a Nix expression and used as the list of
56+ overlays.</para>
57+ </listitem>
58+
59+ <listitem>
60+ <para>If the path is a directory, then we take the content of the directory, order it
61+ lexicographically, and attempt to interpret each as an overlay by:
62+ <itemizedlist>
63+ <listitem>
64+ <para>Importing the file, if it is a <literal>.nix</literal> file.</para>
65+ </listitem>
66+ <listitem>
67+ <para>Importing a top-level <filename>default.nix</filename> file, if it is a directory.</para>
68+ </listitem>
69+ </itemizedlist>
70+ </para>
71+ </listitem>
72+</itemizedlist>
73+</para>
74+
75+<para>On a NixOS system the value of the <literal>nixpkgs.overlays</literal> option, if present,
76+is passed to the system Nixpkgs directly as an argument. Note that this does not affect the overlays for
77+non-NixOS operations (e.g. <literal>nix-env</literal>), which are looked up independently.</para>
5278
53−<para>The last option provides a convenient way to install an overlay from a repository,
54−by cloning the overlay's repository and adding a symbolic link to it in
55−<filename>~/.config/nixpkgs/overlays/</filename>.</para>
79+<para>The <filename>overlays.nix</filename> option therefore provides a convenient way to use the same
80+overlays for a NixOS system configuration and user configuration: the same file can be used
81+as <filename>overlays.nix</filename> and imported as the value of <literal>nixpkgs.overlays</literal>.</para>
5682
5783</section>
5884