Merge pull request #114374 from oxalica/lib/platform-support-check

lib.meta: introduce `availableOn` to check package availability on given platform
This commit is contained in:
Silvan Mosberger
2021-05-08 03:54:36 +02:00
committed by GitHub
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 []);
}