summary refs log tree commit diff
path: root/pkgs/stdenv/generic
diff options
context:
space:
mode:
authorAdam Joseph <adam@westernsemico.com>2023-03-24 00:15:57 -0700
committerAdam Joseph <adam@westernsemico.com>2023-03-24 00:15:57 -0700
commit13507da345589a2de155a83ff1b79a63437c9abf (patch)
treed53e3d8631e2018edf6dd8410c3e181a87a1a6bd /pkgs/stdenv/generic
parent5a9b9e620da1419613835a9268f0dd6a5ccf62e7 (diff)
downloadnixpkgs-13507da345589a2de155a83ff1b79a63437c9abf.tar
nixpkgs-13507da345589a2de155a83ff1b79a63437c9abf.tar.gz
nixpkgs-13507da345589a2de155a83ff1b79a63437c9abf.tar.bz2
nixpkgs-13507da345589a2de155a83ff1b79a63437c9abf.tar.lz
nixpkgs-13507da345589a2de155a83ff1b79a63437c9abf.tar.xz
nixpkgs-13507da345589a2de155a83ff1b79a63437c9abf.tar.zst
nixpkgs-13507da345589a2de155a83ff1b79a63437c9abf.zip
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.
```
Diffstat (limited to 'pkgs/stdenv/generic')
-rw-r--r--pkgs/stdenv/generic/check-meta.nix16
1 files changed, 12 insertions, 4 deletions
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"; }