about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAaron Andersen <aaron@fosslib.net>2019-11-27 18:02:20 -0500
committerGitHub <noreply@github.com>2019-11-27 18:02:20 -0500
commita568a03674b8a82d16ff3e91da9b089727d3a0d6 (patch)
tree577f77534e118c5df00d4959707394f61a28a01e
parentae568810928f69b4e2d73530170044337399453b (diff)
parent95fc2d3fe17199502c8f8121743d21f7795f1454 (diff)
downloadnixlib-a568a03674b8a82d16ff3e91da9b089727d3a0d6.tar
nixlib-a568a03674b8a82d16ff3e91da9b089727d3a0d6.tar.gz
nixlib-a568a03674b8a82d16ff3e91da9b089727d3a0d6.tar.bz2
nixlib-a568a03674b8a82d16ff3e91da9b089727d3a0d6.tar.lz
nixlib-a568a03674b8a82d16ff3e91da9b089727d3a0d6.tar.xz
nixlib-a568a03674b8a82d16ff3e91da9b089727d3a0d6.tar.zst
nixlib-a568a03674b8a82d16ff3e91da9b089727d3a0d6.zip
Merge pull request #73872 from filalex77/modules/services/hardware/bluetooth/ini-generator
nixos/bluetooth: add support for INI generator
-rw-r--r--nixos/modules/services/hardware/bluetooth.nix30
1 files changed, 20 insertions, 10 deletions
diff --git a/nixos/modules/services/hardware/bluetooth.nix b/nixos/modules/services/hardware/bluetooth.nix
index c5f9d1f9b725..7b13beea1ca9 100644
--- a/nixos/modules/services/hardware/bluetooth.nix
+++ b/nixos/modules/services/hardware/bluetooth.nix
@@ -36,17 +36,25 @@ in {
         '';
       };
 
+      config = mkOption {
+        type = with types; attrsOf (attrsOf (oneOf [ bool int str ]));
+        example = {
+          General = {
+            ControllerMode = "bredr";
+          };
+        };
+        description = "Set configuration for system-wide bluetooth (/etc/bluetooth/main.conf).";
+      };
+
       extraConfig = mkOption {
-        type = types.lines;
-        default = "";
+        type = with types; nullOr lines;
+        default = null;
         example = ''
           [General]
           ControllerMode = bredr
         '';
         description = ''
           Set additional configuration for system-wide bluetooth (/etc/bluetooth/main.conf).
-
-          NOTE: We already include [Policy], so any configuration under the Policy group should come first.
         '';
       };
     };
@@ -56,16 +64,18 @@ in {
   ###### implementation
 
   config = mkIf cfg.enable {
+    warnings = optional (cfg.extraConfig != null) "hardware.bluetooth.`extraConfig` is deprecated, please use hardware.bluetooth.`config`.";
+
+    hardware.bluetooth.config = {
+      Policy = {
+        AutoEnable = mkDefault cfg.powerOnBoot;
+      };
+    };
 
     environment.systemPackages = [ bluez-bluetooth pkgs.openobex pkgs.obexftp ];
 
     environment.etc = singleton {
-      source = pkgs.writeText "main.conf" ''
-        [Policy]
-        AutoEnable=${lib.boolToString cfg.powerOnBoot}
-
-        ${cfg.extraConfig}
-      '';
+      source = pkgs.writeText "main.conf" (generators.toINI { } cfg.config + optionalString (cfg.extraConfig != null) cfg.extraConfig);
       target = "bluetooth/main.conf";
     };