Adding a timeout to boot.systemd.initrd

Hello, I would like my laptop to power off if systemd stage-1 init has not completed within a certain time.

The reason I would like this is so that an unplugged and unattended laptop that has been accidentally rebooted will not just sit there draining its battery waiting for some user to unlock the LUKS volumes. Or perhaps the laptop has been somehow powered on with the lid closed, while inside a bag, or something like that. It could happen.

Perhaps the easiest solution would be to add something like:

{
  boot.initrd.systemd.timers.my-timeout = {
    wantedBy = [ "initrd.target" ];
    timerConfig = {
      OnBootSec = "2min";
      Unit = "shutdown.target";
    };
  };
}

Has anyone tried something like this before and would like to share notes?

Pretty sure the LUKS timeout is 90s so you’d want to reduce this timeout, maybe. Though I don’t know much about the boot process tbh