From b7d097438b9b0f782a707f3295d320d824810864 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sat, 24 Sep 2022 22:00:46 -0700 Subject: [PATCH] lib/meta.nix: platformMatch: allow predicate functions --- lib/meta.nix | 7 ++++++- pkgs/stdenv/generic/check-meta.nix | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/meta.nix b/lib/meta.nix index 62894aeb316b..cdd3e1d596c0 100644 --- a/lib/meta.nix +++ b/lib/meta.nix @@ -78,10 +78,15 @@ rec { 2. (modern) a pattern for the platform `parsed` field. + 3. (functional) a predicate function returning a boolean. + We can inject these into a pattern for the whole of a structured platform, and then match that. */ - platformMatch = platform: elem: let + platformMatch = platform: elem: + if builtins.isFunction elem + then elem platform + else let pattern = if builtins.isString elem then { system = elem; } diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index 751e19d1681a..94998bbfa0fe 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -271,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 (either str (attrsOf anything)); # see lib.meta.platformMatch + platforms = listOf (oneOf [ str (attrsOf anything) (functionTo bool) ]); # see lib.meta.platformMatch hydraPlatforms = listOf str; broken = bool; unfree = bool;