Add Nix versioning scheme - #212
Open
samiser wants to merge 1 commit into
Open
Conversation
Signed-off-by: Samiser <github@me.samiser.xyz>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
NixVersionandNixVersionRange(vers:nix/), ordered exactly as Nix'sbuiltins.compareVersions. The algorithm is embedded assrc/univers/nix.pywith.ABOUT/.NOTICEprovenance, following thearch.pyconvention.Also I know the diff line count looks daunting (sorry) but the vast majority of the diff is test data (see Testing).
Motivation
The NixOS security tracker is looking at using univers for CVE constraint checking, and real nixpkgs versions like
2.3pre1or9.8p1follow an ordering no existing scheme reproduces (any string is valid, onlypremarks a pre-release, a leadingvis significant).Testing
The fixture is all 2,025 pairs of a 45-string corpus with expected values produced by the reference implementation itself via
nix-instantiate.etc/scripts/gen_nix_version_cmp.pyregenerates it byte-identically, and CI does not need Nix. That design is why the fixture is ~32k lines, but the rest of the diff is ~400.I know this is longer than other existing test data, but it's just the nature of the combinatorics. If it's too long I could potentially reduce the number of atoms, but I would argue it's better to be as comprehensive as possible.
Other Notes
The ported algorithm is LGPL-2.1-or-later, so
setup.cfgand the root license files are updated accordingly. Nix has no native range notation, so there is nofrom_native.NixVersionis also unhashable likeArchLinuxVersion, for the same reason.