Skip to content

Commit

Permalink
check-meta(hasUnsupportedPlatform): use lib.meta.availableOn
Browse files Browse the repository at this point in the history
`hasUnsupportedPlatform` was not updated with NixOS#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][NixOS#194148 (comment)]

Co-authored-by: sternenseemann <sternenseemann@systemli.org>
Rate limit · GitHub

Access has been restricted

You have triggered a rate limit.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

2 people authored and alyssais committed Jan 11, 2023
1 parent 0b90e54 commit 098c6b0
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 1 addition & 3 deletions lib/meta.nix
Original file line number Diff line number Diff line change
@@ -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
7 changes: 3 additions & 4 deletions pkgs/stdenv/generic/check-meta.nix
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 098c6b0

Please sign in to comment.