From 8f782c7af9ecc380cff475061fe921ef04e6ec3d Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Tue, 20 May 2025 23:29:12 +0100 Subject: [PATCH] lib.version: add release info --- lib/version.nix | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/version.nix b/lib/version.nix index f357afdb..993e6959 100644 --- a/lib/version.nix +++ b/lib/version.nix @@ -90,4 +90,35 @@ in locked = lockedInputs.${name}.locked.narHash; in real != locked; + + /** + Nixvim's current commit, or the specified default when nixvim's repo is dirty. + */ + revisionWithDefault = default: flake.sourceInfo.rev or default; + + /** + Nixvim's current commit, defaulting to the canonical branch name for this release. + */ + revision = with lib.nixvim.version; revisionWithDefault releaseBranch; + + /** + Nixvim's release. + + Derived from the nixpkgs branch targeted in `flake.lock`. + */ + release = + let + inherit (lockedInputs.nixpkgs.original) ref; + parts = lib.splitString "-" ref; + in + lib.last parts; + + /** + The canonical branch name associated with this release of nixvim. + */ + releaseBranch = + let + inherit (lib.nixvim.version) release; + in + if release == "unstable" then "main" else "nixos-" + release; }