Skip to content

Add Nix versioning scheme - #212

Open
samiser wants to merge 1 commit into
aboutcode-org:mainfrom
samiser:add-nix-scheme
Open

Add Nix versioning scheme#212
samiser wants to merge 1 commit into
aboutcode-org:mainfrom
samiser:add-nix-scheme

Conversation

@samiser

@samiser samiser commented Sep 4, 2026

Copy link
Copy Markdown

Adds NixVersion and NixVersionRange (vers:nix/), ordered exactly as Nix's builtins.compareVersions. The algorithm is embedded as src/univers/nix.py with .ABOUT/.NOTICE provenance, following the arch.py convention.

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.3pre1 or 9.8p1 follow an ordering no existing scheme reproduces (any string is valid, only pre marks a pre-release, a leading v is 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.py regenerates 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.cfg and the root license files are updated accordingly. Nix has no native range notation, so there is no from_native. NixVersion is also unhashable like ArchLinuxVersion, for the same reason.

Signed-off-by: Samiser <github@me.samiser.xyz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant