Searching packages: Difference between revisions

From NixOS Wiki
imported>Rapenne-s
add nix search
imported>Fricklerhandwerk
formatting and wording
Line 1: Line 1:
There are a different ways to search for a package name in the nix package manager.
There are multiple ways to search for a package name in <code>nixpkgs</code>.


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


== The NixOS packages search engine ==
There is a web service to search for
* Nix packages at [https://search.nixos.org/packages search.nixos.org/packages]
* NixOS options at [https://search.nixos.org/options search.nixos.org/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
* cons:
** requires Internet connection


* pros
== Using <code>nix search</code> command ==
** it's easy to use
** allow filters
* cons
** it requires Internet
 
== Using nix search 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.
Line 20: Line 21:
</pre>
</pre>


== Using the nix-env 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


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


You can use the nix repl to load the nixpkgs repository and then use the auto completion to search for packages.
You can start <code>nix repl</code> to load the <code>nixpkgs</code> repository and then use auto completion to search for packages.


<pre>
<pre>
Line 45: Line 46:
== 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 a 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.


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

Revision as of 12:45, 4 August 2022

There are multiple ways to search for a package name in nixpkgs.

Using search.nixos.org

There is a web service to search for

  • pros:
    • easy to use
    • allows filters
  • cons:
    • requires Internet connection

Using nix search 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.

$ nix --extra-experimental-features "nix-command flakes" search nixpkgs firefox

Using the nix-env command

It's possible to search for a package using nix-env -qaP

  • pros:
    • works offline
  • cons:
    • it's very slow and requires a lot of memory

Interactive package browsing with nix repl

You can start nix repl to load the nixpkgs repository and then use auto completion to search for packages.

$ nix repl
Welcome to Nix 2.8.1. Type :? for help.

nix-repl> :load <nixpkgs>
Added 16519 variables.

nix-repl> firef[PRESS TAB]

Reverse search: searching which package provides a file

There is a third party program 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.