Fix for Wine Audio Crackling on NixOS (Pipewire Quantum)

This guide addresses a common issue with audio crackling and popping in Wine/Proton games on NixOS. The cause is usually Pipewire’s audio buffer size being too small under load.

The solution is to force a larger, more stable minimum quantum size. This introduces a tiny amount of latency (generally unnoticeable in games) but prevents the audio buffer from underrunning.

Here’s the fix:

# /etc/nixos/configuration.nix

{
  # ... other stuff ...

  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;

    extraConfig = {
      pipewire."99-custom-quantum.conf" = {
        "context.properties" = {
          "default.clock.min-quantum" = 1024;
          "default.clock.max-quantum" = 8192;
        };
      };
      pipewire-pulse."99-custom-quantum.conf" = {
        "context.properties" = {
          "pulse.min.quantum" = "1024/48000";
          "pulse.default.quantum" = "1024/48000";
          "pulse.max.quantum" = "8192/48000";
        };
      };
    };
  };

  # ... other stuff ...
}

Hope this saves someone else the headache! Cheers.