nix.dev icon indicating copy to clipboard operation
nix.dev copied to clipboard

Add: Overlays concept / tutorial - introduction to overlays

Open hsjobeki opened this issue 1 year ago • 3 comments

Learning goals

  • Understand overlays concept

  • What is the problem

  • How do overlays solve it

  • How to use them -> override pkgs within the fixed point

Prerequisites

  • Understand a package set
  • Understand a fixed point

Outline

Prior art

  • https://discourse.nixos.org/t/what-are-overlays/14680
  • https://wiki.nixos.org/wiki/Overlays
  • https://nixcademy.com/posts/mastering-nixpkgs-overlays-techniques-and-best-practice/

Willing to help?

Yes

Priorities

Add :+1: to issues you find important.

hsjobeki avatar Dec 01 '25 09:12 hsjobeki

Did the overlays section ever get added to nix.dev?

Could we include an updated version of this explanation: https://blog.layus.be/posts/2020-06-12-nix-overlays.html

66-firebat avatar Mar 22 '26 21:03 66-firebat

Yes, I'd be happy to review any contributions.

If you want to do it:

Structure for explaining overlays could be:

  • Introduce terminology (prerequisites, keep it simple, write last)
  • Start with a simple example
  • Explain what it does
  • Give a more complex example
  • Explain what it does

Avoid:

Upfront explanations, without examples: (order: example -> explanation)

  • Bad: Overlays provide a method to extend and change nixpkgs. They replace constructs like packageOverride and overridePackages ... (copied from discourse)
  • Better (show examples, maybe not the best one from the wiki):
Consider this simple example
final: prev: {
   google-chrome = prev.google-chrome.override {
     commandLineArgs =
       "--proxy-server='https=127.0.0.1:3128;http=127.0.0.1:3128'";
   };
};
It sets the default proxy in Google Chrome

It seems counter-intuitive, but show the code first. Understanding builds gradually from that examples later.

hsjobeki avatar Mar 23 '26 09:03 hsjobeki

Thanks @hsjobeki , will try to get to it this weekend! I also noticed that devshells were not included in the wiki, so maybe I can have a look at that as well. I really like this style of example-accompanied descriptions, and I look forward to contributing!

66-firebat avatar Mar 25 '26 05:03 66-firebat