Trying to get cage to run after tailscaled auth

Hello,
I am trying to build a kiosk that automatically build, based on configuration.nix. Theirs alot other stuff, but the key here is that i want to first tailscale to connect via a authkey and after that use grafana-kiosk pkgs via cage. I have successfully completed that grafana kiosk work with cage and run smooth, and tailscale does connect to tailnet based on authkey, but not on the first bootup.
First bootup:

  1. Connecting to tailnet via defined authkey.
  2. Cage wont work/fail (bc its trying to connect to a server in the tailnet).
    If i try to start the cage-tty1.service manually afterwards its successfully runs and display, but it is a script, what is the point of manual labor tho:D
    and if i reboot it, and its finish connected to the tailnet, cage work smoothly.

This is my cage config:

  services.cage = {
    enable = true;
    user = "kioskusername";
    program = ''
      ${pkgs.grafana-kiosk}/bin/grafana-kiosk \
        -URL=http://xxx.xxx.xxx.xxx:3000/ \
        -login-method=local \
        -username=usernamekiosk \
        -password=mypass \
        -kiosk-mode=full \
        -ignore-certificate-errors
    '';
    environment = {
      WLR_LIBINPUT_NO_DEVICES = "1";
    };
  };

  # Make sure cage runs after tailscale.
  systemd.services.cage-tty1 = {
    after = [ "tailscaled-autoconnect.service" "tailscaled.service" ];
    wants = [ "tailscaled-autoconnect.service" "tailscaled.service" ];
    wantedBy = [ "multi-user.target" ];
    serviceConfig = {
      Restart = "on-failure";
      RestartSec = 5;
    };
  };

And my Tailscale config looks like this:

  services.tailscale = {
    enable = true;
    authKeyFile = ./ts-auth.key;
  };

The key problem here is to make cage to run after tailscale successfully is running, and connected to the tailnet with maybe a few seconds sleep after.
Dont know with certain if i can run services.cage, and after that systemd.service.cage-tty1…

If anything is unclear please say so, and i will try to answer my best.
Every help would be appreciated :slight_smile:

Thank you in advance.