Searching packages

From NixOS Wiki
Revision as of 16:14, 18 April 2024 by Klinger (talk | contribs) (Package search does not only search package names, but also the description. Added pro/contra to a subsection. Added idea of search engines in browser))

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 for

with channels
with 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 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
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.8.1. Type :? for help.

nix-repl>

Loading the repository for nixpkgs

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

Type the first letters of a package

nix-repl>
firef

Press Tab ↹ key for auto completion

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.