Search nix packages versions - and minimalist devshell and version manager built on nix - Flake generator for version pinned packages.
1---
2title: Listing package versions
3order: 2
4---
5
6# Listing package versions.
7
8In the following example, `emacs@*` is a package spec. Requesting emacs at any version.
9And is equivalent to just `emacs` or `emacs@` with an empty constraint.
10
11```shell
12<!-- @include: ./emacs-all.ansi.bash -->
13```
14<details><summary>see command output</summary>
15<pre class="ansi-to-html">
16<!-- @include: ./emacs-all.ansi.html -->
17</pre>
18</details>
19
20If you want to know the emacs version available on your system's nixpkgs tree,
21use the `system:` backend prefix. More on backend prefixes [here](./finding-packages.html#backend-prefixes).
22
23```shell
24<!-- @include: ./emacs-local.ansi.bash -->
25```
26<details><summary>see command output</summary>
27<pre class="ansi-to-html">
28<!-- @include: ./emacs-local.ansi.html -->
29</pre>
30</details>
31
32
33## Semantic Version Constraints.
34
35A version constraint lets you filter by only those versions that match a particular release set.
36
37This is a very useful feature when you need to keep your tools in a range of known, stable versions.
38For 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.
39
40### SemVer Constraint Syntax
41
42::: tip [SemVer Documentation](https://github.com/Masterminds/semver?tab=readme-ov-file#basic-comparisons).
43
44For more information on the supported constraint syntax, read the documentation of the library we use: [semver constraints](https://github.com/Masterminds/semver?tab=readme-ov-file#checking-version-constraints).
45
46:::
47
48Using the previous emacs example, lets filter by just a pair of release series.
49
50```shell
51<!-- @include: ./emacs-27-29.ansi.bash -->
52```
53<details><summary>see command output</summary>
54<pre class="ansi-to-html">
55<!-- @include: ./emacs-27-29.ansi.html -->
56</pre>
57</details>
58
59### `--all` (short `-a`)
60Use `--all` to visualize the matching versions compared to all others.
61
62```shell
63nix-versions 'emacs@~27 || ~29' --all
64```
65<details><summary>see command output</summary>
66<pre class="ansi-to-html">
67<!-- @include: ./emacs-27-29-all.ansi.html -->
68</pre>
69</details>
70
71
72As you can see, coloring can help visualising the selected versions matching an specified constraint and also
73the latest version in all the set. You can turn off colors using the `--color=false` [option](cli-help.html).
74
75
76### `--one` (short `-1`)
77
78Use `--one` to show only the latest version that matches an specified constraint.
79
80```shell
81<!-- @include: ./emacs-27-29-one.ansi.bash -->
82```
83<details><summary>see command output</summary>
84<pre class="ansi-to-html">
85<!-- @include: ./emacs-27-29-one.ansi.html -->
86</pre>
87</details>
88
89
90## Regexp Version Constraints
91
92Sometimes packages do not follow SemVer conventions. In those cases you can specify
93a regular expression to match on versions.
94
95::: info Enable Regexps by ending your constraint with the `$` symbol.
96
97Since `$` is an invalid character on SemVer constraint syntax, we use it to identify
98when a constraint should be matched as a regexp. So, always try to start your regexp
99expression with `^` and end it with `$`.
100:::
101
102
103```shell
104<!-- @include: ./leanify-regexp-all.ansi.bash -->
105```
106<details><summary>see command output</summary>
107<pre class="ansi-to-html">
108<!-- @include: ./leanify-regexp-all.ansi.html -->
109</pre>
110</details>
111