title: Listing package versions order: 2#
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.
<!-- @include: ./emacs-all.ansi.bash -->
see command output
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.
<!-- @include: ./emacs-local.ansi.bash -->
see command output
Semantic Version Constraints.#
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.
SemVer Constraint Syntax#
::: tip SemVer Documentation.
For more information on the supported constraint syntax, read the documentation of the library we use: semver constraints.
:::
Using the previous emacs example, lets filter by just a pair of release series.
<!-- @include: ./emacs-27-29.ansi.bash -->
see command output
--all (short -a)#
Use --all to visualize the matching versions compared to all others.
nix-versions 'emacs@~27 || ~29' --all
see command output
As you can see, coloring can help visualising the selected versions matching an specified constraint and also
the latest version in all the set. You can turn off colors using the --color=false option.
--one (short -1)#
Use --one to show only the latest version that matches an specified constraint.
<!-- @include: ./emacs-27-29-one.ansi.bash -->
see command output
Regexp Version Constraints#
Sometimes packages do not follow SemVer conventions. In those cases you can specify a regular expression to match on versions.
::: info 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 $.
:::
<!-- @include: ./leanify-regexp-all.ansi.bash -->