Searching packages: Difference between revisions

imported>Rapenne-s
m Better display
Klinger (talk | contribs)
m changed link from redirect page to article
 
(10 intermediate revisions by 6 users not shown)
Line 1: Line 1:
There are a different ways to search for a package name in the nix package manager.
There are numerous approaches available for searching substrings within both package names and package descriptions in <code>nixpkgs</code>.


== Using <code>search.nixos.org</code> website ==


== The NixOS packages search engine ==
There is a web service to search with
: [[channel branches]]
:* Nix packages at [https://search.nixos.org/packages search.nixos.org/packages]
:* NixOS options at [https://search.nixos.org/options search.nixos.org/options]
: [[flakes]]
:* packages at [https://search.nixos.org/flakes?type=packages search.nixos.org/flakes?type=packages]
:* options at [https://search.nixos.org/flakes?type=options search.nixos.org/flakes?type=options]


There is a website that let you search for Nix packages and NixOS options at https://search.nixos.org/
; pros:
* easy to use
* allows filters
* nice GUI in browser
* browser extensions possible (like @nixpgs as search engine in Firefox)
; cons:
* always requires Internet connection


* pros
== Using the <code>nix search</code> command ==
** it's easy to use
** allow filters
* cons
** it requires Internet


== Using the nix-env command ==
While this command requires [[flakes]], you can use it to search for a package. It may be slow the first time, but further runs will use cached results.
 
<syntaxhighlight lang="bash">nix search nixpkgs firefox</syntaxhighlight>
 
; pros:
* fast
* possible offline usage
; cons:
* requires disk space for caching
* quite long command
 
== Using the <code>nix-env</code> command ==


It's possible to search for a package using <code>nix-env -qaP</code>
It's possible to search for a package using <code>nix-env -qaP</code>


* pros
; pros:
** works offline
* works offline
* cons
; cons:
** it's very slow and requires a lot of memory
* it's very slow and requires a lot of memory
 
== Using the <code>nix repl</code> environment ==
 
With the read–eval–print loop (REPL) of nix you can browse packages interactively.
 
Starting the [https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-repl.html nix repl]
<syntaxhighlight lang="bash">nix repl</syntaxhighlight>
<syntaxhighlight lang="console">
Welcome to Nix 2.18.2. Type :? for help.
 
nix-repl>
</syntaxhighlight>
 
Loading the repository for nixpkgs
<syntaxhighlight lang="console">
nix-repl>
</syntaxhighlight>
<syntaxhighlight lang="bash">nix-repl> :load <nixpkgs>
Added 21181 variables.
</syntaxhighlight>Type the first letters of a package
<syntaxhighlight lang="bash">nix-repl> neo  </syntaxhighlight>
Press <tt>Tab ↹</tt> key<!-- {{[[mw:Template::Key press]]|Tab}} --> for auto completion


== Reverse search: searching which package provides a file ==
== Reverse search: searching which package provides a file ==


It's possible to use the third party program [https://github.com/bennofs/nix-index nix-index] to find which package provides a given file, this is particularly useful when you are looking for a very specific file but you don't know which package installs it.
There is third party programs [https://github.com/nix-community/nix-index nix-index], and [https://wiki.nixos.org/wiki/Flakes rippkgs] to find which package provides a given file. This is particularly useful when you are looking for a very specific file but you don't know which package installs it.


[[Category:Reference]]
[[Category:Reference]]
[[Category:Nixpkgs]]