Searching packages: Difference between revisions

From NixOS Wiki
Gerg-L (talk | contribs)
fixed nix-index link, updated nix repl section mention rippkgs
Klinger (talk | contribs)
m changed link from redirect page to article
 
Line 4: Line 4:


There is a web service to search with
There is a web service to search with
: [[channels]]
: [[channel branches]]
:* Nix packages at [https://search.nixos.org/packages search.nixos.org/packages]
:* Nix packages at [https://search.nixos.org/packages search.nixos.org/packages]
:* NixOS options at [https://search.nixos.org/options search.nixos.org/options]
:* NixOS options at [https://search.nixos.org/options search.nixos.org/options]
Line 17: Line 17:
* browser extensions possible (like @nixpgs as search engine in Firefox)  
* browser extensions possible (like @nixpgs as search engine in Firefox)  
; cons:
; cons:
* always requires Internet connection  
* always requires Internet connection


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

Latest revision as of 20:32, 1 July 2024

There are numerous approaches available for searching substrings within both package names and package descriptions in nixpkgs.

Using search.nixos.org website

There is a web service to search with

channel branches
flakes
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

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

nix search nixpkgs firefox
pros
  • fast
  • possible offline usage
cons
  • requires disk space for caching
  • quite long command

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

Using the nix repl environment

With the read–eval–print loop (REPL) of nix you can browse packages interactively.

Starting the nix repl

nix repl
Welcome to Nix 2.18.2. Type :? for help.

nix-repl>

Loading the repository for nixpkgs

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

Type the first letters of a package

nix-repl> neo

Press Tab ↹ key for auto completion

Reverse search: searching which package provides a file

There is third party programs nix-index, and 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.