2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2009-08-10 19:25:09 +01:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2016-01-29 22:08:42 +00:00
|
|
|
let
|
|
|
|
bluez-bluetooth = if config.services.xserver.desktopManager.kde4.enable then pkgs.bluez else pkgs.bluez5;
|
|
|
|
|
|
|
|
configBluez = {
|
|
|
|
description = "Bluetooth Service";
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "dbus";
|
|
|
|
BusName = "org.bluez";
|
2016-04-27 11:48:06 +01:00
|
|
|
ExecStart = "${getBin bluez-bluetooth}/bin/bluetoothd -n";
|
2016-01-29 22:08:42 +00:00
|
|
|
};
|
|
|
|
wantedBy = [ "bluetooth.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
configBluez5 = {
|
|
|
|
description = "Bluetooth Service";
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "dbus";
|
|
|
|
BusName = "org.bluez";
|
2016-04-27 11:48:06 +01:00
|
|
|
ExecStart = "${getBin bluez-bluetooth}/bin/bluetoothd -n";
|
2016-01-29 22:08:42 +00:00
|
|
|
NotifyAccess="main";
|
|
|
|
CapabilityBoundingSet="CAP_NET_ADMIN CAP_NET_BIND_SERVICE";
|
|
|
|
LimitNPROC=1;
|
|
|
|
};
|
|
|
|
wantedBy = [ "bluetooth.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
obexConfig = {
|
|
|
|
description = "Bluetooth OBEX service";
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "dbus";
|
|
|
|
BusName = "org.bluez.obex";
|
2016-04-27 11:48:06 +01:00
|
|
|
ExecStart = "${getBin bluez-bluetooth}/bin/obexd";
|
2016-01-29 22:08:42 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
bluezConfig = if config.services.xserver.desktopManager.kde4.enable then configBluez else configBluez5;
|
|
|
|
in
|
2009-08-10 19:25:09 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2010-08-27 16:32:49 +01:00
|
|
|
|
|
|
|
hardware.bluetooth.enable = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
type = types.bool;
|
2010-08-27 16:32:49 +01:00
|
|
|
default = false;
|
|
|
|
description = "Whether to enable support for Bluetooth.";
|
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
2016-01-29 22:08:42 +00:00
|
|
|
|
2010-08-27 16:32:49 +01:00
|
|
|
config = mkIf config.hardware.bluetooth.enable {
|
|
|
|
|
2016-01-29 22:08:42 +00:00
|
|
|
environment.systemPackages = [ bluez-bluetooth pkgs.openobex pkgs.obexftp ];
|
|
|
|
services.udev.packages = [ bluez-bluetooth ];
|
|
|
|
services.dbus.packages = [ bluez-bluetooth ];
|
|
|
|
systemd.services."dbus-org.bluez" = bluezConfig;
|
|
|
|
systemd.services."dbus-org.bluez.obex" = obexConfig;
|
2013-02-10 18:30:02 +00:00
|
|
|
|
2011-09-14 19:20:50 +01:00
|
|
|
};
|
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
}
|