Starting in a new topic, since it was getting off-topic
From what I can tell:
command-not-found is a nixos feature which allows you to type a command name, like lscpu, and if you don’t have that command available in your current system profile/generation, it will tell you what available NixOS packages contain an executable of the same name.
It relies on programs.sqlite, which is generated as part of the channel release process by scripts available at GitHub - NixOS/nixos-channel-scripts: Tools to create channels from hydra jobsets. Because generating this database requires building essentially all programs, the database is not available from a github checkout since it inherently relies on hydra builds. (EDIT: blurred because not quite sure it’s accurate: This is part of why the channel-based expressions available on https://releases.nixos.org/ take a few days to be available after the channel tag gets updated on github (since the tag updating is gated on a smaller number of tests passing, and so completes earlier).) This is all better described at Channel branches - NixOS Wiki.
nix-index is a third-party tool to provide the same functionality in another way. It is best described by it’s git page:
nix-index is a tool to quickly locate the package providing a certain file in
nixpkgs. It indexes built derivations found in binary caches.
nix-index provides nix-locate, which is a command that also lets you see which packages contain a specific executable. nix-index-database provides pre-generated databases and a wrapper around the whole thing that makes it easier to use declaratively. nix-locate is more explicit in it’s intent than just typing a command at the CLI, and therefore more amenable to scripting.
I don’t really know why you’d prefer to use EDIT: it seems that although providing similar functionality, it’s worth noting that the actual database file you get is not the same, per the replies below. As tejing notes, nix-index over the builtin https://release.nixos.org option, but it does exist. I suppose I also don’t really know why you’d prefer to use the https://release.nixos.org option either. They seem functionally very equivalent, but I am not an expert.nix-index also provides dynamic library information, so this is one reason to use nix-index.
comma is a tool which uses EDIT: programs.sqlitenix-index to spawn ephemeral shells which will contain an executable, so it’s a useful convenience and another reason to use nix-index.
Note that if you are not using nix-channel the tool, you will need to set the command-not-found.dbPath appropriately for programs.sqlite.
Are there other cool functionality that people are aware of that rely on programs.sqlite or nix-index?