From 35b8de02c2bc768103175073169713bfc0cedcc7 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 5 May 2021 12:47:04 +0200 Subject: [PATCH] modules: add bluetooth --- modules/bluetooth.nix | 38 ++++++++++++++++++++++++++++++++++++++ modules/default.nix | 1 + 2 files changed, 39 insertions(+) create mode 100644 modules/bluetooth.nix diff --git a/modules/bluetooth.nix b/modules/bluetooth.nix new file mode 100644 index 0000000..811dd94 --- /dev/null +++ b/modules/bluetooth.nix @@ -0,0 +1,38 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.my.modules.bluetooth; +in +{ + options.my.modules.bluetooth = with lib; { + enable = mkEnableOption "wireless configuration"; + + 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; + }; + }) + + # Support for A2DP audio profile + (lib.mkIf cfg.enableHeadsetIntegration { + hardware.bluetooth.settings = { + General = { + Enable = "Source,Sink,Media,Socket"; + }; + }; + }) + ]); +} diff --git a/modules/default.nix b/modules/default.nix index f20351f..c25a426 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -3,6 +3,7 @@ { imports = [ + ./bluetooth.nix ./documentation.nix ./ergodox.nix ./home.nix