check-meta: Clarify error message about unsupported platform
Right now if you are specifying supported platforms using meta.platforms
you can get a bit misleading error message:
$ nix-build default.nix
error:
… in the condition of the assert statement
at /nix/store/53pzmaza73pl8q2yl1q62h7ncx21nxc1-source/lib/customisation.nix:419:9:
418| drvPath =
419| assert condition;
| ^
420| drv.drvPath;
… while evaluating the attribute 'handled'
at /nix/store/53pzmaza73pl8q2yl1q62h7ncx21nxc1-source/pkgs/stdenv/generic/check-meta.nix:643:9:
642| # or, alternatively, just output a warning message.
643| handled = (
| ^
644| if valid == "yes" then
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: Package ‘test’ in /home/kamil/code/test/default.nix:3 is not available on the requested hostPlatform:
hostPlatform.config = "aarch64-none-elf"
package.meta.platforms = [
"aarch64-none-elf"
]
package.meta.badPlatforms = [ ]
, refusing to evaluate.
a) To temporarily allow packages that are unsupported for this system, you can use an environment variable
for a single invocation of the nix tools.
$ export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1
Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
then pass `--impure` in order to allow use of environment variables.
b) For `nixos-rebuild` you can set
{ nixpkgs.config.allowUnsupportedSystem = true; }
in configuration.nix to override this.
c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
{ allowUnsupportedSystem = true; }
to ~/.config/nixpkgs/config.nix.
It is not clear why this derivation cannot be built for
"aarch64-none-elf" target since error message list this triplet in
package.meta.platforms right below hostPlatform.config. The issue is that
package.meta.platforms is checked against hostPlatform.system field, not
hostPlatform.config field:
https://github.com/NixOS/nixpkgs/blob/b134951a4c9f3c995fd7be05f3243f8ecd65d798/lib/meta.nix#L103
And in this case hostPlatform.system is "aarch64-none" while
hostPlatform.config is "aarch64-none-efi".
I think that it would be better to print hostPlatform.system in error
message.
This commit is contained in:
@@ -534,7 +534,7 @@ let
|
||||
reason = "unsupported";
|
||||
errormsg = ''
|
||||
is not available on the requested hostPlatform:
|
||||
hostPlatform.config = "${hostPlatform.config}"
|
||||
hostPlatform.system = "${hostPlatform.system}"
|
||||
package.meta.platforms = ${toPretty' (attrs.meta.platforms or [ ])}
|
||||
package.meta.badPlatforms = ${toPretty' (attrs.meta.badPlatforms or [ ])}
|
||||
'';
|
||||
|
||||
Reference in New Issue
Block a user