NixOS / nix

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

`nix build`'s `--rebuild` flag does not work in conjunction with `--max-jobs 0` #8789

Open someplaceguy opened 1 year ago

someplaceguy commented 1 year ago

Describe the bug

When I run nix build --rebuild ..., an already-built package gets rebuilt, as expected (locally).

However, when I run nix build --rebuild --max-jobs 0 ..., which AFAIK is the way to force a package to be rebuilt on a remote builder, the package does not get rebuilt.

The remote builder seems to be working fine for me otherwise, although I've always been using nix-build so far, not nix build.

Before trying to rebuild, I've made sure to build the package on the remote builder using nix build --max-jobs 0 ... (i.e. without the --rebuild flag).

Steps To Reproduce

Here's the full command line I am using:

$ nix build --extra-experimental-features flakes --no-link --print-build-logs git+file:/backup/nix/nixpkgs#age -vvvvvvvv --rebuild --max-jobs 0

Expected behavior

I expected the package to be rebuilt.

nix-env --version output

nix-env (Nix) 2.13.3

Additional context

Here's the output of the command, after nix build connects to the remote builder over ssh and ssh successfully authenticates:

(...)
age> Authenticated to mainserv ([201:d78c:e546:b9b0:6743:5d4f:f9c0:38ae]:60) using "publickey".
age> debug1: channel 0: new session [client-session] (inactive timeout: 0)
age> debug1: Requesting no-more-sessions@openssh.com
age> debug1: Entering interactive session.
age> debug1: pledge: network
age> debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
age> debug1: Remote: /etc/ssh/authorized_keys.d/root:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
waiting for children
building of '/nix/store/xfqy1r0zdibzfl8wx1maxr5qgcmy00bp-age-1.1.1.drv!out' from .drv file: read 131 bytes
age> debug1: Remote: /etc/ssh/authorized_keys.d/root:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
age> debug1: Sending command: nix-store --serve --write
age> debug1: pledge: fork
waiting for children
building of '/nix/store/xfqy1r0zdibzfl8wx1maxr5qgcmy00bp-age-1.1.1.drv!out' from .drv file: read 92 bytes
copying 0 paths...
waiting for children
building of '/nix/store/xfqy1r0zdibzfl8wx1maxr5qgcmy00bp-age-1.1.1.drv!out' from .drv file: read 157 bytes
starting pool of 3 threads
waiting for children
building of '/nix/store/xfqy1r0zdibzfl8wx1maxr5qgcmy00bp-age-1.1.1.drv!out' from .drv file: read 64 bytes
killing process 1782044
waiting for children
building of '/nix/store/xfqy1r0zdibzfl8wx1maxr5qgcmy00bp-age-1.1.1.drv!out' from .drv file: got EOF
building of '/nix/store/xfqy1r0zdibzfl8wx1maxr5qgcmy00bp-age-1.1.1.drv!out' from .drv file: woken up
building of '/nix/store/xfqy1r0zdibzfl8wx1maxr5qgcmy00bp-age-1.1.1.drv!out' from .drv file: build done
killing process 1782042
builder process for '/nix/store/xfqy1r0zdibzfl8wx1maxr5qgcmy00bp-age-1.1.1.drv' finished
lock released on '/nix/store/j88hc3i2yl2ga992sawlvdhfhq23hw3m-age-1.1.1.lock'
building of '/nix/store/xfqy1r0zdibzfl8wx1maxr5qgcmy00bp-age-1.1.1.drv!out' from .drv file: done
building of '/nix/store/xfqy1r0zdibzfl8wx1maxr5qgcmy00bp-age-1.1.1.drv!out' from .drv file: goal destroyed

$ 
someplaceguy commented 1 year ago

When using the ssh-ng protocol instead of ssh, the output is slightly different but the result is the same:

Authenticated to mainserv ([201:d78c:e546:b9b0:6743:5d4f:f9c0:38ae]:60) using "publickey".
debug1: channel 0: new session [client-session] (inactive timeout: 0)
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
[0/1 built] connecting to 'ssh-ng://root@mainserv'debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: Remote: /etc/ssh/authorized_keys.d/root:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Remote: /etc/ssh/authorized_keys.d/root:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
[0/1 built] connecting to 'ssh-ng://root@mainserv'debug1: Sending command: nix-daemon --stdio
debug1: pledge: fork
hook reply is 'accept'
checking outputs of '/nix/store/kqbh86559rfsnsqbar2fynfg32h76xvw-age-1.1.1.drv' on 'ssh-ng://root@mainserv'...
waiting for children
building of '/nix/store/kqbh86559rfsnsqbar2fynfg32h76xvw-age-1.1.1.drv!out' from .drv file: read 298 bytes
waiting for the upload lock to 'ssh-ng://root@mainserv'...
copying dependencies to 'ssh-ng://root@mainserv'...
waiting for children
building of '/nix/store/kqbh86559rfsnsqbar2fynfg32h76xvw-age-1.1.1.drv!out' from .drv file: read 92 bytes
copying 0 paths...
waiting for children
building of '/nix/store/kqbh86559rfsnsqbar2fynfg32h76xvw-age-1.1.1.drv!out' from .drv file: read 90 bytes
waiting for children
building of '/nix/store/kqbh86559rfsnsqbar2fynfg32h76xvw-age-1.1.1.drv!out' from .drv file: read 156 bytes
waiting for children
building of '/nix/store/kqbh86559rfsnsqbar2fynfg32h76xvw-age-1.1.1.drv!out' from .drv file: read 987 bytes
querying info about missing paths...
waiting for children
building of '/nix/store/kqbh86559rfsnsqbar2fynfg32h76xvw-age-1.1.1.drv!out' from .drv file: read 64 bytes
killing process 1821147
waiting for children
building of '/nix/store/kqbh86559rfsnsqbar2fynfg32h76xvw-age-1.1.1.drv!out' from .drv file: got EOF
building of '/nix/store/kqbh86559rfsnsqbar2fynfg32h76xvw-age-1.1.1.drv!out' from .drv file: woken up
building of '/nix/store/kqbh86559rfsnsqbar2fynfg32h76xvw-age-1.1.1.drv!out' from .drv file: build done
killing process 1821145
builder process for '/nix/store/kqbh86559rfsnsqbar2fynfg32h76xvw-age-1.1.1.drv' finished
lock released on '/nix/store/nm0v8px7kil19cdmp7prmbrcmrzdrr76-age-1.1.1.lock'
building of '/nix/store/kqbh86559rfsnsqbar2fynfg32h76xvw-age-1.1.1.drv!out' from .drv file: done
building of '/nix/store/kqbh86559rfsnsqbar2fynfg32h76xvw-age-1.1.1.drv!out' from .drv file: goal destroyed

$