diff options
author | Oleksii Filonenko <brightone@protonmail.com> | 2019-11-21 18:35:45 +0200 |
---|---|---|
committer | Oleksii Filonenko <brightone@protonmail.com> | 2019-11-22 17:11:44 +0200 |
commit | 95fc2d3fe17199502c8f8121743d21f7795f1454 (patch) | |
tree | 89a3241717dc4b10fee863c5222103cf6d0afb4a /nixos | |
parent | 6b2504f9f20e79711e835ef412173ee2be542dc2 (diff) | |
download | nixlib-95fc2d3fe17199502c8f8121743d21f7795f1454.tar nixlib-95fc2d3fe17199502c8f8121743d21f7795f1454.tar.gz nixlib-95fc2d3fe17199502c8f8121743d21f7795f1454.tar.bz2 nixlib-95fc2d3fe17199502c8f8121743d21f7795f1454.tar.lz nixlib-95fc2d3fe17199502c8f8121743d21f7795f1454.tar.xz nixlib-95fc2d3fe17199502c8f8121743d21f7795f1454.tar.zst nixlib-95fc2d3fe17199502c8f8121743d21f7795f1454.zip |
hardware/bluetooth: add support for INI generator
- Add services.hardware.bluetooth.config option - Use lib.generators.toINI with both config and extraConfig options hardware/bluetooth: a couple suggestions Co-authored-by: Aaron Andersen <aaron@fosslib.net>
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/hardware/bluetooth.nix | 30 |
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"; }; |