{
  pkgs,
  lib,
  cfg,
  flakes,
  ...
}: let
  registryName = name:
    if name == "self"
    then cfg.renameSelf
    else name;

  registryFilter = {
    nixpkgs = true;
    unstable = true;
    self = cfg.renameSelf != null;
  };
in {
  nix.registry =
    lib.mapAttrs'
    (name: value: lib.nameValuePair (registryName name) {flake = value;})
    (lib.filterAttrs (name: _: registryFilter.${name} or cfg.allInputs) flakes);
}
