Wakeup-sleep loop on Framework12 (immediately sleep on wakeup)

Does anyone have experience with Framework12 (I have niri + DankMaterialShell as DE) and sleep/wakeup?

Currently, I can sleep by closing the lid or pressing the power button, but only wakeup with the power button. However, as soon as it wakes up it immediately goes back to sleep, and the only thing I can do is hard reboot by long (10s) press the power button.

No matter what I do in services.logind.settings.Login or systemd.sleep I cannot get rid of this issue, the behaviour remains the same.

The log during trying to wake up by power button:

Dec 16 14:20:35 jfw12 systemd-sleep[2920]: System returned from sleep operation 'suspend'.
Dec 16 14:20:35 jfw12 bluetoothd[906]: Controller resume with wake event 0x0
Dec 16 14:20:35 jfw12 kernel: PM: suspend exit
Dec 16 14:20:35 jfw12 systemd[1]: user.slice: Unit now thawed.
Dec 16 14:20:35 jfw12 systemd[1]: user-992.slice: Unit now thawed.
Dec 16 14:20:35 jfw12 systemd[1]: user-1000.slice: Unit now thawed.
Dec 16 14:20:35 jfw12 systemd-sleep[2920]: Successfully thawed unit 'user.slice'.
Dec 16 14:20:35 jfw12 systemd[1]: session-3.scope: Unit now thawed.
Dec 16 14:20:35 jfw12 systemd[1]: user@1000.service: Unit now thawed.
Dec 16 14:20:35 jfw12 systemd[1]: systemd-suspend.service: Deactivated successfully.
Dec 16 14:20:35 jfw12 systemd[1]: Finished System Suspend.
Dec 16 14:20:35 jfw12 systemd[1]: Stopped target Sleep.
Dec 16 14:20:35 jfw12 systemd[1]: Reached target Suspend.
Dec 16 14:20:35 jfw12 systemd[1]: Starting Post-Resume Actions...
Dec 16 14:20:35 jfw12 systemd[1]: Stopped target Suspend.
Dec 16 14:20:35 jfw12 systemd-logind[941]: Operation 'suspend' finished.
Dec 16 14:20:35 jfw12 systemd-resolved[578]: Closing all remaining TCP connections.
Dec 16 14:20:35 jfw12 systemd-resolved[578]: Resetting learnt feature levels on all servers.
Dec 16 14:20:35 jfw12 ModemManager[1385]: <msg> [base-manager] couldn't check support for device '/sys/devices/pci0000>
Dec 16 14:20:35 jfw12 ModemManager[1385]: <msg> [sleep-monitor-systemd] system is resuming
Dec 16 14:20:35 jfw12 systemd-logind[941]: The system will suspend now!
Dec 16 14:20:35 jfw12 kdeconnectd[2042]: Error sending UDP packet: QAbstractSocket::NetworkError
Dec 16 14:20:35 jfw12 systemd[1]: post-resume.service: Deactivated successfully.
Dec 16 14:20:35 jfw12 systemd[1]: Finished Post-Resume Actions.
Dec 16 14:20:35 jfw12 ModemManager[1385]: <msg> [sleep-monitor-systemd] system is about to suspend
Dec 16 14:20:35 jfw12 systemd[1]: Reached target Post-Resume Actions.
Dec 16 14:20:35 jfw12 systemd[1]: Stopped target Post-Resume Actions.
Dec 16 14:20:35 jfw12 kernel: ucsi_acpi USBC000:00: unknown error 0
Dec 16 14:20:35 jfw12 kernel: ucsi_acpi USBC000:00: con4: failed to register partner alt modes (-5)
Dec 16 14:20:35 jfw12 kernel: ucsi_acpi USBC000:00: unknown error 256
Dec 16 14:20:35 jfw12 kernel: ucsi_acpi USBC000:00: con2: failed to register partner alt modes (-5)
Dec 16 14:20:35 jfw12 kernel: iwlwifi 0000:00:14.3: WFPM_UMAC_PD_NOTIFICATION: 0x20
Dec 16 14:20:35 jfw12 kernel: iwlwifi 0000:00:14.3: WFPM_LMAC2_PD_NOTIFICATION: 0x1f
Dec 16 14:20:35 jfw12 kernel: iwlwifi 0000:00:14.3: WFPM_AUTH_KEY_0: 0x90
Dec 16 14:20:35 jfw12 kernel: iwlwifi 0000:00:14.3: CNVI_SCU_SEQ_DATA_DW9: 0x0
Dec 16 14:20:35 jfw12 kernel: iwlwifi 0000:00:14.3: RFIm is deactivated, reason = 4
Dec 16 14:20:35 jfw12 kernel: ucsi_acpi USBC000:00: unknown error 256
Dec 16 14:20:35 jfw12 kernel: ucsi_acpi USBC000:00: GET_CABLE_PROPERTY failed (-5)
Dec 16 14:20:35 jfw12 kernel: ucsi_acpi USBC000:00: unknown error 0
Dec 16 14:20:35 jfw12 kernel: ucsi_acpi USBC000:00: GET_CABLE_PROPERTY failed (-5)
Dec 16 14:20:35 jfw12 systemd-networkd[752]: wlp0s20f3: Link UP
Dec 16 14:20:35 jfw12 kdeconnectd[2042]: Failed to open any MDNS client sockets
Dec 16 14:20:35 jfw12 kdeconnectd[2042]: Failed to open any MDNS server sockets
Dec 16 14:20:35 jfw12 systemd-networkd[752]: wlp0s20f3: Link DOWN
Dec 16 14:20:35 jfw12 systemd[1]: Starting Pre-Sleep Actions...
Dec 16 14:20:35 jfw12 systemd[1]: pre-sleep.service: Deactivated successfully.
Dec 16 14:20:35 jfw12 systemd[1]: Finished Pre-Sleep Actions.
Dec 16 14:20:35 jfw12 systemd[1]: Reached target Sleep.
Dec 16 14:20:35 jfw12 systemd[1]: Starting System Suspend...
Dec 16 14:20:35 jfw12 systemd[1]: user.slice: Unit now frozen.
Dec 16 14:20:35 jfw12 systemd[1]: user-992.slice: Unit now frozen-by-parent.
Dec 16 14:20:35 jfw12 systemd[1]: user-1000.slice: Unit now frozen-by-parent.
Dec 16 14:20:35 jfw12 systemd-sleep[2941]: Successfully froze unit 'user.slice'.
Dec 16 14:20:35 jfw12 systemd[1]: session-3.scope: Unit now frozen-by-parent.
Dec 16 14:20:35 jfw12 systemd[1]: user@1000.service: Unit now frozen-by-parent.
Dec 16 14:20:35 jfw12 systemd-sleep[2941]: Performing sleep operation 'suspend'...
Dec 16 14:20:35 jfw12 kernel: PM: suspend entry (deep)

I now have

  systemd = {
    sleep.extraConfig = ''
      AllowSuspendThenHibernate=no
      HibernateDelaySec=30m
    '';
  };

and

    logind = {
      settings.Login = {
        # IdleAction = "ignore";
        # IdleActionSec = "0";
        /*
        NOTE: messes with resume (suspend loop because press evaluated twice?)
        HandlePowerKey = "hibernate";
        HandlePowerKeyLongPress = "poweroff";
        */
        /*
           HandleLidSwitch =
          if (builtins.any (s: builtins.match ".*sleep_default=deep.*" s != null) config.boot.kernelParams)
          then "suspend"
          else "suspend-then-hibernate";
        HandleLidSwitchExternalPower = "lock";
        */
        # lidSwitchIgnoreInhibited = true;
        SleepOperation = "suspend";
        KillUserProcesses = true;
      };
    };

but basically nothing I change/enable/disable has a noticeable effect.

Any ideas?

Solved:
programs.niri.settings.input.power-key-handling.enable (from the niri flake) defaults to true and re-processes the button press for wakeup which causes immediate sleep.
Setting this attribute to false fixes the issue. Still can’t wakeup by any other action though, not sure why.

I don’t have your exact laptop, but the controls for what can cause a wakeup are usually hiding in BIOS settings.