Listing package versions
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.
nix-versions 'emacs@*'
see command output
Name Version NixInstallable VerBackend emacs 26.3 nixpkgs/e5b91d9#emacs nixhub emacs 27.1 nixpkgs/54c1e44#emacs nixhub emacs 27.2 nixpkgs/4c3c80d#emacs nixhub emacs 28.1 nixpkgs/994df04#emacs nixhub emacs 28.2 nixpkgs/09ec6a0#emacs nixhub emacs 29.1 nixpkgs/160b762#emacs nixhub emacs 29.2 nixpkgs/a3ed740#emacs nixhub emacs 29.3 nixpkgs/a985888#emacs nixhub emacs 29.4 nixpkgs/b58e19b#emacs nixhub emacs 30.1 nixpkgs/0740f6f#emacs nixhub
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.
nix-versions system:emacs
see command output
Name Version NixInstallable VerBackend emacs 30.1 nixpkgs#emacs system
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
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.
# show only emacs 27 and 29 release series.
nix-versions 'emacs@~27 || ~29'
see command output
Name Version NixInstallable VerBackend emacs 27.1 nixpkgs/54c1e44#emacs nixhub emacs 27.2 nixpkgs/4c3c80d#emacs nixhub emacs 29.1 nixpkgs/160b762#emacs nixhub emacs 29.2 nixpkgs/a3ed740#emacs nixhub emacs 29.3 nixpkgs/a985888#emacs nixhub emacs 29.4 nixpkgs/b58e19b#emacs nixhub
--all
(short -a
)
Use --all
to visualize the matching versions compared to all others.
nix-versions 'emacs@~27 || ~29' --all
see command output
Name Version NixInstallable VerBackend emacs 26.3 nixpkgs/e5b91d9#emacs nixhub emacs 27.1 nixpkgs/54c1e44#emacs nixhub emacs 27.2 nixpkgs/4c3c80d#emacs nixhub emacs 28.1 nixpkgs/994df04#emacs nixhub emacs 28.2 nixpkgs/09ec6a0#emacs nixhub emacs 29.1 nixpkgs/160b762#emacs nixhub emacs 29.2 nixpkgs/a3ed740#emacs nixhub emacs 29.3 nixpkgs/a985888#emacs nixhub emacs 29.4 nixpkgs/b58e19b#emacs nixhub emacs 30.1 nixpkgs/0740f6f#emacs nixhub
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.
nix-versions 'emacs@~27 || ~29' --one
see command output
Name Version NixInstallable VerBackend emacs 29.4 nixpkgs/b58e19b#emacs nixhub
Regexp Version Constraints
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 $
.
nix-versions 'leanify@^\d+-12-\d+$' --all
see command output
Name Version NixInstallable VerBackend leanify 2022-12-04 nixpkgs/10b8130#leanify nixhub leanify 2023-10-19 nixpkgs/92d295f#leanify nixhub leanify 2023-12-17 nixpkgs/0d53485#leanify nixhub