check-meta(hasUnsupportedPlatform): use lib.meta.availableOn

`hasUnsupportedPlatform` was not updated with #37395, so it does not
understand attrsets in `meta.[bad]platforms`.  In particular,
attrsets in `meta.badPlatforms` will "fail open" and be ignored.

Let's use `lib.meta.availableOn` instead of duplicating its logic.

Thanks to @alyssais for [noticing][1].

[1][https://github.com/NixOS/nixpkgs/pull/194148#discussion_r990817610]

Co-authored-by: sternenseemann <sternenseemann@systemli.org>
This commit is contained in:
Adam Joseph 2022-10-09 15:26:14 -07:00 committed by Alyssa Ross
parent 0b90e548b5
commit 098c6b0bec
2 changed files with 4 additions and 7 deletions

View File

@ -98,9 +98,7 @@ rec {
2. None of `meta.badPlatforms` pattern matches the given platform.
*/
availableOn = platform: pkg:
if !(pkg?meta) then true else
(!(pkg.meta ? platforms) ||
lib.any (platformMatch platform) pkg.meta.platforms) &&
((!pkg?meta.platforms) || lib.any (platformMatch platform) pkg.meta.platforms) &&
lib.all (elem: !platformMatch platform elem) (pkg.meta.badPlatforms or []);
/* Get the corresponding attribute in lib.licenses

View File

@ -57,9 +57,8 @@ let
isMarkedBroken = attrs: attrs.meta.broken or false;
hasUnsupportedPlatform = attrs:
(!lib.lists.elem hostPlatform.system (attrs.meta.platforms or lib.platforms.all) ||
lib.lists.elem hostPlatform.system (attrs.meta.badPlatforms or []));
hasUnsupportedPlatform =
pkg: !(lib.meta.availableOn hostPlatform pkg);
isMarkedInsecure = attrs: (attrs.meta.knownVulnerabilities or []) != [];
@ -272,7 +271,7 @@ let
sourceProvenance = listOf lib.types.attrs;
maintainers = listOf (attrsOf anything); # TODO use the maintainer type from lib/tests/maintainer-module.nix
priority = int;
platforms = listOf str;
platforms = listOf (either str (attrsOf anything)); # see lib.meta.platformMatch
hydraPlatforms = listOf str;
broken = bool;
unfree = bool;