Back to rankings

nix-community/nix-index

Rust

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

nixnixpkgstoolingsearch
Star Growth
Stars
1.3k
Forks
78
Weekly Growth
Issues
73
5001k
Mar 2017Apr 2020Jun 2023Jul 2026
Artifactscrates.iocargo add nix-index
README

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
$ nix-locate 'bin/hello'
hello.out                                        29,488 x /nix/store/bdjyhh70npndlq3rzmggh4f2dzdsj4xy-hello-2.10/bin/hello
linuxPackages_4_4.dpdk.examples               2,022,224 x /nix/store/jlnk3d38zsk0bp02rp9skpqk4vjfijnn-dpdk-16.07.2-4.4.52-examples/bin/helloworld
linuxPackages.dpdk.examples                   2,022,224 x /nix/store/rzx4k0pb58gd1dr9kzwam3vk9r8bfyv1-dpdk-16.07.2-4.9.13-examples/bin/helloworld
linuxPackages_4_10.dpdk.examples              2,022,224 x /nix/store/wya1b0910qidfc9v3i6r9rnbnc9ykkwq-dpdk-16.07.2-4.10.1-examples/bin/helloworld
linuxPackages_grsec_nixos.dpdk.examples       2,022,224 x /nix/store/2wqv94290pa38aclld7sc548a7hnz35k-dpdk-16.07.2-4.9.13-examples/bin/helloworld
camlistore.out                                7,938,952 x /nix/store/xn5ivjdyslxldhm5cb4x0lfz48zf21rl-camlistore-0.9/bin/hello

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:

    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:

  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)
Related repositories
unionlabs/union

The trust-minimized, zero-knowledge bridging protocol, designed for censorship resistance, extremely high security, and usage in decentralized finance.

Rustcrates.ioApache License 2.0blockchaincosmos
union.build
73.9k3.9k
NixOS/nixpkgs

Nix Packages collection & NixOS

NixMIT Licensenixpkgsnix
25.5k19.6k
NixOS/nix

Nix, the purely functional package manager

C++GNU Lesser General Public License v2.1nixfunctional-programming
nixos.org
17.4k2k
jetify-com/devbox

Instant, easy, and predictable development environments

GoGo ModulesApache License 2.0devboxdevelopment-environment
jetify.com/devbox/
12.2k347
nix-community/home-manager

Manage a user environment using Nix [maintainer=@khaneliman, @rycee]

NixMIT Licensenixnixpkgs
nix-community.github.io/home-manager/
10.1k2.4k
xonsh/xonsh

🐚 Python-powered shell. Full-featured, cross-platform and AI-friendly.

PythonPyPIOtherxonshdevops
xon.sh
9.6k730
teslamate-org/teslamate

A self-hosted data logger for your Tesla 🚘 [main maintainer=@JakobLichterfeld]

ElixirGNU Affero General Public License v3.0teslatesla-api
docs.teslamate.org
8.8k991
cachix/devenv

Fast, Declarative, Reproducible, and Composable Developer Environments using Nix

Rustcrates.ioApache License 2.0developer-toolsdevenv
devenv.sh
7.2k525
RubyMetric/chsrc

chsrc 全平台通用换源工具与框架. Change Source everywhere for every software

CGNU General Public License v3.0gemlinux
chsrc.run
6.8k277
nix-darwin/nix-darwin

Manage your macOS using Nix

NixMIT Licensedarwinnix
nix-darwin.org
5.7k649
digitallyinduced/ihp

🔥 The fastest way to build type safe web apps. IHP is a new batteries-included web framework optimized for longterm productivity and programmer happiness

HaskellMIT Licensehaskellpostgresql
ihp.digitallyinduced.com
5.3k223
nix-community/awesome-nix

😎 A curated list of the best resources in the Nix community [maintainer=@cyntheticfox]

Creative Commons Zero v1.0 Universalawesome-listawesome
nix-community.github.io/awesome-nix/
5.3k203