NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.08k stars 14.13k forks source link

`nix flake check` fails for yarn packages #162528

Open mkhl opened 2 years ago

mkhl commented 2 years ago

Describe the bug

nix flake check fails for yarn packages

Steps To Reproduce

Steps to reproduce the behavior:

  1. git clone https://github.com/mkhl/yarn-flake-check
  2. cd yarn-flake-check
  3. nix flake check

Expected behavior

the checks succeed

Screenshots

error: a 'aarch64-linux' with features {} is required to build '/nix/store/ayfxz488paiyyaiz6sbgcdvv5r063g1a-yarn.nix.drv', but I am a 'x86_64-linux' with features {benchmark, big-parallel, kvm, nixos-test}

Additional context

none

Notify maintainers

maybe @jtojnar?

Metadata

> nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.16.11-200.fc35.x86_64, Fedora Linux, 35 (Workstation Edition)`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.6.1`
 - channels(mkhl): `"nixpkgs"`
 - nixpkgs: `/home/mkhl/.nix-defexpr/channels/nixpkgs`
Artturin commented 2 years ago

For context

yarn.nix is being built at https://github.com/NixOS/nixpkgs/blob/764670261a559e0e2e89dcce487fb9bd3ae19f9e/pkgs/development/tools/yarn2nix-moretea/yarn2nix/default.nix#L44

tomberek commented 2 years ago

Duplicate of https://github.com/NixOS/nix/issues/4265

simpler reproducer:

{
  outputs = { self, nixpkgs }: {
  checks = nixpkgs.lib.genAttrs ["x86_64-linux" "aarch64-linux"] (system:
    with nixpkgs.legacyPackages.${system}; {
      hello = import (writeText "hi" "hi");
    });
  };
}

This is due to IFD (import from derivation) being required to perform the evaluation. In some sense the error message is correct: you are unable to be certain that the flake evaluates on a aarch64-linux without performing a build on that architecture. This is a reason IFD can cause problems and should often be avoided. If you had an aarch64-linux builder in your builders option, then a build would be dispatched there and the result used to continue evaluation.

mkhl commented 2 years ago

i see, thank you

although i don't understand why the same issue isn't present for packages, just for checks