@@ -1,7 +1,7 @@
11# Checks derivation meta and attrs for problems (like brokenness,
22# licenses, etc).
33
4−{ lib, config, system, meta }:
4+{ lib, config, hostPlatform, meta }:
55
66let
77 # See discussion at https://github.com/NixOS/nixpkgs/pull/25304#issuecomment-298385426
@@ -144,7 +144,7 @@ let
144144 license = either (listOf lib.types.attrs) (either lib.types.attrs str);
145145 maintainers = listOf str;
146146 priority = int;
147− platforms = listOf str;
147+ platforms = listOf (either str lib.systems.parsed.types.system);
148148 hydraPlatforms = listOf str;
149149 broken = bool;
150150
@@ -173,6 +173,11 @@ let
173173 else "key '${k}' is unrecognized; expected one of: \n\t [${lib.concatMapStringsSep ", " (x: "'${x}'") (lib.attrNames metaTypes)}]";
174174 checkMeta = meta: if shouldCheckMeta then lib.remove null (lib.mapAttrsToList checkMetaAttr meta) else [];
175175
176+ checkPlatform = attrs: let
177+ raw = attrs.meta.platforms;
178+ uniform = map (x: if builtins.isString x then { system = x; } else { parsed = x; }) raw;
179+ in lib.any (pat: lib.matchAttrs pat hostPlatform) uniform;
180+
176181 # Check if a derivation is valid, that is whether it passes checks for
177182 # e.g brokenness or license.
178183 #
@@ -186,8 +191,8 @@ let
186191 { valid = false; reason = "blacklisted"; errormsg = "has a blacklisted license (‘${showLicense attrs.meta.license}’)"; }
187192 else if !allowBroken && attrs.meta.broken or false then
188193 { valid = false; reason = "broken"; errormsg = "is marked as broken"; }
189− else if !allowUnsupportedSystem && !allowBroken && attrs.meta.platforms or null != null && !lib.lists.elem system attrs.meta.platforms then
190− { valid = false; reason = "broken"; errormsg = "is not supported on ‘${system}’"; }
194+ else if !allowUnsupportedSystem && !allowBroken && attrs.meta.platforms or null != null && !(checkPlatform attrs) then
195+ { valid = false; reason = "broken"; errormsg = "is not supported on ‘${hostPlatform.config}’"; }
191196 else if !(hasAllowedInsecure attrs) then
192197 { valid = false; reason = "insecure"; errormsg = "is marked as insecure"; }
193198 else let res = checkMeta (attrs.meta or {}); in if res != [] then