A list of files containing Nix expressions that can be used to add default bindings to nix repl sessions.

Each file is called with three arguments:

  1. An attribute set containing at least a currentSystem attribute (this is identical to builtins.currentSystem, except that it's available in pure-eval mode).
  2. The final top-level bindings produced by calling all repl-overlays.
  3. The top-level bindings produced by the previous repl-overlays value (or the default top-level bindings).

For example, the following file would alias pkgs to legacyPackages.${info.currentSystem} (if that attribute is defined):

info: final: prev:
if prev ? legacyPackages
   && prev.legacyPackages ? ${info.currentSystem}
then
{
  pkgs = prev.legacyPackages.${info.currentSystem};
}
else
{ }

Here's a more elaborate repl-overlay, which provides the following variables:

For example, the following attribute set:

info: final: attrs: let
  # Equivalent to nixpkgs `lib.optionalAttrs`.
  optionalAttrs = predicate: attrs:
    if predicate
    then attrs
    else {};

  # If `attrs.${oldName}.${info.currentSystem}` exists, alias `${newName}` to
  # it.
  collapseRenamed = oldName: newName:
    optionalAttrs (builtins.hasAttr oldName attrs
      && builtins.hasAttr info.currentSystem attrs.${oldName})
    {
      ${newName} = attrs.${oldName}.${info.currentSystem};
    };

  # Alias `attrs.${oldName}.${info.currentSystem} to `${newName}`.
  collapse = name: collapseRenamed name name;

  # Alias all `attrs` keys with an `${info.currentSystem}` attribute.
  collapseAll =
    builtins.foldl'
    (prev: name: prev // collapse name)
    {}
    (builtins.attrNames attrs);
in
  # Preserve the original bindings as `original`.
  (optionalAttrs (! attrs ? original)
    {
      original = attrs;
    })
  // (collapseRenamed "packages" "pkgs")
  // (collapseRenamed "legacyPackages" "pkgs")
  // collapseAll