From b46c97e1dc27f78bcc1c72e9999e07c9b49ace6e Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Thu, 23 Mar 2023 23:47:11 +0200 Subject: stdenv: generalise showPlatforms --- pkgs/stdenv/generic/check-meta.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'pkgs/stdenv/generic') diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index 4c218b24d11..1118e6837f2 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -113,7 +113,9 @@ let showLicenseOrSourceType = value: toString (map (v: v.shortName or "unknown") (lib.lists.toList value)); showLicense = showLicenseOrSourceType; - showPlatforms = value: lib.optionalString (builtins.isList value && builtins.all builtins.isString value) (toString value); + 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»"; @@ -369,7 +371,7 @@ 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.meta.platforms}` but not on requested ‘${hostPlatform.system}’"; } + { valid = "no"; reason = "unsupported"; errormsg = "is only supported on `${showPlatforms attrs}` but not on requested ‘${hostPlatform.system}’"; } else if !(hasAllowedInsecure attrs) then { valid = "no"; reason = "insecure"; errormsg = "is marked as insecure"; } -- cgit 1.4.1 From 13507da345589a2de155a83ff1b79a63437c9abf Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Fri, 24 Mar 2023 00:15:57 -0700 Subject: 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(-) (limited to 'pkgs/stdenv/generic') diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index 1118e6837f2..7f317c787b0 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"; } -- cgit 1.4.1