1
0
Fork 0
nix-configuration/modules/system/bluetooth.nix

52 lines
1.2 KiB
Nix
Raw Normal View History

# Configures bluetooth.
{
lib,
config,
pkgs,
...
}:
2024-02-29 14:53:34 +00:00
let
cfg = config.aux.system.bluetooth;
2024-02-29 14:53:34 +00:00
in
{
options = {
aux.system.bluetooth = {
enable = lib.mkEnableOption (lib.mdDoc "Enables bluetooth");
};
};
2024-02-29 14:53:34 +00:00
config = lib.mkIf cfg.enable {
# Set up Bluetooth
hardware.bluetooth = {
enable = true;
powerOnBoot = true;
settings = {
General = {
Enable = "Source,Sink,Media,Socket";
Experimental = true;
KernelExperimental = true;
};
};
};
2024-02-29 14:53:34 +00:00
# Add Bluetooth LE audio support
environment.systemPackages = with pkgs; [ liblc3 ];
# FIXME: Create systemd service to manually start the adapter on boot.
# This is a workaround for hardware.bluetooth.powerOnBoot not working as expected.
systemd.services.startBluetooth = {
description = "Manually starts the Bluetooth service on boot";
after = [ "bluetooth.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
type = "simple";
ExecStart = "${pkgs.bluez}/bin/bluetoothctl -- power on";
Restart = "always";
RestartSec = "5s";
};
};
};
}