Failed to start systemd.service

In configuration.nix i have defined the following:

  systemd.timers."daily" = {
    wantedBy = [ "" ];
    timerConfig = {
      OnCalendar = "daily";
      Persistent = "true";
      Unit = "daily.service";
  };"daily" = {
    script = ''
      ${pkgs.coreutils}/bin/cp "-u /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";

However, in my system log it says failed to start daily service.

What is wrong with the definition of my service?

There’s probably more specific error output if you check the output of systemctl status daily, but I suspect the issue is that the service doesn’t have permissions on the user’s home directory, since it’s a system service and not running as your user.

EDIT: Apparently I didn’t notice the User = "sperber";. And completely missed the quoting issue. Oh well, it got solved.

1 Like

You are quoting all the arguments as one:

  ${pkgs.coreutils}/bin/cp "-u /home/sperber/.doom.d/ /home/sperber/Dokumente/Install/Linux/"


  ${pkgs.coreutils}/bin/cp -u /home/sperber/.doom.d/ /home/sperber/Dokumente/Install/Linux/

or if you really want to quote:

  ${pkgs.coreutils}/bin/cp -u "/home/sperber/.doom.d/" "/home/sperber/Dokumente/Install/Linux/"


Ah, i see. I thought i had to quote everything as in the wiki article but this was obviously just related to the echo command (stupid me).

Thank you!