Skip to content

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.

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-unstable or a particular release nixos-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.

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:

Terminal window
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.

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.

Terminal window
# Search programs whose name matches pip
nix run nixpkgs#nix-search-cli -- --name pip --max-results 3

Be sure to checkout their help documentation nix-search-cli --help for more advanced examples.

Thanks to our integration with nix-search-cli, it is possible to include the * wildcard in a package name.

Terminal window
nix-versions 'cargo*@latest'

It is possible to list packages that provide a given program by prefixing with bin/.

Terminal window
nix-versions 'bin/emacsclient@latest'

Listing different ruby implementations:

Terminal window
nix-versions 'bin/ruby@latest'

The program can also include * wildcards.

Terminal window
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.

Terminal window
nix-versions 'lazamar:nixos-21.05:emacs@latest' 'lazamar:nixos-23.05:emacs@latest' 'lazamar:nixpkgs-unstable:emacs@latest'

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>.

Terminal window
nix-versions emacs@~ --lazamar=nixos-23.05
Contribute Community Sponsor