diff options
author | John Ericson <Ericson2314@yahoo.com> | 2018-03-19 20:12:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-19 20:12:50 -0400 |
commit | 3c331bff5b1c00a2c6d24f889b684d7331220b5b (patch) | |
tree | 97721246695f6039d5592b86cb65ed264be1c9c5 /lib | |
parent | e8fe2e15489665ac02c3702763b9dcd817beca13 (diff) | |
parent | e547bd0dc419cdbe2e8d8440224b252f723590ab (diff) |
Merge pull request #37395 from obsidiansystems/lib-meta-platform
lib: Factor in tiny bit of `meta.platform` checking
Diffstat (limited to 'lib')
-rw-r--r-- | lib/meta.nix | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/meta.nix b/lib/meta.nix index 07b1710fff70a..199030c103af5 100644 --- a/lib/meta.nix +++ b/lib/meta.nix @@ -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; } |