NixOS / nix

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

PATH setup does not happen for ssh with command #8061

Open ahihi opened 1 year ago

ahihi commented 1 year ago

Describe the bug

when ssh-ing into a macOS system with Nix installed, with a remote command given to ssh, the resulting shell's PATH does not include Nix directories.

Steps To Reproduce

  1. install multi-user Nix on macOS (10.14.6 in my case)
  2. enable remote login (ssh) on the system
  3. connect to the system with ssh <host> 'echo $PATH'
  4. see Nix directories missing

Expected behavior

i expected PATH to include the Nix directories.

nix-env --version output

nix-env (Nix) 2.11.1

Additional context

this breaks any attempt to call Nix-installed executables in the ssh remote command, for example mosh does not work due to not being able to find mosh-server.

https://github.com/NixOS/nix/issues/2587 seems related.

abathur commented 1 year ago

@Hoverbear wonder if this is related to https://github.com/DeterminateSystems/nix-installer/issues/327#issuecomment-1470383194 or just ~adjacent?

Hoverbear commented 1 year ago

This sounds similar! Here are two valid workarounds: https://github.com/DeterminateSystems/nix-installer#using-macos-remote-ssh-builders-nix-binaries-are-not-on-path

balsoft commented 1 year ago

See also https://github.com/NixOS/nix/pull/6628 . It got stuck in review, as I can't produce good enough code that implements it.