1.8 KiB
Overlays are a feature of Nixpkgs that allow you to:
- Add new packages with new names to the namespace without modifying upstream
- For example, if there is a package
foobar, you might addfoobar-1_2_3to add a specific version for backwards compatibility
- For example, if there is a package
- Globally override existing package names, in terms of other packages.
- For example, if you want to globally override a package to enable a disabled-by-default feature.
First, you need to define a file for the overlay under
overlays/, and then import it in flake.nix. There is an
example pull request in
#14 for this; an overlay
typically looks like this:
final: prev: {
gdal = prev.gdalMinimal;
}
This says "globally override gdal with a different version, named
gdalMinimal". In this case gdalMinimal is a build with less features
enabled.
The most important part is that there is an equation of the form lhs = rhs;
— if the lhs refers to an existing name, it's overwritten. If it refers
to a new name, it's introduced. Overwriting an existing name acts as if you
changed the files upstream: so the above example globally overrides GDAL for
anything that depends on it.
The names final and prev are used to refer to packages in terms of other
overlays. For more information about this, see the
NixOS Wiki Page for Overlays.
We also use an overlay to override the default build recipe for postgresql_16, and instead feed it the specially patched postgres for use with orioledb extension. This experimental variant can be built with nix build .#psql_orioledb_16/bin. This will build this patched version of postgres, along with all extensions and wrappers that currently are known to work with orioledb.