Nix Overlays

Summary

  • a way to extend or modify the functionality of the Nix package manager
  • is a collection of Nix packages that can be used to add or override packages in the Nixpkgs collection
  • useful when you want to add packages that are not available in the Nixpkgs repository, or when you want to use a different version of a package than the one provided in Nixpkgs
  • can also be used to customize the behavior of packages or to add custom packages for your own projects

Example

{ inputs, lib, ... }: {
  nixpkgs.overlays = [
    # channels
    (final: prev: {
      # expose other channels via overlays
      stable = import inputs.nixos-stable { system = prev.system; };
    })
    (final: prev: {
      python3 = prev.python3.override {
        packageOverrides = (pfinal: pprev: {
          pyopenssl = pprev.pyopenssl.overrideAttrs (old: {
            meta = old.meta // { broken = false; };
          });
        });
      };
    })
    (final: prev:
      let
        pkgs = final;
      in
      with pkgs; {
        yabai = final.callPackage ./pkgs/yabai {
          inherit (darwin.apple_sdk_11_0.frameworks) SkyLight Cocoa Carbon ScriptingBridge;
        };

        yabai-zsh-completions = final.callPackage ./pkgs/yabai-zsh-completions { };
      }
    )
  ];
}

Notes mentioning this note

There are no notes linking to this note.