3
0
Fork 0
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:
Maximilian Bosch 2023-10-20 12:12:48 +02:00
parent 039f73f134
commit bb7921d1d6
No known key found for this signature in database
GPG key ID: D006A998C6ABFDF1
3 changed files with 24 additions and 10 deletions

View file

@ -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
{

View 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;
};
}

View file

@ -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);
};
}