1
0
Fork 0
mirror of https://github.com/hercules-ci/flake-parts.git synced 2024-12-14 11:47:31 +00:00

Merge pull request #165 from hercules-ci/nixpkgs-lower-bound

Add lower bound to lib version
This commit is contained in:
Robert Hensing 2023-05-31 16:33:09 +02:00 committed by GitHub
commit 8eab53d223
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 3 deletions

View file

@ -6,7 +6,14 @@
};
outputs = { nixpkgs-lib, ... }: {
lib = import ./lib.nix { inherit (nixpkgs-lib) lib; };
lib = import ./lib.nix {
inherit (nixpkgs-lib) lib;
# Extra info for version check message
revInfo =
if nixpkgs-lib?rev
then " (nixpkgs-lib.rev: ${nixpkgs-lib.rev})"
else "";
};
templates = {
default = {
path = ./template/default;

20
lib.nix
View file

@ -1,4 +1,8 @@
{ lib }:
{ lib
# Optionally a string with extra version info to be included in the error message
# in case is lib is out of date. Empty or starts with space.
, revInfo ? ""
}:
let
inherit (lib)
mkOption
@ -207,5 +211,19 @@ let
lib.setDefaultModuleLocation modulePath (import modulePath staticArgs);
};
# A best effort, lenient estimate. Please use a recent nixpkgs lib if you
# override it at all.
minVersion = "22.05";
in
if builtins.compareVersions lib.version minVersion <= 0
then
abort ''
The nixpkgs-lib dependency of flake-parts was overridden but is too old.
The minimum supported version of nixpkgs-lib is ${minVersion},
but the actual version is ${lib.version}${revInfo}.
''
else
flake-parts-lib