Can't pair bluetooth audio devices - org.bluez.Error.AuthenticationFailed

I’m trying to pair audio devices (bt earphones, bt speaker) with my Thinkpad P14s gen 2 (NixOS 23.11). Every attempt fails with:

[bluetooth]# pair C0:(...):4F 
Attempting to pair with C0:(...):4F
[CHG] Device C0:(...):4F Connected: yes
Failed to pair: org.bluez.Error.AuthenticationFailed
[CHG] Device C0:(...):4F Connected: no

For context:
I remember it used to work in the past. I am not sure at which moment it stopped.
Also, other devices (like mouse) have no trouble pairing. The sound itself also works.

Here is what I already tried:
[on other OS]

  • pairing with another PC (Ubuntu) - works fine,
  • pairing on same PC (Ubuntu, Windows 11) - works fine;

[on NixOS]

  • pairing via external bluetooth USB dongle - works fine,
  • pairing via builtin bluetooth adapter - does not work,
  • pairing using bluetoothctl and graphical blueman-manager - neither does work,
  • restart services - does not work,
  • reset all known bluetooth devices - does not work,
  • reinstall NixOS - does not work,
  • use default NixOS graphical (with pulseaudio, pipewire) and minimal configuration (with bluetooth and pulseaudio) - neither does work;

Please help

As a follow-up: I installed NixOS on another pc, and I was able to connect my earphones there.

After 20 long hours I mamaged to fix it (at least to some extent). Since there is very little info on this specific topic (and usually the solutions boil down to a trivial device reset) I want to share what helped me.

I found a simmilar topic, and followed a proposed link. At that moment I had a dual boot NixOS/Win11. I managed to pair my earphones on the latter, so I copied the connection key from Windows and entered into info files in Linux, as described in the wiki. Then - after a reboot - I managed to pair and connect my earphones.

I do not dare to guess the reasons for this particular error, but I hope it helps someone else!