nix flake check cannot be convinced to build derivations on other systems, ignores eval-system, ignores system #673

Closed
opened 2025-02-13 21:03:22 +00:00 by jade · 1 comment
Owner

Describe the bug

I want to build the flake checks for another system and remote-build it. This is, of course, Impossible.

  1. nix flake check is bugged so it doesn't use eval-system to consider what its local system is. This is probably a bug affecting all of flakes.
  2. nix flake check is using some heuristic to decide whether it can build something which is not "trying to build it and seeing if build-remote rejects it". This is wrong or at least should be possible to override to actually try to build it.

Steps To Reproduce

flake.nix:

{
  outputs = { self }: {
    packages.aarch64-linux.default = builtins.derivation {
      name = "foo";
      builder = "/bin/sh";
      system = "aarch64-linux";
      args = ["-c" ">$out"];
    };
  };
}
$ nix flake check --eval-system aarch64-linux
warning: The check omitted these incompatible systems: aarch64-linux
Use '--all-systems' to check all.

$ nix flake check -Lv --system aarch64-linux
fetching path input 'path:/Users/jade/dev/repro/lix-flake-check-other-system'
evaluating flake...
checking flake output 'packages'...
checking derivation packages.aarch64-linux.default...
derivation evaluated to /nix/store/b43vhzlxfq9wjvbrphjbx9kfdf4l1w0z-foo.drv

$ nix flake check -Lv --system aarch64-linux --builders @$HOME/.config/nix/machines
fetching path input 'path:/Users/jade/dev/repro/lix-flake-check-other-system'
evaluating flake...
checking flake output 'packages'...
checking derivation packages.aarch64-linux.default...
derivation evaluated to /nix/store/b43vhzlxfq9wjvbrphjbx9kfdf4l1w0z-foo.drv

$ nix flake check -Lv --all-systems --builders @$HOME/.config/nix/machines
fetching path input 'path:/Users/jade/dev/repro/lix-flake-check-other-system'
evaluating flake...
checking flake output 'packages'...
checking derivation packages.aarch64-linux.default...
derivation evaluated to /nix/store/b43vhzlxfq9wjvbrphjbx9kfdf4l1w0z-foo.drv

Note that at no point did it try building the derivation even though it has the ability to build it. And also, --system should basically never be used since it tricks this Nix into thinking it can locally execute things which it cannot execute. --eval-system is the correct arg in my mental model to convince it to do this, but it doesn't work.

Expected behavior

It should build the derivation or attempt to. It should use the remote builders as configured to do so.

nix --version output

nix (Lix, like Nix) 2.93.0-dev-pre20250201-a513806
System type: aarch64-darwin
Additional system types: x86_64-darwin
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /Users/jade/.config/nix/nix.conf:/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix
Data directory: /nix/store/g02blypc82xcxnmckvy0mr5789lgjy1k-lix-2.93.0-dev-pre20250201-a513806/share

Additional context

Add any other context about the problem here.

## Describe the bug I want to build the flake checks for another system and remote-build it. This is, of course, Impossible. 1. `nix flake check` is bugged so it doesn't use `eval-system` to consider what its local system is. This is probably a bug affecting all of flakes. 2. `nix flake check` is using some heuristic to decide whether it can build something which is not "trying to build it and seeing if build-remote rejects it". This is wrong or at least should be possible to override to actually try to build it. ## Steps To Reproduce flake.nix: ```nix { outputs = { self }: { packages.aarch64-linux.default = builtins.derivation { name = "foo"; builder = "/bin/sh"; system = "aarch64-linux"; args = ["-c" ">$out"]; }; }; } ``` ``` $ nix flake check --eval-system aarch64-linux warning: The check omitted these incompatible systems: aarch64-linux Use '--all-systems' to check all. $ nix flake check -Lv --system aarch64-linux fetching path input 'path:/Users/jade/dev/repro/lix-flake-check-other-system' evaluating flake... checking flake output 'packages'... checking derivation packages.aarch64-linux.default... derivation evaluated to /nix/store/b43vhzlxfq9wjvbrphjbx9kfdf4l1w0z-foo.drv $ nix flake check -Lv --system aarch64-linux --builders @$HOME/.config/nix/machines fetching path input 'path:/Users/jade/dev/repro/lix-flake-check-other-system' evaluating flake... checking flake output 'packages'... checking derivation packages.aarch64-linux.default... derivation evaluated to /nix/store/b43vhzlxfq9wjvbrphjbx9kfdf4l1w0z-foo.drv $ nix flake check -Lv --all-systems --builders @$HOME/.config/nix/machines fetching path input 'path:/Users/jade/dev/repro/lix-flake-check-other-system' evaluating flake... checking flake output 'packages'... checking derivation packages.aarch64-linux.default... derivation evaluated to /nix/store/b43vhzlxfq9wjvbrphjbx9kfdf4l1w0z-foo.drv ``` Note that at no point did it try building the derivation even though it has the ability to build it. And also, `--system` should basically never be used since it tricks this Nix into thinking it can locally execute things which it cannot execute. `--eval-system` is the correct arg in my mental model to convince it to do this, but it doesn't work. ## Expected behavior It should build the derivation or attempt to. It should use the remote builders as configured to do so. ## `nix --version` output ``` nix (Lix, like Nix) 2.93.0-dev-pre20250201-a513806 System type: aarch64-darwin Additional system types: x86_64-darwin Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /Users/jade/.config/nix/nix.conf:/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/g02blypc82xcxnmckvy0mr5789lgjy1k-lix-2.93.0-dev-pre20250201-a513806/share ``` ## Additional context Add any other context about the problem here.
Member

This issue was mentioned on Gerrit on the following CLs:

  • commit message in cl/2657 ("fix: flakes now obey --eval-system")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix/+/2657", "number": 2657, "kind": "commit message"}], "cl_meta": {"2657": {"change_title": "fix: flakes now obey --eval-system"}}} --> This issue was mentioned on Gerrit on the following CLs: * commit message in [cl/2657](https://gerrit.lix.systems/c/lix/+/2657) ("fix: flakes now obey --eval-system")
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#673
No description provided.