Running the following command fails with error code 255, there are no other error messages:
nix run -- 'nixpkgs#nixos-rebuild' switch -v --target-host "$host" --build-host "$host" --flake ".#$host"
Changing or removing the --build-host fixes the issue. Any idea what is causing this? What does the error code 255 actually means?
Here are the logs from the part that fails:
building '/nix/store/if5c9j6gqn9lrbsxvknbjlwgggrf93rd-backend-1.0.0.drv'...
copying path '/nix/store/myvv172x2am72534zgn9wx0qp5amq6a8-gcc-wrapper-14.3.0' from 'https://cache.nixos.org'...
downloading 'https://cache.nixos.org/nar/1y4akrnapfxv1hx1v1vmjyl36gv0savxyfsj7rnm8p7sic7vz1z1.nar.xz'...
copying path '/nix/store/3hra9mhqpw6wfn22dblr3jhcydxmsy8z-make-binary-wrapper-hook' from 'https://cache.nixos.org'...
downloading 'https://cache.nixos.org/nar/17dalm4klx46swgp4l8dj5wmss8i20alhdbxhkwb8mnfc0z2y0mm.nar.xz'...
Traceback (most recent call last):
File "/nix/store/qbrx5yh7w11zaqrr0kxdgszz0svr3421-nixos-rebuild-ng-25.11/lib/python3.13/site-packages/nixos_rebuild/__init__.py", line 352, in main
execute(sys.argv)
~~~~~~~^^^^^^^^^^
File "/nix/store/qbrx5yh7w11zaqrr0kxdgszz0svr3421-nixos-rebuild-ng-25.11/lib/python3.13/site-packages/nixos_rebuild/__init__.py", line 315, in execute
services.build_and_activate_system(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
action=action,
^^^^^^^^^^^^^^
...<6 lines>...
grouped_nix_args=grouped_nix_args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/nix/store/qbrx5yh7w11zaqrr0kxdgszz0svr3421-nixos-rebuild-ng-25.11/lib/python3.13/site-packages/nixos_rebuild/services.py", line 301, in build_and_activate_system
path_to_config = _build_system(
attr=attr,
...<5 lines>...
grouped_nix_args=grouped_nix_args,
)
File "/nix/store/qbrx5yh7w11zaqrr0kxdgszz0svr3421-nixos-rebuild-ng-25.11/lib/python3.13/site-packages/nixos_rebuild/services.py", line 163, in _build_system
path_to_config = nix.build_remote_flake(
attr,
...<5 lines>...
copy_flags=grouped_nix_args.copy_flags,
)
File "/nix/store/qbrx5yh7w11zaqrr0kxdgszz0svr3421-nixos-rebuild-ng-25.11/lib/python3.13/site-packages/nixos_rebuild/nix.py", line 166, in build_remote_flake
r = run_wrapper(
[
...<8 lines>...
stdout=PIPE,
)
File "/nix/store/qbrx5yh7w11zaqrr0kxdgszz0svr3421-nixos-rebuild-ng-25.11/lib/python3.13/site-packages/nixos_rebuild/process.py", line 137, in run_wrapper
r = subprocess.run(
run_args,
...<7 lines>...
**kwargs,
)
File "/nix/store/cdaifv92znxy5ai4sawricjl0p5b9sgf-python3-3.13.11/lib/python3.13/subprocess.py", line 577, in run
raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ssh', '-F', '/home/runner/work/server/server/ssh_config', '-o', 'ControlMaster=auto', '-o', 'ControlPath=/home/runner/work/_temp/nixos-rebuild.bqrg9ryx/ssh-%n', '-o', 'ControlPersist=60', 'gc.l', '--', 'nix', '--extra-experimental-features', "'nix-command flakes'", 'build', "'/nix/store/25phhfxi80bb06b5z447xy6gqj4fyqd0-nixos-system-unnamed-25.11.20260203.e576e3c.drv^*'", '--print-out-paths', '--no-link', '-v']' returned non-zero exit status 255.
Error: Process completed with exit code 255.
EDIT:
Using -vvv logging there are additional lines before the error is raised:
client_loop: send disconnect: Broken pipe
client_loop: send disconnect: Broken pipe
So it seems like it is a SSH issue, the connection is closed for some reason.