From f9e8ef7e6d8b9df759a9cb6f7a1c3218684331ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20S=C3=B8holm?= Date: Mon, 20 Mar 2017 14:28:02 +0100 Subject: [PATCH] nixos/bluetooth: add extraConfig option (#23427) --- nixos/modules/services/hardware/bluetooth.nix | 29 +++++++++++++++---- pkgs/os-specific/linux/bluez/bluez5.nix | 4 +++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/hardware/bluetooth.nix b/nixos/modules/services/hardware/bluetooth.nix index 71b3a93a2e0..f1fcb436934 100644 --- a/nixos/modules/services/hardware/bluetooth.nix +++ b/nixos/modules/services/hardware/bluetooth.nix @@ -14,12 +14,26 @@ in options = { - hardware.bluetooth.enable = mkEnableOption "support for Bluetooth."; + hardware.bluetooth = { + enable = mkEnableOption "support for Bluetooth."; - hardware.bluetooth.powerOnBoot = mkOption { - type = types.bool; - default = true; - description = "Whether to power up the default Bluetooth controller on boot."; + powerOnBoot = mkOption { + type = types.bool; + default = true; + description = "Whether to power up the default Bluetooth controller on boot."; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + example = '' + [General] + ControllerMode = bredr + ''; + description = '' + Set additional configuration for system-wide bluetooth (/etc/bluetooth/main.conf). + ''; + }; }; }; @@ -30,6 +44,11 @@ in environment.systemPackages = [ bluez-bluetooth pkgs.openobex pkgs.obexftp ]; + environment.etc = singleton { + source = pkgs.writeText "main.conf" cfg.extraConfig; + target = "bluetooth/main.conf"; + }; + services.udev.packages = [ bluez-bluetooth ]; services.dbus.packages = [ bluez-bluetooth ]; systemd.packages = [ bluez-bluetooth ]; diff --git a/pkgs/os-specific/linux/bluez/bluez5.nix b/pkgs/os-specific/linux/bluez/bluez5.nix index 6185e22fb87..9149f6da033 100644 --- a/pkgs/os-specific/linux/bluez/bluez5.nix +++ b/pkgs/os-specific/linux/bluez/bluez5.nix @@ -73,6 +73,10 @@ stdenv.mkDerivation rec { mkdir $out/sbin ln -s ../libexec/bluetooth/bluetoothd $out/sbin/bluetoothd ln -s ../libexec/bluetooth/obexd $out/sbin/obexd + + # Add extra configuration + mkdir $out/etc/bluetooth + ln -s /etc/bluetooth/main.conf $out/etc/bluetooth/main.conf ''; enableParallelBuilding = true;