Semantic versioning for Nix
FlakeHub enables you to use a subset of Semantic Versioning (SemVer) with your Nix flakes. The diagram below provides a quick refresher on the structure of versions in SemVer:
major.minor.patch
Backwardsincompatiblecompatible
- Major versions represent backwards-incompatible API changes.
- Minor versions represent additions of backwards-compatible functionality.
- Patch versions represent backwards-compatible bug fixes.
Here’s an example SemVer-compatible version:
21.3.12
A breaking API change would entail a bump to major version 22 while a bug fix would entail a patch version bump to 13.
For things like pre-releases you can add extra information to the patch.
21.3.12-pre
Supported operators
FlakeHub’s subset of SemVer supports the =
operator.
Exact version (=
)
The =
operator signals that you want to resolve to an exact version.
Here’s an example:
nix flake show "https://flakehub.com/f/DeterminateSystems/fh/=0.1.15"
Here, =0.1.15
could only resolve to 0.1.15
and this operation would fail if that version didn’t exist.
Wildcard operator (*
)
The wildcard (*
) operator allows for any version in that position.
- The version range
*
always uses the highest published version. 1.*
allows any version with the major version of 1.1.2.*
allows any version with the major and minor version 1.2.
nix flake show "https://flakehub.com/f/DeterminateSystems/flake-checker/*"
Here, *
would resolve to the most recent version of the flake-checker flake.