From 13507da345589a2de155a83ff1b79a63437c9abf Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Fri, 24 Mar 2023 00:15:57 -0700 Subject: [PATCH] check-meta.nix: fix self-contradictory error messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. ``` --- pkgs/stdenv/generic/check-meta.nix | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index 1118e6837f294..7f317c787b04e 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -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"; }