Using a non NixOS, system wide installed Nix as a remote builder

I have an office PC with Nix installed system wide on it, without NixOS. I can connect to it remotely using ssh reverse tunneling. I managed to setup all the ssh keys necessary such that I can ssh to that machine both as a regular user and as root without a password prompt and only an ssh key. However, now I get:

$ sudo ssh office 'nix-store --help'
bash: line 1: nix-store: command not found

But OTH, If I run:

$ sudo ssh office
...
# nix-store --help

It doesn’t print an error.

What’s the best way to make nix commands available in that bash interpreter? The “Non standard Nix installations” section in the WiKi doesn’t exactly fits my case I think - because it is a system wide installation, but not a NixOS machine…

1 Like

The solution was adding to sshd_config:

SetEnv PATH=/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2 Likes

Just wanted to add that this and other things are documented at the wiki https://wiki.nixos.org/wiki/Distributed_build

1 Like