{ pkgs, ... }: {
  programs.nix-index = {
    enable = true;
    enableBashIntegration = true;
    enableZshIntegration = true;
  };

  systemd.user = {
    services."nix-index" = {
      Unit = {
        Description = "Update the nix-locate database";
        After = [ "network.target" ];
      };
      Service = {
        Type = "oneshot";
        ExecStart = "${pkgs.nix-index}/bin/nix-index";
      };
    };

    timers."nix-index" = {
      Unit.Description = "Daily update the nix-locate database";
      Timer = {
        OnCalendar = "daily";
        Persistent = true;
        Unit = "nix-index.service";
      };
      Install.WantedBy = [ "timers.target" ];
    };
  };
}
