Laptop HDMI audio

Hello, today I encountered a problem on my laptop where the HDMI audio wasn’t working on the TV. Initially, it wasn’t displayed in KDE at all in HDMI-stereo mode. After a long time of fiddling with the AI, I came up with this solution.

#Sound

security.rtkit.enable = true;
services.pipewire = {
  enable = true;
  alsa.enable = true;
  alsa.support32Bit = true;
  pulse.enable = true;
  wireplumber.extraConfig = {
    “51-hdmi-default-profile”.“monitor.alsa.rules” = [
      {
      matches = [
        { “device.name” = “~alsa_card.pci-0000_00_1f.3”; }
      ];
      actions.update-props.“device.profile” = “output:hdmi-stereo”;
      }
    ];
    “52-hdmi-audio-format-fix”.“monitor.alsa.rules” = [
      {
        matches = [
          { “node.name” = “~alsa_output.pci-0000_00_1f.3.hdmi-stereo”; }
        ];
        actions.update-props.“audio.format” = “S16LE”;
        }
      ];
    };
};

I’d like to know if there’s a more correct way to fix this.
A little background information:
NixOS: 26.05
Kernel: LTS
Notebook: Thunderobot 911S Core D
It works directly through ALSA
Without 51-hdmi-default-profile default device profile after HDMI connect is analog-stereo
Without 52-hdmi-audio-format-fix no sound on TV