diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2023-01-31 00:02:31 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-31 00:02:31 +0000 |
commit | dd1ff149da07cd25a3e0152c67184e049256fcf1 (patch) | |
tree | 98dd4e2a8ffa16ee3990d1610053bfbcd2003dc8 /lib | |
parent | 7b0719bd7411ffe9935af524729055f58fa6a537 (diff) | |
parent | fe85b09c8be67eb08edbe43122a0301b62a40ef0 (diff) |
Merge master into staging-next
Diffstat (limited to 'lib')
-rw-r--r-- | lib/meta.nix | 11 | ||||
-rw-r--r-- | lib/systems/inspect.nix | 10 |
2 files changed, 15 insertions, 6 deletions
diff --git a/lib/meta.nix b/lib/meta.nix index cdd3e1d596c03..5fd55c4e90d69 100644 --- a/lib/meta.nix +++ b/lib/meta.nix @@ -76,20 +76,19 @@ rec { 1. (legacy) a system string. - 2. (modern) a pattern for the platform `parsed` field. + 2. (modern) a pattern for the entire platform structure (see `lib.systems.inspect.platformPatterns`). - 3. (functional) a predicate function returning a boolean. + 3. (modern) a pattern for the platform `parsed` field (see `lib.systems.inspect.patterns`). We can inject these into a pattern for the whole of a structured platform, and then match that. */ - platformMatch = platform: elem: - if builtins.isFunction elem - then elem platform - else let + platformMatch = platform: elem: let pattern = if builtins.isString elem then { system = elem; } + else if elem?parsed + then elem else { parsed = elem; }; in lib.matchAttrs pattern platform; diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix index 6a9f0fadcd3d1..30615c9fde32c 100644 --- a/lib/systems/inspect.nix +++ b/lib/systems/inspect.nix @@ -7,6 +7,7 @@ let abis_ = abis; in let abis = lib.mapAttrs (_: abi: builtins.removeAttrs abi [ "assertions" ]) abis_; in rec { + # these patterns are to be matched against {host,build,target}Platform.parsed patterns = rec { isi686 = { cpu = cpuTypes.i686; }; isx86_32 = { cpu = { family = "x86"; bits = 32; }; }; @@ -95,4 +96,13 @@ rec { else matchAttrs patterns; predicates = mapAttrs (_: matchAnyAttrs) patterns; + + # these patterns are to be matched against the entire + # {host,build,target}Platform structure; they include a `parsed={}` marker so + # that `lib.meta.availableOn` can distinguish them from the patterns which + # apply only to the `parsed` field. + + platformPatterns = mapAttrs (_: p: { parsed = {}; } // p) { + isStatic = { isStatic = true; }; + }; } |