Add index to NixOS channel
So, I'm not sure if you're aware, but NixOS channels already come with a similar index called "programs.sqlite":
https://github.com/NixOS/nixos-channel-scripts/blob/master/generate-programs-index.cc
It works similar to nix-index, but it only handles files in the "bin" directory so it can link in to the "command-not-found" program. nix-index is more general than programs.sqlite and can be useful for more things. Bundling it with the channels could be fairly useful!
This also links well into my attempt to get AppStream metadata for NixOS (NixOS/nixpkgs#15932). I need to be able to lookup what derivations have /share/metainfo/ folders so it can download those derivations and add them to the AppStream database.
Related to this idea of "indexing" Nixpgs, is trying to get a database of the output of nix-env -qa in the channels. It can be a pretty costly call taking up to 30s but it's also a pretty necessary operation when you're making a UI package manager. My backend for PackageKit calls it way too much and it's definitely noticeable. Having a database of this meta stuff would make Nix more like "normal" package managers. Of course, there are issues with overrides and other things changing the attribute set, but those users probably don't want a GUI for their package manager.
It's not particular important to me right now to integrate this into the nixos channels, as building the index really doesn't take all that long and I'm personally not using the channels much anyway (working from git with the channels as branches). We could perhaps add an environment variable to override the default database location. This should make it easy to integrate into the channel, as you could just set it to /nix/var/nix/profiles/per-user/root/channels/nixos/<database>.
About the meta-information, I was thinking about making a database with additional information about each store path. This could, for example, be used to sort the results by popularity of the store path (determined by the amount of things that reference this path) and it could also store description etc and other things that you get from nix-env -qa.
I just found this from this issue: https://github.com/NixOS/nixpkgs/issues/30785
I found out that nodePackages are not searchable by nix-index atm.
@CMCDragonkai the problem is that nodePackages is not built by hydra, so there's no way to know which files are in a node package (we'd have to build it to find out). That's why nix-index cannot find it.
@matthewbauer
as a temp workaround you might want to download from
https://github.com/Mic92/nix-index-database/releases/latest