Merge pull request #37395 from obsidiansystems/lib-meta-platform

lib: Factor in tiny bit of `meta.platform` checking
This commit is contained in:
John Ericson
2018-03-19 20:12:50 -04:00
committed by GitHub
3 changed files with 26 additions and 15 deletions

View File

@@ -67,4 +67,23 @@ rec {
*/
hiPrioSet = set: mapDerivationAttrset hiPrio set;
/* Check to see if a platform is matched by the given `meta.platforms`
element.
A `meta.platform` pattern is either
1. (legacy) a system string.
2. (modern) a pattern for the platform `parsed` field.
We can inject these into a patten for the whole of a structured platform,
and then match that.
*/
platformMatch = platform: elem: let
pattern =
if builtins.isString elem
then { system = elem; }
else { parsed = elem; };
in lib.matchAttrs pattern platform;
}