NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.43k stars 1.5k forks source link

`nix build --max-jobs 0 ` with a remote store fails contrary to the documentation #7101

Open kjeremy opened 2 years ago

kjeremy commented 2 years ago

Describe the bug

The manual says

To build only on remote builders and disable building on the local machine, you can use the option --max-jobs 0.

However nix build --eval-store auto --store ssh-ng://... --max-jobs 0 nixpkgs#hello fails with

error: unable to start any build; either increase '--max-jobs' or enable remote builds. https://nixos.org/manual/nix/stable/advanced-topics/distributed-builds.html

Steps To Reproduce

  1. nix build --eval-store auto --store ssh-ng://... --max-jobs 0 .#flake_target

Expected behavior

The build executed on the remote.

nix-env (Nix) 2.11.0

knedlsepp commented 2 years ago

The manual mentions you'll have to either specify --builders "...." or configure /etc/nix/machines.

kjeremy commented 2 years ago

What's the difference between using builders and --store? I thought that specifying --store would be a remote build.

L-as commented 2 years ago

AFAIK, -j0 is 0 jobs on your own store, which you specify with --store, so this is working as intended.

nrdxp commented 1 year ago

@kjeremy, --store specifies a different and newer kind of remote build. Since the entire build process takes place on the remote machine without copying closures back and forth, it is much more efficient. It run basically as if you had sshed to the machine and run the build there directly.

It works completely differently than the old remote build protocol, and max-jobs 0 wouldn't be necessary since the local store is not involved at all.

divanorama commented 1 year ago
$ nix-build ... -j 0 --builders "ssh://abc def" -vvvvv
...
starting build hook '/nix/store/hcs9kmk8hsqhd4nkqmlwkcz1iaklp8al-nix-2.11.1/bin/nix __build-remote'
got 0 remote builders
hook reply is 'decline-permanently'
killing process 84827
...
$ nix --version
nix (Nix) 2.11.1
divanorama commented 1 year ago

Adding the user to trustedUsers seems to be doing the trick in my case Quite confusing that neither error message nor https://nixos.org/manual/nix/stable/advanced-topics/distributed-builds.html mentions that. But https://nixos.wiki/wiki/Distributed_build does. Added it via nix.settings.trusted-users = [ "username" ]; in configuration.nix