bluetooth: use upstream's recommendation for enabling interfaces
bluez no longer recommends spawning "hciconfig <device> up" from a udev rule as the main bluez daemon now supports automatically enabling power for all devices. Reference: http://www.bluez.org/release-of-bluez-5-35/
This commit is contained in:
parent
048114eb4f
commit
99d4ed5861
@ -6,9 +6,7 @@ let
|
|||||||
bluez-bluetooth = pkgs.bluez;
|
bluez-bluetooth = pkgs.bluez;
|
||||||
cfg = config.hardware.bluetooth;
|
cfg = config.hardware.bluetooth;
|
||||||
|
|
||||||
in
|
in {
|
||||||
|
|
||||||
{
|
|
||||||
|
|
||||||
###### interface
|
###### interface
|
||||||
|
|
||||||
@ -32,6 +30,8 @@ in
|
|||||||
'';
|
'';
|
||||||
description = ''
|
description = ''
|
||||||
Set additional configuration for system-wide bluetooth (/etc/bluetooth/main.conf).
|
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.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -45,7 +45,12 @@ in
|
|||||||
environment.systemPackages = [ bluez-bluetooth pkgs.openobex pkgs.obexftp ];
|
environment.systemPackages = [ bluez-bluetooth pkgs.openobex pkgs.obexftp ];
|
||||||
|
|
||||||
environment.etc = singleton {
|
environment.etc = singleton {
|
||||||
source = pkgs.writeText "main.conf" cfg.extraConfig;
|
source = pkgs.writeText "main.conf" ''
|
||||||
|
[Policy]
|
||||||
|
AutoEnable=${lib.boolToString cfg.powerOnBoot}
|
||||||
|
|
||||||
|
${cfg.extraConfig}
|
||||||
|
'';
|
||||||
target = "bluetooth/main.conf";
|
target = "bluetooth/main.conf";
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -53,29 +58,11 @@ in
|
|||||||
services.dbus.packages = [ bluez-bluetooth ];
|
services.dbus.packages = [ bluez-bluetooth ];
|
||||||
systemd.packages = [ bluez-bluetooth ];
|
systemd.packages = [ bluez-bluetooth ];
|
||||||
|
|
||||||
services.udev.extraRules = optionalString cfg.powerOnBoot ''
|
|
||||||
ACTION=="add", KERNEL=="hci[0-9]*", ENV{SYSTEMD_WANTS}="bluetooth-power@%k.service"
|
|
||||||
'';
|
|
||||||
|
|
||||||
systemd.services = {
|
systemd.services = {
|
||||||
bluetooth = {
|
bluetooth = {
|
||||||
wantedBy = [ "bluetooth.target" ];
|
wantedBy = [ "bluetooth.target" ];
|
||||||
aliases = [ "dbus-org.bluez.service" ];
|
aliases = [ "dbus-org.bluez.service" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
"bluetooth-power@" = mkIf cfg.powerOnBoot {
|
|
||||||
description = "Power up bluetooth controller";
|
|
||||||
after = [
|
|
||||||
"bluetooth.service"
|
|
||||||
"suspend.target"
|
|
||||||
"sys-subsystem-bluetooth-devices-%i.device"
|
|
||||||
];
|
|
||||||
wantedBy = [ "suspend.target" ];
|
|
||||||
|
|
||||||
serviceConfig.Type = "oneshot";
|
|
||||||
serviceConfig.ExecStart = "${pkgs.bluez.out}/bin/hciconfig %i up";
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.user.services = {
|
systemd.user.services = {
|
||||||
|
Loading…
Reference in New Issue
Block a user