Searching packages: Difference between revisions
Peterldowns (talk | contribs) I added a reference to peterldowns/nix-search-cli. I checked with the wiki maintainers before making this edit: https://github.com/NixOS/nixos-wiki-infra/issues/157 |
Peterldowns (talk | contribs) Reference to peterldowns/nix-search-cli in the search.nixos.org section, since it uses the same backing elasticsearch instance. |
||
Line 18: | Line 18: | ||
; cons: | ; cons: | ||
* always requires Internet connection | * always requires Internet connection | ||
If you'd like to search with this web service from the command line, you may use [https://github.com/peterldowns/nix-search-cli peterldowns/nix-search-cli]. It provides exactly the same search experience by default. | |||
== Using the <code>nix search</code> command == | == Using the <code>nix search</code> command == |
Latest revision as of 22:49, 24 November 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
- Nix packages at search.nixos.org/packages
- NixOS options at search.nixos.org/options
- flakes
- packages at search.nixos.org/flakes?type=packages
- options at search.nixos.org/flakes?type=options
- 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
If you'd like to search with this web service from the command line, you may use peterldowns/nix-search-cli. It provides exactly the same search experience by default.
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 are third party programs that make it easier to determine which package you need to install in order to obtain a specific file or program.
These are most commonly used, and require you to create an index on your computer before you can search for a package:
These are online tools which search an index someone else keeps up to date:
- peterldowns/nix-search-cli:
nix-search -p theBinaryIWantToInstall
to search the search.nixos.org elasticsearch index.