"lftp: command not found" when running duply in a systemd.service

I want to use duply (terminal front-end for duplicity) to back up my files in a systemd.service.

The Nixos package had an error that didn’t include lftp but @symphorien and @bjornfor fixed it in November and i can run duply from the terminal just fine.

However, when trying to run it in a systemd.service i still get lftp: command not found.

I defined the service as follows:

  systemd.timers."daily" = {
    wantedBy = [ "timers.target" ];
    timerConfig = {
      OnCalendar = "daily";
      Persistent = "true";
      Unit = "daily.service";
    };
  };

  systemd.services."daily" = {
    script = ''
      ${pkgs.coreutils}/bin/cp -u -r /home/sperber/.doom.d/ /home/sperber/Dokumente/Install/Linux/
      ${pkgs.rsync}/bin/rsync -r -t -p --delete -s --exclude hardware-configuration.nix /etc/nixos/ /home/sperber/Dokumente/Install/Linux/Nixos
      ${pkgs.rsnapshot}/bin/rsnapshot -c /home/sperber/Dokumente/Install/Linux/rsnapshot.conf daily

      ${pkgs.duply}/bin/duply /home/sperber/.duply/manitu backup+purgeAuto --force

      # ${pkgs.coreutils}/bin/cp -u -r /srv/ /home/sperber/Dokumente/Programmieren/

    '';
    serviceConfig = {
      Type = "oneshot";
      User = "sperber";

      ### duply benötigt lftp im PATH
      path = [ pkgs.lftp ];
    };
  };

I thought that lftp is not in PATH for sytemd so i tried to add it via

    serviceConfig = {
      Type = "oneshot";
      User = "sperber";

      ### duply benötigt lftp im PATH
      **path = [ pkgs.lftp ];**
    };
  };

and

  systemd.user.extraConfig = ''
    DefaultEnvironment="PATH=/run/current-system/sw/bin"
  '';

but i still get lftp: command not found.

Is this a problem with the Nixos package of duply or do i have to add lftp to the PATH for systemd differently?

1 Like

systemd.services.foo.path, not systemd.services.foo.serviceConfig.path.

2 Likes

That works, thank you!

1 Like