Index of files of binary cache

With pacman I can easily query database for containing files. For example: pacman -F XInput2.h will show

extra/libxi 1.8-1 [installed]
    usr/include/X11/extensions/XInput2.h

I know there is GitHub - nix-community/nix-index: Quickly locate nix packages with specific files [maintainers=@bennofs @figsoda @raitobezarius]. But looking at the source code, I see they just query the binary cache server with every package’s hash. Is there a way to build file indexes more effectively?

No, I don’t think so. The binary cache is quite dumb. And thanks to that it’s relatively simple to distribute via a CDN.

Related:

  • I think some (unofficial) place already offers a finished index
  • channels come with index of binaries, so e.g.
    $ rustc
    The program 'rustc' is not in your PATH. It is provided by several packages.
    You can make it available in an ephemeral shell by typing one of the following:
      nix-shell -p mrustc-bootstrap
      nix-shell -p rustc
      nix-shell -p rustup
    
1 Like

nix-index can also have a local database, you don’t need to use the online binary cache

How did you enable that? I installed NixOS, and it doesn’t prompt like that by default.

Yeah, I know it caches file index.

I found unofficial nix-index-database, so it’s not an issue now. But if I can reuse nix-channels` cache, it would be better.

Thanks everyone

programs.command-not-found.enable, should be true by default. I don’t know what’s wrong in your case.

The default DB path is /nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite so I’d start by checking its existence.

1 Like

And in case the shell hook is not working for some reason, it’s possible to run explicitly, e.g. command-not-found rustc

1 Like

Yes, the database wasn’t there. I found solution here (`command-not-found` unable to open database - #8 by cdepillabout)
I just run sudo nix-channel --update to fix that.

But unfortunately, programs.sqlite maps executable name to package name, I need full file index. Maybe it will be useful for someone, programs.sqlite contains only in nixos channels. FYI you can download it from Channels for NixOS project(s) nixexprs.tar.xz file.

Thanks, the issue is closed now.

1 Like

23.05 is working, nice