2021-05-05 12:47:04 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
2021-05-29 16:37:07 +02:00
|
|
|
cfg = config.my.hardware.bluetooth;
|
2021-05-05 12:47:04 +02:00
|
|
|
in
|
|
|
|
{
|
2021-05-29 16:37:07 +02:00
|
|
|
options.my.hardware.bluetooth = with lib; {
|
2021-05-09 11:40:37 +02:00
|
|
|
enable = mkEnableOption "bluetooth configuration";
|
2021-05-05 12:47:04 +02:00
|
|
|
|
|
|
|
enableHeadsetIntegration = my.mkDisableOption "A2DP sink configuration";
|
|
|
|
|
|
|
|
loadExtraCodecs = my.mkDisableOption "extra audio codecs";
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable (lib.mkMerge [
|
|
|
|
# Enable bluetooth devices and GUI to connect to them
|
|
|
|
{
|
|
|
|
hardware.bluetooth.enable = true;
|
|
|
|
services.blueman.enable = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Support for additional bluetooth codecs
|
|
|
|
(lib.mkIf cfg.loadExtraCodecs {
|
|
|
|
hardware.pulseaudio = {
|
|
|
|
extraModules = [ pkgs.pulseaudio-modules-bt ];
|
|
|
|
package = pkgs.pulseaudioFull;
|
|
|
|
};
|
2021-05-25 18:18:40 +02:00
|
|
|
|
2024-02-29 13:06:58 +01:00
|
|
|
services.pipewire.wireplumber.configPackages = [
|
|
|
|
(pkgs.writeTextDir "share/wireplumber/bluetooth.lua.d/51-bluez-config.lua" ''
|
2023-03-28 17:27:56 +02:00
|
|
|
bluez_monitor.properties = {
|
|
|
|
-- SBC XQ provides better audio
|
|
|
|
["bluez5.enable-sbc-xq"] = true,
|
|
|
|
|
|
|
|
-- mSBC provides better audio + microphone
|
|
|
|
["bluez5.enable-msbc"] = true,
|
|
|
|
|
|
|
|
-- Synchronize volume with bluetooth device
|
|
|
|
["bluez5.enable-hw-volume"] = true,
|
|
|
|
|
|
|
|
-- FIXME: Some devices may now support both hsp_ag and hfp_ag
|
|
|
|
["bluez5.headset-roles"] = "[ hsp_hs hsp_ag hfp_hf hfp_ag ]"
|
2021-05-25 18:18:40 +02:00
|
|
|
}
|
2024-02-29 13:06:58 +01:00
|
|
|
'')
|
|
|
|
];
|
2021-05-05 12:47:04 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
# Support for A2DP audio profile
|
|
|
|
(lib.mkIf cfg.enableHeadsetIntegration {
|
|
|
|
hardware.bluetooth.settings = {
|
|
|
|
General = {
|
|
|
|
Enable = "Source,Sink,Media,Socket";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})
|
|
|
|
]);
|
|
|
|
}
|