lib.meta: introduce availableOn

This commit is contained in:
oxalica
2021-02-26 00:21:13 +08:00
parent 905ecb920e
commit 354d262db8
14 changed files with 27 additions and 15 deletions

View File

@@ -87,4 +87,16 @@ rec {
then { system = elem; }
else { parsed = elem; };
in lib.matchAttrs pattern platform;
/* Check if a package is available on a given platform.
A package is available on a platform if both
1. One of `meta.platforms` pattern matches the given platform.
2. None of `meta.badPlatforms` pattern matches the given platform.
*/
availableOn = platform: pkg:
lib.any (platformMatch platform) pkg.meta.platforms &&
lib.all (elem: !platformMatch platform elem) (pkg.meta.badPlatforms or []);
}