guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implementing Nix's command-not-found in Guix


From: indieterminacy
Subject: Re: Implementing Nix's command-not-found in Guix
Date: Sun, 05 Mar 2023 03:19:14 +0100

On 04-03-2023 22:42, Sarthak Shah wrote:
Hello Guix!

I'd like to implement something similar to NixOS's command-not-found
in Guix.
As you can see in the repository below, it contains a nix file which
is essentially a shell script which runs the second file, a perl
script, if the user enters a command which is not found on this
system. The perl script suggests names of packages containing said
command which it pulls from an SQL database.
https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found
This would make Guix much more user-friendly; for example, new Guix
System users often struggle to figure out how to add the "clear"
command to their shell. command-not-found would immediately inform
them that it can be found in the ncurses package.

How would you recommend I go about implementing something similar for
Guix?
I have unfortunately been unable to find a database or anything
similar listing files outputted to /bin by each package, which would
in my opinion be the starting step.


While you wait for a better answer it may be worth trying out IDUtils (which if I recall Ludo recommended during a Guix blogpost).
```
An ID database is a binary file containing a list of file names, a list of tokens, and a sparse matrix indicating which tokens appear in which files.

With this database and some tools to query it (described in this manual), many text-searching tasks become simpler and faster. For example, you can list all files that reference a particular #include file throughout a huge source hierarchy, search for all the memos containing references to a project, or automatically invoke an editor on all files containing references to some function or variable. Anyone with a large software project to maintain, or a large set of text files to organize, can benefit from the ID utilities.
```
https://www.gnu.org/software/idutils/manual/idutils.html

As such, even if it is not a complete solution it could allow you to identify or exclude things in advance of a more complete or bespoke solutions.

Happy hacking!

--
Jonathan McHugh
indieterminacy@libre.brussels



reply via email to

[Prev in Thread] Current Thread [Next in Thread]