Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
N

nix-index

> 编程语言
Open source

Quickly locate nix packages with specific files [maintainers=@bennofs @figsoda @raitobezarius]

1.3K stars0 likes0 views
WebsiteGitHub

About

Quickly locate nix packages with specific files [maintainers=@bennofs @figsoda @raitobezarius]

nix-index

A files database for nixpkgs

nix-index is a tool to quickly locate the package providing a certain file in nixpkgs. It indexes built derivations found in binary caches.

Demo
…

Installation

Flakes

  1. create the database:

    $ nix run github:nix-community/nix-index#nix-index
  2. query for a file:

    $ nix run github:nix-community/nix-index#nix-locate -- bin/hello

Latest Git version

To install the latest development version of nix-index, simply clone the repo and run nix-env -if.:

$ git clone https://github.com/nix-community/nix-index
$ cd nix-index
$ nix-env -if.

Stable

For the stable version, you can either checkout the latest tag (see the list here) or use Nixpkgs' repositories' and install it with:

$ nix-env -iA nixos.nix-index

Usage

First, you need to generate an index by running nix-index (it takes around 5 minutes) . Then, you can use nix-locate pattern. For more information, see nix-locate --help and nix-index --help.

Use pre-generated database

nix-index-database provides pre-generated databases if you don't want to generate a database locally. It also comes with nixos/home-manager modules to use those databases.

Usage as a command-not-found replacement

Nix-index provides a "command-not-found" script that can print for you the attribute path of unfound commands in your shell. You can either source ${pkgs.nix-index}/etc/command-not-found.sh in your own shell init files (works for ZSH and Bash for as far as we know) or you can use the following in home-manager / /etc/nixos/configuration.nix:

nix
    programs.command-not-found.enable = false;
    # for home-manager, use programs.bash.initExtra instead
    programs.bash.interactiveShellInit = ''
      source ${pkgs.nix-index}/etc/profile.d/command-not-found.sh
    '';

Replace bash with zsh if you use zsh.

Example output:

$ blender
The program 'blender' is currently not installed. You can install it
by typing:
  nix-env -iA nixpkgs.blender.out

Or run it once with:
  nix-shell -p blender.out --run ...

A home-manager module is now available to integrate nix-index with bash, zsh, and fish using this script.

You can also use command-not-found.nu as a Nushell hook by adding the following to your Nushell config:

nix
  programs.nushell = {
    enable = true;
    extraConfig = ''
      $env.config.hooks.command_not_found = source ${pkgs.nix-index}/etc/profile.d/command-not-found.nu
    '';
  };

Contributing

If you find any missing features that you would like to implement, I'm very happy about any PRs! You can also create an issue first if the feature is more complex so we can discuss possible implementations.

Here is a quick description of all relevant files:

  • bin/{nix-index, nix-locate}.rs: Implementation of the nix-index / nix-locate command line tools
  • src/database.rs: High-level functions for working with the database format
  • src/files.rs: The data types for working with file listings
  • src/frcode.rs: Low-level implementation of an encoder to efficiently store many file paths (see comments in the file for more details). Used by database.rs.
  • src/hydra.rs: Deals with everything that has to do with downloading from the binary cache (fetching file listings and references)
  • src/nixpkgs.rs: Implements the gathering of the packages (store paths and attributes) using nix-env
  • src/package.rs: High-level data types for representing store paths (sometimes also refered to as a package)
  • src/workset.rs: A queue used by nix-index to implement the recursive fetching (fetching references of everything)

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rustnixnixpkgssearchtooling

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言