# nix-index-database: a prebuilt nix-locate index you subscribe to instead of building

> nix-index-database ships a weekly nixos-unstable index for nix-locate, plus NixOS, nix-darwin and home-manager modules that wire the database into your shell. The trade-off is that the index tracks one channel and one architecture per file.

**nix-community/nix-index-database** — Weekly updated nix-index database [maintainer=@Mic92]

- Repository: https://github.com/nix-community/nix-index-database
- Stars: 618 · Forks: 50
- Language: Nix
- License: MIT
- Published: 2026-08-23 · Updated: 2026-08-23 · Language: en
- Canonical page: https://hysenlabs.com/projects/nix-community-nix-index-database

## The problem: nix-locate is empty until you index your own machine

nix-index builds a map from file paths to the store paths that provide them, and nix-locate queries that map. The map is not shipped with nixpkgs. You generate it locally by indexing a channel, which means downloading and scanning a large set of store paths before the first useful query. On a fresh machine that is a long wait for a feature you might use once a week.

nix-index-database removes that step by publishing the result. The repository describes itself as a "weekly updated nix-index database for nixos-unstable channel", and it packages the database together with a nix-index wrapper so that nix-locate reads the published files instead of a locally generated index. The audience is narrow and specific: people on nixos-unstable who want command-not-found style lookups and nix-locate answers immediately after a rebuild, and who are willing to accept a snapshot that is at most about a week old.

The demo in the README is the whole pitch in one line: running nix run github:nix-community/nix-index-database bin/cntr prints the store path and binary that provide cntr, without any local indexing step.

## Two database variants and what the small one gives up

The repository publishes two variants. The full database, packaged as nix-index-with-db, contains every indexed file, including headers and libraries. The small database, packaged as nix-index-with-small-db, contains only files under /bin/ directories. The README states the small variant is much smaller, downloads faster and consumes less memory.

That is a real trade-off, not a free win. If your question is "which package provides this shared library or this header", the small database cannot answer it, because those paths were filtered out. If your question is "which package provides this executable", the small database is the better default: less to download on every update and less resident memory when nix-locate runs. The README also notes the small variant is used for comma, which makes sense because comma resolves commands, not libraries.

Switching variants is an override of the package, not a separate module option:

## Installing the module in NixOS and running nix-locate

The NixOS path is a flake input plus one module import. The README gives this shape, with the input following your nixpkgs so the wrapper and your system agree on the package set:

```nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";

    nix-index-database.url = "github:nix-community/nix-index-database";
    nix-index-database.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = { self, nixpkgs, nix-index-database, ... }: {
    nixosConfigurations = {
      my-nixos = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          ./configuration.nix
          nix-index-database.nixosModules.default
        ];
      };
    };
  };
}
```

After that, the README says you can call nix-locate as usual and it will automatically use the database from this repository. The important constraint is stated in a warning in the same section: do not also add nix-index to environment.systemPackages, because it will conflict with the wrapper this project installs. The same warning appears for the home-manager module and home.packages.

For a quick check before touching your configuration, the README's own demo runs the flake directly:

```bash
nix run github:nix-community/nix-index-database bin/cntr
```

You should see a line naming the cntr store path and its /bin/cntr file. If that works, the database is reachable and the wrapper logic is sound on your machine.

## Ad-hoc download without any Nix module

You do not have to adopt a module. The README includes a shell function that fetches the release asset matching your machine and drops it into the cache directory nix-index reads. The filename is derived from uname, with arm64 rewritten to aarch64, and the download comes from the releases/latest/download path:

```bash
download_nixpkgs_cache_index () {
  filename="index-$(uname -m | sed 's/^arm64$/aarch64/')-$(uname | tr A-Z a-z)"
  mkdir -p ~/.cache/nix-index && cd ~/.cache/nix-index
  wget -q -N https://github.com/nix-community/nix-index-database/releases/latest/download/$filename
  ln -f $filename files
}

download_nixpkgs_cache_index
```

The ln -f is the part that matters: nix-index looks for a file literally named files, and the function hard-links the versioned download to that name. Re-running the function refreshes the link to the newest asset. This route suits people who do not want a flake input, or who want to refresh the index on a schedule outside Nix.

## Nix 2.18 is a floor, not a suggestion

The README's requirements section is one line long and easy to skip: Nix 2.18 or newer, because the packages use unsafeDiscardReferences to skip nix store checks, and on older Nix versions these packages might fail. That is the most likely first failure mode. If your Nix predates 2.18, the module may evaluate or build incorrectly rather than producing a clear error about the version.

The second failure mode is channel drift. The database is built for nixos-unstable. If you track a stable release, or pin nixpkgs to a commit from months ago, nix-locate will answer against a package set that is not yours. Queries for recently added packages will miss, and store paths in the output may not exist on your machine. The index is a snapshot of someone else's channel, and it says so.

The third is the conflict the README warns about twice: adding nix-index alongside the module. The wrapper and the plain package both want to provide the same commands, and the documentation does not describe a merge.

## When to build your own index instead

The obvious alternative is nix-index itself, the upstream project this database is generated from. The difference is who pays for the indexing. nix-index builds a database from your own channel and your own store, so it matches your pinned nixpkgs exactly, including packages that are not in nixos-unstable and any local overlays that change what gets built. nix-index-database trades that accuracy for time: no indexing run, no local scan, just a download. If you run a stable channel, use overlays heavily, or need lookups for packages that never reach nixos-unstable, the upstream tool is the correct choice and this repository is the wrong one.

A second alternative for command lookup specifically is comma, which runs a command from nixpkgs without installing it. comma answers "run this", while nix-locate answers "which package contains this file". They overlap in feel but not in function, and the README treats comma as an optional companion: the NixOS module accepts programs.nix-index-database.comma.enable, and the repository ships comma-wrapper.nix for that purpose. Enabling comma through the module is a convenience, not a substitute for the database.

## Licence, update cadence and what maintenance actually costs you

The repository is MIT licensed, which is permissive and imposes no conditions on how you use the modules or the published database in your own configuration. The database files themselves are generated from nixpkgs contents; the repository does not discuss any separate terms for the generated artifacts, so if you plan to redistribute them inside a product, that is a question for your own review rather than something the README answers.

Upgrade cost is close to zero by design. There are no migrations, no schema you manage, and no service to keep running. You bump the flake input, or re-run the ad-hoc download function, and you get the newest weekly snapshot. The last push was on 2026-08-23, and the releases listed in the repository run weekly, with 2026-08-23-033710, 2026-08-16-033510 and 2026-08-09-040451 as the most recent tags. The cadence is the dependency: if the weekly job stops, your nix-locate answers keep working but slowly describe an older nixpkgs. Nothing in your configuration will tell you that happened, because the module has no staleness check.

## Conclusion

Adopt nix-index-database if you run nixos-unstable (or a close follower) and want nix-locate answers without building an index on your own machine. Skip it if you track a stable release, pin an old nixpkgs, or need a database for a channel this repository does not publish. Before enabling the module, confirm your Nix is 2.18 or newer, remove nix-index from environment.systemPackages or home.packages, and check that a release asset exists for your machine's architecture.

## FAQ

### Is NixOS better than Ubuntu?

The README does not compare NixOS with other distributions. It only describes this repository as a weekly updated nix-index database for the nixos-unstable channel, with modules for NixOS, nix-darwin and home-manager.

### Which companies use Nix?

The README names no companies. The repository lives in the nix-community organisation, and the project description credits a maintainer.

### Can I run Nix on Windows?

The README does not mention Windows. It documents usage in NixOS, nix-darwin and home-manager, and the ad-hoc download script derives its filename from uname, which is not a Windows command.

### What is Nix used for?

The README only shows one use: querying which package provides a file, via nix-locate and the database published here, plus an optional comma wrapper for running commands. It does not describe Nix itself in general terms.

## Sources

- [Official README](https://github.com/nix-community/nix-index-database#readme)
- [Project repository](https://github.com/nix-community/nix-index-database)
- [Release notes](https://github.com/nix-community/nix-index-database/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/nix-community-nix-index-database
