lib/meta.nix: platformMatch: allow predicate functions

This commit is contained in:
Adam Joseph 2022-09-24 22:00:46 -07:00
parent d3eee3182c
commit b7d097438b
2 changed files with 7 additions and 2 deletions

View File

@ -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; }

View File

@ -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;