Merge pull request #37918 from Ericson2314/check-meta-golf

meta: Simplify platform check logic
This commit is contained in:
John Ericson 2018-03-28 11:38:36 -04:00 committed by GitHub
commit d5f356374c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -174,9 +174,10 @@ let
else "key '${k}' is unrecognized; expected one of: \n\t [${lib.concatMapStringsSep ", " (x: "'${x}'") (lib.attrNames metaTypes)}]";
checkMeta = meta: if shouldCheckMeta then lib.remove null (lib.mapAttrsToList checkMetaAttr meta) else [];
checkPlatform = attrs:
(!(attrs ? meta.platforms) || lib.any (lib.meta.platformMatch hostPlatform) attrs.meta.platforms) &&
(!(attrs ? meta.badPlatforms && lib.any (lib.meta.platformMatch hostPlatform) attrs.meta.badPlatforms));
checkPlatform = attrs: let
anyMatch = lib.any (lib.meta.platformMatch hostPlatform);
in anyMatch (attrs.meta.platforms or lib.platforms.all) &&
! anyMatch (attrs.meta.badPlatforms or []);
# Check if a derivation is valid, that is whether it passes checks for
# e.g brokenness or license.