diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2018-03-19 18:03:46 -0400 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2018-03-19 19:29:16 -0400 |
commit | e547bd0dc419cdbe2e8d8440224b252f723590ab (patch) | |
tree | 56bcf02f80daba865e1aa7e5c9cf9b65ad21a62d /lib/meta.nix | |
parent | eae19f3c28503a8623b0fee10bfb0b3322122637 (diff) |
lib: Factor in tiny bit of `meta.platform` checking
I need it in stdenv and release-lib, so that seems motivation enough.
Diffstat (limited to 'lib/meta.nix')
-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 07b1710fff70..199030c103af 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; } |