Overlays: Difference between revisions

From NixOS Wiki
imported>Krey
(Created page with "Overlays provide a method to extend and change nixpkgs. They replace constructs like <code>packageOverride</code> and <code>overridePackages</code>. Consider a simple example...")
 
imported>Krey
No edit summary
Line 29: Line 29:
==== On the system level ====
==== On the system level ====


If you want your overlays to be accessible on the system level, by nix tools and also in the system-wide configuration, add <code>nixpkgs-overlays</code> to your <code>NIX_PATH</code>:
If you want your overlays to be accessible by nix tools and also in the system-wide configuration, add <code>nixpkgs-overlays</code> to your <code>NIX_PATH</code>:


<syntaxhighlight lang="shell">
<syntaxhighlight lang="shell">

Revision as of 19:23, 29 April 2018

Overlays provide a method to extend and change nixpkgs. They replace constructs like packageOverride and overridePackages.

Consider a simple example of setting the default proxy in Google Chrome:

let overlay1 = self: super:
{
   google-chrome = super.google-chrome.override {
     commandLineArgs =
       "--proxy-server='https=127.0.0.1:3128;http=127.0.0.1:3128'";
   };
};

Applying overlays manually

import <nixpkgs> { overlays = [ overlay1 overlay2 ]; }

Applying overlays automatically

On the user level

A list of overlays placed into ~/.config/nixpkgs/overlays.nix will be automatically loaded by all nix tools.

Alternatively, you can put each overlay in its own .nix file under your ~/.config/nixpkgs/overlays directory.

On the system level

If you want your overlays to be accessible by nix tools and also in the system-wide configuration, add nixpkgs-overlays to your NIX_PATH:

NIX_PATH="$NIX_PATH:nixpkgs-overlays=/cfg/overlays"

Currently nixos-rebuild only works with a <nixpkgs-overlays> path that is a directory.

External Documentation