Overlays
This chapter describes how to extend and change Nixpkgs content using
overlays. Overlays are used to add phases in the fix-point used by Nixpkgs
to bind the dependencies of all packages.
Installing Overlays
Overlays are looked for in the following order, the first valid one is
considered, and all the rest are ignored:
As argument of the imported attribute set. When importing Nixpkgs,
the overlays attribute argument can be set to a list of
functions, which would be describe in .
As a directory pointed by the environment variable named
NIXPKGS_OVERLAYS. This directory can contain symbolic
links to Nix expressions.
As the directory located at
~/.nixpkgs/overlays/. This directory can contain
symbolic links to Nix expressions.
For the second and third option, the directory contains either
directories providing a default.nix expression, or files, or symbolic links
to the entry Nix expression of the overlay. These Nix expressions are
following the syntax described in .
To install an overlay, using the last option. Clone the repository of
the overlay, and add a symbolic link to it in the
~/.nixpkgs/overlays/ directory.
Overlays Layout
An overlay is a Nix expression, which is a function which accepts 2
arguments.
self: super:
{
foo = super.foo.override { ... };
bar = import ./pkgs/bar {
inherit (self) stdenv fetchurl;
inherit (self) ninja crawl dwarf-fortress;
};
}
The first argument, usualy named self, corresponds
to the final package set. You should use this set to inherit all the
dependencies needed by your package expression.
The second argument, usualy named super,
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
overlay nor any of the following overlays. This set is used in to override
existing packages, either by changing their dependencies or their
recipes.
The value returned by this function should be a set similar to
pkgs/top-level/all-packages.nix, which contains either
extra packages defined by the overlay, or which overwrite Nixpkgs packages
with other custom defaults. This is similar to .