flake/version overlay: review fixes

* Improves the comments of `lib/flake-version-info.nix` and drops the
  `__`-prefix from the filename.
* `lib'` -> `lib0` in `nixpkgs/lib`.
* Drop the declaration of `trivial.version` in the overlay because this
  declaration already uses the final expressions of `versionSuffix` and
  `release` now.
* No need to fall back to `self.lastModified` anymore, this was a
  workaround for pre2.4 Nix.

Co-authored-by: Robert Hensing <robert@roberthensing.nl>
Co-authored-by: Silvan Mosberger <contact@infinisil.com>
This commit is contained in:
Maximilian Bosch 2023-10-31 13:38:29 +01:00
parent 78f5ed053a
commit ede5720a0d
No known key found for this signature in database
GPG Key ID: D006A998C6ABFDF1
4 changed files with 23 additions and 20 deletions

View File

@ -9,7 +9,7 @@
nixpkgs = self;
};
libVersionInfoOverlay = import ./lib/__flake-version-info.nix self;
libVersionInfoOverlay = import ./lib/flake-version-info.nix self;
lib = (import ./lib).extend libVersionInfoOverlay;
forAllSystems = lib.genAttrs lib.systems.flakeExposed;

View File

@ -1,17 +0,0 @@
# lib overlay to be used by the nixpkgs & nixpkgs/lib flakes
# to provide meaningful values for `lib.trivial.version` et al..
#
# Internal and subject to change, don't use this anywhere else!
self: # from the flake
finalLib: prevLib: # lib overlay
{
trivial = prevLib.trivial // {
versionSuffix =
".${finalLib.substring 0 8 (self.lastModifiedDate or self.lastModified or "19700101")}.${self.shortRev or "dirty"}";
version = finalLib.trivial.release + finalLib.trivial.versionSuffix;
revisionWithDefault = default: self.rev or default;
};
}

View File

@ -0,0 +1,20 @@
# This function produces a lib overlay to be used by the nixpkgs
# & nixpkgs/lib flakes to provide meaningful values for
# `lib.trivial.version` et al..
#
# Internal and subject to change, don't use this anywhere else!
# Instead, consider using a public interface, such as this flake here
# in this directory, `lib/`, or use the nixpkgs flake, which applies
# this logic for you in its `lib` output attribute.
self: # from the flake
finalLib: prevLib: # lib overlay
{
trivial = prevLib.trivial // {
versionSuffix =
".${finalLib.substring 0 8 (self.lastModifiedDate or "19700101")}.${self.shortRev or "dirty"}";
revisionWithDefault = default: self.rev or default;
};
}

View File

@ -3,8 +3,8 @@
outputs = { self }:
let
lib' = import ./.;
lib0 = import ./.;
in {
lib = lib'.extend (import ./__flake-version-info.nix self);
lib = lib0.extend (import ./flake-version-info.nix self);
};
}