From 098c6b0becdbf0226b359c69fbfa4911b35a77d9 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sun, 9 Oct 2022 15:26:14 -0700 Subject: [PATCH] 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 --- lib/meta.nix | 4 +--- pkgs/stdenv/generic/check-meta.nix | 7 +++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/meta.nix b/lib/meta.nix index 8f4e7e2c7bf7..62894aeb316b 100644 --- a/lib/meta.nix +++ b/lib/meta.nix @@ -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 diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index da2e9b135f2e..751e19d1681a 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -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;