2024-06-24 11:38:28 -04:00
|
|
|
# Configures bluetooth.
|
2024-05-07 18:02:59 -04:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2024-02-29 09:53:34 -05:00
|
|
|
|
|
|
|
let
|
2024-06-24 11:38:28 -04:00
|
|
|
cfg = config.aux.system.bluetooth;
|
2024-11-06 10:42:06 -05:00
|
|
|
|
|
|
|
# Copy bluetooth device configs
|
|
|
|
shure-aonic-bluetooth = pkgs.writeText "info" (builtins.readFile ./bluetooth/shure-aonic-tw2);
|
2024-02-29 09:53:34 -05:00
|
|
|
in
|
|
|
|
{
|
|
|
|
|
2024-05-07 18:02:59 -04:00
|
|
|
options = {
|
2024-06-24 11:38:28 -04:00
|
|
|
aux.system.bluetooth = {
|
2024-09-08 11:58:56 -04:00
|
|
|
enable = lib.mkEnableOption "Enables bluetooth.";
|
2024-11-06 10:42:06 -05:00
|
|
|
adapter = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "The MAC address of your primary Bluetooth adapter Used to install device configs.";
|
|
|
|
default = "";
|
|
|
|
};
|
2024-10-18 16:14:33 -04:00
|
|
|
experimental.enable = lib.mkEnableOption "Enables experimental features, like device power reporting.";
|
2024-05-07 18:02:59 -04:00
|
|
|
};
|
|
|
|
};
|
2024-02-29 09:53:34 -05:00
|
|
|
|
2024-06-24 11:38:28 -04:00
|
|
|
config = lib.mkIf cfg.enable {
|
2024-05-07 18:02:59 -04:00
|
|
|
# Set up Bluetooth
|
|
|
|
hardware.bluetooth = {
|
|
|
|
enable = true;
|
|
|
|
powerOnBoot = true;
|
2024-10-18 16:14:33 -04:00
|
|
|
settings = lib.mkIf cfg.experimental.enable {
|
2024-05-07 18:02:59 -04:00
|
|
|
General = {
|
|
|
|
Enable = "Source,Sink,Media,Socket";
|
|
|
|
Experimental = true;
|
|
|
|
KernelExperimental = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-02-29 09:53:34 -05:00
|
|
|
|
2024-05-07 18:02:59 -04:00
|
|
|
# Add Bluetooth LE audio support
|
|
|
|
environment.systemPackages = with pkgs; [ liblc3 ];
|
2024-11-06 10:42:06 -05:00
|
|
|
|
|
|
|
# Install Bluetooth device profiles
|
|
|
|
systemd.tmpfiles.rules = lib.mkIf (cfg.adapter != "") [
|
|
|
|
"d /var/lib/bluetooth/${cfg.adapter}/ 0700 root root" # First, make sure the directory exists
|
|
|
|
"L+ /var/lib/bluetooth/${cfg.adapter}/00:0E:DD:72:2F:0C/info - - - - ${shure-aonic-bluetooth}"
|
|
|
|
];
|
2024-05-07 18:02:59 -04:00
|
|
|
};
|
|
|
|
}
|