Skip to content

Listing package versions

In the following example, emacs@* is a package spec. Requesting emacs at any version. And is equivalent to just emacs or emacs@ with an empty constraint.

Terminal window
nix-versions emacs@*

If you want to know the emacs version available on your system’s nixpkgs tree, use the system: backend prefix. More on backend prefixes here.

Terminal window
nix-versions system:emacs@

A version constraint lets you filter by only those versions that match a particular release set.

This is a very useful feature when you need to keep your tools in a range of known, stable versions. For example, you might need that your compiler/interpreter is always compatible with your current code, even if the nixpkgs tree is bleeding edge and contains latest versions that you might be not be ready to use.

Using the previous emacs example, lets filter by just a pair of release series.

Terminal window
nix-versions 'emacs@~27 || ~29'

Use --all to visualize the matching versions compared to all others.

Terminal window
nix-versions 'emacs@~27 || ~29' --all

As you can see, coloring can help visualising the selected versions matching a specified constraint and also the latest version in all the set. You can turn off colors using the --color=false option.

Use --one to show only the latest version that matches a specified constraint.

Terminal window
nix-versions 'emacs@~27 || ~29' --one

Sometimes packages do not follow SemVer conventions. In those cases you can specify a regular expression to match on versions.

Enable Regexps by ending your constraint with the $ symbol.

Since $ is an invalid character on SemVer constraint syntax, we use it to identify when a constraint should be matched as a regexp. So, always try to start your regexp expression with ^ and end it with $.

Terminal window
nix-versions 'leanify@^27\.[0-9]+$'
Contribute Community Sponsor