check-meta.nix: fix self-contradictory error messages

See https://github.com/NixOS/nixpkgs/pull/222792#pullrequestreview-1356114111

You can't just `lib.filter _ lib.systems.all` -- that throws away
important information, leading to nixpkgs disagreeing with itself
like this:

```
$ NIXPKGS_ALLOW_BROKEN=1 nix-instantiate . -A pkgsStatic.systemd
error: Package ‘systemd-252.5’ in ... is only supported on ... x86_64-linux but not on requested x86_64-linux, refusing to evaluate.
```

After:

```
$ NIXPKGS_ALLOW_BROKEN=1 nix-instantiate . -A pkgsStatic.systemd
error: Package ‘systemd-252.5’ in ... is not available on the requested hostPlatform:
         hostPlatform.config = "x86_64-unknown-linux-musl"
         package.meta.platforms = [
           "aarch64-linux"
           "armv5tel-linux"
           "armv6l-linux"
           "armv7a-linux"
           "armv7l-linux"
           "i686-linux"
           "m68k-linux"
           "microblaze-linux"
           "microblazeel-linux"
           "mipsel-linux"
           "mips64el-linux"
           "powerpc64-linux"
           "powerpc64le-linux"
           "riscv32-linux"
           "riscv64-linux"
           "s390-linux"
           "s390x-linux"
           "x86_64-linux"
         ]
         package.meta.badPlatforms = [
           {
             isStatic = true;
             parsed = { };
           }
         ]
       , refusing to evaluate.
```
This commit is contained in:
Adam Joseph 2023-03-24 00:15:57 -07:00
parent 5a9b9e620d
commit 13507da345

View file

@ -113,9 +113,6 @@ let
showLicenseOrSourceType = value: toString (map (v: v.shortName or "unknown") (lib.lists.toList value));
showLicense = showLicenseOrSourceType;
showPlatforms = attrs: toString (builtins.filter
(system: lib.meta.availableOn (lib.systems.elaborate { inherit system; }) attrs)
lib.platforms.all);
showSourceType = showLicenseOrSourceType;
pos_str = meta: meta.position or "«unknown-file»";
@ -371,7 +368,18 @@ let
else if !allowBroken && attrs.meta.broken or false then
{ valid = "no"; reason = "broken"; errormsg = "is marked as broken"; }
else if !allowUnsupportedSystem && hasUnsupportedPlatform attrs then
{ valid = "no"; reason = "unsupported"; errormsg = "is only supported on `${showPlatforms attrs}` but not on requested ${hostPlatform.system}"; }
let toPretty = lib.generators.toPretty {
allowPrettyValues = true;
indent = " ";
};
in { valid = "no"; reason = "unsupported";
errormsg = ''
is not available on the requested hostPlatform:
hostPlatform.config = "${hostPlatform.config}"
package.meta.platforms = ${toPretty (attrs.meta.platforms or [])}
package.meta.badPlatforms = ${toPretty (attrs.meta.badPlatforms or [])}
'';
}
else if !(hasAllowedInsecure attrs) then
{ valid = "no"; reason = "insecure"; errormsg = "is marked as insecure"; }