How to use other packages binary in systemd service configuration?

I tried to write a systemd service configuration that simply calls a ssh command by setting ExecStart in /etc/nixos/configuration.nix

ExecStart = "${pkgs.openssh}/bin/ssh .....(other parameters)."   

service starting condition were set like:

after =  [ "" ""];

but the serivce failed to start, system log shows systemd

Failed to locate executable ssh: No such file or directory.

What is the standard way of using binary from another nix package?

The ExecStart looks fine to me.

What does systemctl cat <service-name> say?

I end up solving the problem by adding path

path = [pkgs.bash pkgs.openssh];

there might be another way by just use a script instead of ExecStart, ExecStop, but I didnt test that.

1 Like