Searching packages: Difference between revisions

imported>Vater
there is also a search for everybody's (experimental) darling flakes nowadays
imported>Vater
form & foo
Line 1: Line 1:
There are multiple ways to search for a package name in <code>nixpkgs</code>.
There are multiple ways to search for a package name in <code>nixpkgs</code>.


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


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


* pros:
; pros:
** easy to use
* easy to use
** allows filters
* allows filters
* cons:
; cons:
** requires Internet connection
* requires Internet connection


== Using <code>nix search</code> command ==
== Using the <code>nix search</code> command ==


While this command is still experimental, you can use it to search for a package. It may be slow the first time, but further runs will use cached results.
While this command is still experimental, you can use it to search for a package. It may be slow the first time, but further runs will use cached results.


<pre>
<syntaxhighlight lang="bash">nix --extra-experimental-features "nix-command flakes" search nixpkgs firefox</syntaxhighlight>
$ nix --extra-experimental-features "nix-command flakes" search nixpkgs firefox
</pre>


== Using the <code>nix-env</code> command ==
== Using the <code>nix-env</code> command ==
Line 27: Line 27:
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


== Interactive package browsing with <code>nix repl</code> ==
== Using the <code>nix repl</code> environment ==


You can start <code>nix repl</code> to load the <code>nixpkgs</code> repository and then use auto completion to search for packages.
With the read–eval–print loop (REPL) of nix you can browse packages interactively.


<pre>
Starting the [[nix command/repl|nix repl]]
$ nix repl
<syntaxhighlight lang="bash">nix repl</syntaxhighlight>
<syntaxhighlight lang="console">
Welcome to Nix 2.8.1. Type :? for help.
Welcome to Nix 2.8.1. Type :? for help.


nix-repl> :load <nixpkgs>
nix-repl>
</syntaxhighlight>
 
Loading the repository for nixpkgs
<syntaxhighlight lang="console">
nix-repl>
</syntaxhighlight>
<syntaxhighlight lang="bash">:load <nixpkgs></syntaxhighlight>
<syntaxhighlight lang="console">
Added 16519 variables.
Added 16519 variables.
</syntaxhighlight>


nix-repl> firef[PRESS TAB]
Type the first letters of a package
</pre>
<syntaxhighlight lang="console">nix-repl></syntaxhighlight>
<syntaxhighlight lang="bash">firef</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 ==