From 4f2f8faa7f7d3cba5c4eccf6077cef2235f0071a Mon Sep 17 00:00:00 2001 From: Kamil Zaripov Date: Sat, 16 Aug 2025 22:10:30 +0300 Subject: [PATCH] check-meta: Clarify error message about unsupported platform MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- pkgs/stdenv/generic/check-meta.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index c3e9469649ff..d2c7d0b2f168 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -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 [ ])} '';