[Nix-dev] Missing command suggestions

Eelco Dolstra eelco.dolstra at logicblox.com
Mon Mar 25 15:24:59 CET 2013


Hi,

On 25/03/13 15:07, Ludovic Courtès wrote:

> Eelco Dolstra <eelco.dolstra at logicblox.com> skribis:
> 
>> NixOS now provides Ubuntu-style missing command suggestions.  I implemented this
>> a while ago, but now it's enabled by default as part of the NixOS channel.
> 
> Nice!  Can you say a bit about the implementation?

The NixOS channel generation script
(https://nixos.org/repos/nix/release/trunk/channels/mirror-nixos.sh) adds a
SQLite database "programs.sqlite" to the channel.  It contains a mapping from
program names to package names.  (See
https://nixos.org/repos/nix/release/trunk/channels/generate-programs-index.pl
for the actual generation of that file.)

After running "nix-channel --update nixos", the database ends up in

  /nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite

The NixOS global bashrc installs a function "command_not_found_handle" which is
called by Bash whenever a command is not found.  It calls a helper script that
looks in the SQLite database to print an appropriate help message.

-- 
Eelco Dolstra | LogicBlox, Inc. | http://nixos.org/~eelco/


More information about the nix-dev mailing list