lib/clan: add checks

This commit is contained in:
Johannes Kirschbauer
2025-10-02 18:16:04 +02:00
parent 149e14e85d
commit 2dabff5db1
2 changed files with 63 additions and 13 deletions

View File

@@ -39,23 +39,32 @@ in
};
modules = [
clan-core.modules.clan.default
{
checks.minNixpkgsVersion = {
assertion = lib.versionAtLeast nixpkgs.lib.version "25.11";
message = ''
Nixpkgs version: ${nixpkgs.lib.version} is incompatible with clan-core. (>= 25.11 is recommended)
---
Your version of 'nixpkgs' seems too old for clan-core.
Please read: https://docs.clan.lol/guides/nixpkgs-flake-input
You can ignore this check by setting:
clan.checks.minNixpkgsVersion.ignore = true;
---
'';
};
}
];
};
apply =
config:
# TOOD:
# - allow to disable version check?
# - self-incrementing version?
if !lib.versionAtLeast nixpkgs.lib.version "25.11" then
throw ''
Nixpkgs version: ${nixpkgs.lib.version} is incompatible with clan-core. (>= 25.11 is required)
---
Your version of 'nixpkgs' seems too old for clan-core.
Please read: https://docs.clan.lol/guides/nixpkgs-flake-input
---
''
else
config;
lib.deepSeq (lib.mapAttrs (
id: check:
if check.ignore || check.assertion then
null
else
throw "clan.checks.${id} failed with message\n${check.message}"
) config.checks) config;
};
# Mapped flake toplevel outputs