Finding packages
Finding packages
Section titled “Finding packages”In order to install a package, you need to know its attribute path.
nix-versions is only possible thanks to the awesome people who have built public web services that allow us to search
not only historic versions, but also packages by matching on their attribute path and provided programs.
Search Backends
Section titled “Search Backends”Currently, nix-versions can interface to the following backends:
-
search.nixos.org - This is the official NixOS website used to search for packages. Most people use it via the web interface, but thanks to nix-search-cli we can query their ElasticSearch database and find packages by name or provided programs.
-
Lazamar index - Thanks to Lazamar, people can search historical versions of packages by channel. (You can think of a nixpkgs channel as a particular branch, eg
nixpkgs-unstableor a particular releasenixos-24.05.) -
NixHub API - The nice guys at Jetify built this versions index for their awesome devbox product. And kindly have provided a public API.
-
history.nix-packages.com API - Another community provided API providing historic versions for nixpkgs.
When searching for packages by wildcards on their attribute name or provided program names, we use search.nixos.org.
For searching versions, we can use any of the other backends. NixHub is pre-selected as default versions backend, since it seems to be updated more frequently.
Backend Prefixes
Section titled “Backend Prefixes”For each package spec it is possible to specify the backend that will be used to search for versions of it
by using a prefix like nixhub:, lazamar:<channel>, history:, system:.
Of these system: is the only one that is not a remote service. It will query your local nixpkgs tree and return the current version
that is available for some package.
You can mix them on a single command line to compare version availability on the different indexes:
nix-versions 'nixhub:emacs@latest' 'lazamar:nixos-24.05:emacs@latest' 'system:emacs@'You can also change the default backend for those that do not use a particular backend prefix by using the options like --nixhub, --lazamar and --history.
nix-search-cli Integration
Section titled “nix-search-cli Integration”We recommend the amazing nix-search-cli tool which we use internally to interact with search.nixos.org, but that you can use from your terminal to search for packages by name, description, programs, license, homepage, and more.
# Search programs whose name matches pipnix run nixpkgs#nix-search-cli -- --name pip --max-results 3Be sure to checkout their help documentation nix-search-cli --help for more advanced examples.
Wildcards in package names
Section titled “Wildcards in package names”Thanks to our integration with nix-search-cli,
it is possible to include the * wildcard in a package name.
nix-versions 'cargo*@latest'Packages by program name
Section titled “Packages by program name”It is possible to list packages that provide a given program by
prefixing with bin/.
nix-versions 'bin/emacsclient@latest'Listing different ruby implementations:
nix-versions 'bin/ruby@latest'Packages by program wildcard
Section titled “Packages by program wildcard”The program can also include * wildcards.
nix-versions 'bin/cargo*@latest'Finding versions on a particular nixpkgs channel
Section titled “Finding versions on a particular nixpkgs channel”Using the Lazamar index, you can search for versions of programs at a particular NixOS release or nixpkgs branch. See their webpage for existing channels you can use.
The following example lists the latest versions of emacs at nixos-21.05, nixos-23.05 and nixpkgs-unstable.
nix-versions 'lazamar:nixos-21.05:emacs@latest' 'lazamar:nixos-23.05:emacs@latest' 'lazamar:nixpkgs-unstable:emacs@latest'Setting default versions backend
Section titled “Setting default versions backend”If no prefix has been specified, the default versions backend is used (NixHub). But you can also
override the default backend via options like --nixhub, --history, --lazamar <channel>.
nix-versions emacs@~ --lazamar=nixos-23.05