Swayidle systemd service not working

I have written a systemd service to start swayidle automatically (below), but it doesn’t work properly, and when i ask journalctl the error comes up as saying that the service was restarted too early, and failed to start the service. I have tried changing the target, switching it toa user service, adding user to the serviceConfig, and changing the Restart condition, nothing seems to work. Any ideas on what’s wrong?

    systemd.user.services.swayidle = let
      swaylock = "${pkgs.swaylock}/bin/swaylock -fF";
      hyprctl = "${pkgs.hyprland}/bin/hyprctl";
      swayidle = "${pkgs.swayidle}/bin/swayidle -w";
    in {
      enable = true;
      description = "Idle manager for Wayland";
      wantedBy = [ "default.target" ];
      serviceConfig = {
        Type = "simple";
        User = config.user.name;
        Restart = "on-failure";
        Environment = [ "PATH=${makeBinPath [pkgs.dash]}" ];
        ExecStart = ''
          ${swayidle} \
                      timout 300 '${swaylock}' \
                      timout 310 '${hyprctl} dispatch dpms off' \
                             resume '${hyprctl} dispatch dpms on' \
                      before-sleep '${swaylock}'
        '';

edit: I should also note that the command in ExecStart works when I run it from a terminal, so it can’t be that either