about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKristoffer Søholm <k.soeholm@gmail.com>2017-03-20 14:28:02 +0100
committerFranz Pletz <fpletz@fnordicwalking.de>2017-03-20 14:28:02 +0100
commitf9e8ef7e6d8b9df759a9cb6f7a1c3218684331ee (patch)
tree3ba8f4b50f865a594924c6a9dd83eb14aea3a74a
parent1f0ce0eaf8ca840e769615acc7581bd71268ca44 (diff)
downloadnixlib-f9e8ef7e6d8b9df759a9cb6f7a1c3218684331ee.tar
nixlib-f9e8ef7e6d8b9df759a9cb6f7a1c3218684331ee.tar.gz
nixlib-f9e8ef7e6d8b9df759a9cb6f7a1c3218684331ee.tar.bz2
nixlib-f9e8ef7e6d8b9df759a9cb6f7a1c3218684331ee.tar.lz
nixlib-f9e8ef7e6d8b9df759a9cb6f7a1c3218684331ee.tar.xz
nixlib-f9e8ef7e6d8b9df759a9cb6f7a1c3218684331ee.tar.zst
nixlib-f9e8ef7e6d8b9df759a9cb6f7a1c3218684331ee.zip
nixos/bluetooth: add extraConfig option (#23427)
-rw-r--r--nixos/modules/services/hardware/bluetooth.nix29
-rw-r--r--pkgs/os-specific/linux/bluez/bluez5.nix4
2 files changed, 28 insertions, 5 deletions
diff --git a/nixos/modules/services/hardware/bluetooth.nix b/nixos/modules/services/hardware/bluetooth.nix
index 71b3a93a2e0d..f1fcb4369346 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 6185e22fb875..9149f6da033b 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;