User service: nix: command not found

Hi! I have the following problem:
I’ve just written a user systemd service for updating home-manager:

home-manager-update = {
  enable = true;
  after = [ "home-manager-flake-update.service" ];
  wantedBy = [ "default.target" ];
  description = "Service for automatic updating home-manager";
  serviceConfig = {
    Type = "oneshot";
    ExecStart = ''${pkgs.home-manager}/bin/home-manager switch --verbose --show-trace'';
  };
};

But when I try to start it there is this error:

[jeansib@dell-3:~]$ systemctl --user restart home-manager-update.service 
Job for home-manager-update.service failed because the control process exited with error code.
See "systemctl --user status home-manager-update.service" and "journalctl --user -xeu home-manager-update.service" for details.

[jeansib@dell-3:~]$ 

In journalctl there is this line:

lut 14 12:49:43 dell-3 home-manager[2352251]: /nix/store/7jk94hz2d11wcb80bp9r6yrs73ns7wsj-home-manager-0-unstable-2025-01-02/bin/home-manager: line 209: nix: command not found

What does “nix: command not found” mean? I’m not using this command.
Best,
Miro

It means, that there is no program called nix in the units path…

As this seems to be a system managed unit (for whatever reason) use path to add required dependencies.

Thank you, but how do I do that?
And why does it need this command? I just want to use home-manager…

The HM CLI is just a shell script calling nix to build the environment before running the activation script.

Okay, that makes sense. So… do I need to set $PATH? Or what…

Okay, I’ve managed it with this:

path = [ ''${pkgs.nix}'' ];

path = [ pkgs.nix ] should do as well, no need for the stringification, as far as I remember

Yeah, that also works.