Merge pull request #73872 from filalex77/modules/services/hardware/bluetooth/ini-generator
nixos/bluetooth: add support for INI generator
This commit is contained in:
commit
a568a03674
@ -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";
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user