There’s so much free software out there that sooner or later, you will need
to search for packages. The
guix search command that we’ve seen
before (see Вызов
guix package) lets you search by keywords:
guix search video editor
Sometimes, you instead want to find which package provides a given file, and
this is where
guix locate comes in. Here is how you can find
which package provides the
$ guix locate ls firstname.lastname@example.org /gnu/store/…-coreutils-9.1/bin/ls
Of course the command works for any file, not just commands:
$ guix locate unistr.h email@example.com /gnu/store/…/include/unicode/unistr.h firstname.lastname@example.org /gnu/store/…/include/unistr.h
You may also specify glob patterns with wildcards. For example, here is how you would search for packages providing .service files:
$ guix locate -g '*.service' email@example.com …/lib/systemd/system/man-db.service firstname.lastname@example.org …/system-services/fi.w1.wpa_supplicant1.service
guix locate command relies on a database that maps file names
to package names. By default, it automatically creates that database if it
does not exist yet by traversing packages available locally, which
can take a few minutes (depending on the size of your store and the speed of
your storage device).
Примечание: For now,
guix locatebuilds its database based on purely local knowledge—meaning that you will not find packages that never reached your store. Eventually it will support downloading a pre-built database so you can potentially find more packages.
guix locate first tries to look for a system-wide
database, usually under /var/cache/guix/locate; if it does not exist
or is too old, it falls back to the per-user database, by default under
~/.cache/guix/locate. On a multi-user system, administrators may
want to periodically update the system-wide database so that all users can
benefit from it, for instance by setting up
guix locate [options…] file…
... where file is the name of a file to search for (specifically, the “base name” of the file: files whose parent directories are called file are not matched).
The available options are as follows:
Interpret file… as glob patterns—patterns that may include wildcards, such as ‘*.scm’ to denote all files ending in ‘.scm’.
Display database statistics.
Update the file database.
By default, the database is automatically updated when it is too old.
Clear the database and re-populate it.
This option lets you start anew, ensuring old data is removed from the
database, which also avoids having an endlessly growing database. By
guix locate automatically does that periodically, though
Use file as the database, creating it if necessary.
guix locate picks the database under
~/.cache/guix or /var/cache/guix, whichever is the most recent
Use method to select the set of packages to index. Possible values are:
This is the default method: it works by traversing profiles on the machine and recording packages it encounters—packages you or other users of the machine installed, directly or indirectly. It is fast but it can miss other packages available in the store but not referred to by any profile.
This is a slower but more exhaustive method: it checks among all the existing packages those that are available in the store and records them.