forked from mirrors/nixpkgs
flake: also provide proper version info for lib's flake
This effectively means that nixpkgs$ nix eval ./lib#lib.trivial.version "23.11.20231020.ee0d6b5" now gives meaningful results as well. See https://github.com/NixOS/nixpkgs/pull/257100#discussion_r1352075369 for the discussion around this.
This commit is contained in:
parent
039f73f134
commit
bb7921d1d6
10
flake.nix
10
flake.nix
|
@ -9,17 +9,9 @@
|
|||
nixpkgs = self;
|
||||
};
|
||||
|
||||
libVersionInfoOverlay = import ./lib/__flake-version-info.nix self;
|
||||
lib = (import ./lib).extend libVersionInfoOverlay;
|
||||
|
||||
libVersionInfoOverlay = finalLib: prevLib: {
|
||||
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;
|
||||
};
|
||||
};
|
||||
|
||||
forAllSystems = lib.genAttrs lib.systems.flakeExposed;
|
||||
in
|
||||
{
|
||||
|
|
17
lib/__flake-version-info.nix
Normal file
17
lib/__flake-version-info.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
# 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;
|
||||
};
|
||||
}
|
|
@ -1,5 +1,10 @@
|
|||
{
|
||||
description = "Library of low-level helper functions for nix expressions.";
|
||||
|
||||
outputs = { self }: { lib = import ./.; };
|
||||
outputs = { self }:
|
||||
let
|
||||
lib' = import ./.;
|
||||
in {
|
||||
lib = lib'.extend (import ./__flake-version-info.nix self);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue