{ config, lib, pkgs, ... }:
let
  bluetoothSupport = config.sbruder.full;
in
lib.mkIf config.sbruder.gui.enable {
  sound.enable = true;
  hardware.pulseaudio = {
    enable = true;
    daemon.config = {
      "default-sample-format" = "s16le";
      "default-sample-rate" = "48000";
      "alternate-sample-rate" = "44100";
      "resample-method" = "soxr-hq";
      "flat-volumes" = "no";
    };
  } // lib.optionalAttrs bluetoothSupport {
    package = pkgs.pulseaudioFull;
    extraModules = [
      pkgs.pulseaudio-modules-bt # Non-standard codecs for bluetooth
    ];
  };

  environment.systemPackages = with pkgs; [
    pavucontrol
  ];

  hardware.bluetooth.enable = lib.mkDefault bluetoothSupport;
  services.blueman.enable = lib.mkDefault bluetoothSupport;
}