Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit 30e399b

Browse files
committed
docs: nix overlays
Signed-off-by: Austin Seipp <aseipp@pobox.com> Change-Id: Id3dadebc0870e3c2768a4fb63f218a22
1 parent 56152fb commit 30e399b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

docs/nix-overlays.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Overlays are a feature of Nixpkgs that allow you to:
2+
3+
- Add new packages with new names to the namespace _without_ modifying upstream
4+
- For example, if there is a package `foobar`, you might add `foobar-1_2_3` to
5+
add a specific version for backwards compatibility
6+
- Globally override _existing_ package names, in terms of other packages.
7+
- For example, if you want to globally override a package to enable a
8+
disabled-by-default feature.
9+
10+
First, you need to define a file for the overlay under
11+
[overlays/](../overlays/), and then import it in `flake.nix`. There is an
12+
example pull request in
13+
[#14](https://github.com/supabase/nix-postgres/issues/14) for this; an overlay
14+
typically looks like this:
15+
16+
```
17+
final: prev: {
18+
gdal = prev.gdalMinimal;
19+
}
20+
```
21+
22+
This says "globally override `gdal` with a different version, named
23+
`gdalMinimal`". In this case `gdalMinimal` is a build with less features
24+
enabled.
25+
26+
The most important part is that there is an equation of the form `lhs = rhs;`
27+
&mdash; if the `lhs` refers to an existing name, it's overwritten. If it refers
28+
to a new name, it's introduced. Overwriting an existing name acts as if you
29+
changed the files upstream: so the above example _globally_ overrides GDAL for
30+
anything that depends on it.
31+
32+
The names `final` and `prev` are used to refer to packages in terms of other
33+
overlays. For more information about this, see the
34+
[NixOS Wiki Page for Overlays](https://nixos.wiki/wiki/Overlays).

0 commit comments

Comments
 (0)