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;
|
2017-02-17 18:44:04 +00:00
|
|
|
|
2016-01-29 22:08:42 +00:00
|
|
|
let
|
2017-02-11 19:01:13 +00:00
|
|
|
bluez-bluetooth = pkgs.bluez;
|
2017-02-17 18:44:04 +00:00
|
|
|
cfg = config.hardware.bluetooth;
|
|
|
|
|
2017-04-13 03:48:58 +01:00
|
|
|
in {
|
2009-08-10 19:25:09 +01:00
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2010-08-27 16:32:49 +01:00
|
|
|
|
2017-03-20 13:28:02 +00:00
|
|
|
hardware.bluetooth = {
|
|
|
|
enable = mkEnableOption "support for Bluetooth.";
|
2017-02-17 18:44:04 +00:00
|
|
|
|
2017-03-20 13:28:02 +00:00
|
|
|
powerOnBoot = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Whether to power up the default Bluetooth controller on boot.";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
[General]
|
|
|
|
ControllerMode = bredr
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Set additional configuration for system-wide bluetooth (/etc/bluetooth/main.conf).
|
2017-04-13 03:48:58 +01:00
|
|
|
|
|
|
|
NOTE: We already include [Policy], so any configuration under the Policy group should come first.
|
2017-03-20 13:28:02 +00:00
|
|
|
'';
|
|
|
|
};
|
2010-08-27 16:32:49 +01:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
2017-02-10 02:25:03 +00:00
|
|
|
|
2017-02-17 18:44:04 +00:00
|
|
|
config = mkIf cfg.enable {
|
2010-08-27 16:32:49 +01:00
|
|
|
|
2016-01-29 22:08:42 +00:00
|
|
|
environment.systemPackages = [ bluez-bluetooth pkgs.openobex pkgs.obexftp ];
|
2017-02-01 21:52:12 +00:00
|
|
|
|
2017-03-20 13:28:02 +00:00
|
|
|
environment.etc = singleton {
|
2017-04-13 03:48:58 +01:00
|
|
|
source = pkgs.writeText "main.conf" ''
|
|
|
|
[Policy]
|
|
|
|
AutoEnable=${lib.boolToString cfg.powerOnBoot}
|
|
|
|
|
|
|
|
${cfg.extraConfig}
|
|
|
|
'';
|
2017-03-20 13:28:02 +00:00
|
|
|
target = "bluetooth/main.conf";
|
|
|
|
};
|
|
|
|
|
2016-01-29 22:08:42 +00:00
|
|
|
services.udev.packages = [ bluez-bluetooth ];
|
|
|
|
services.dbus.packages = [ bluez-bluetooth ];
|
2017-02-17 18:44:04 +00:00
|
|
|
systemd.packages = [ bluez-bluetooth ];
|
|
|
|
|
|
|
|
systemd.services = {
|
|
|
|
bluetooth = {
|
|
|
|
wantedBy = [ "bluetooth.target" ];
|
|
|
|
aliases = [ "dbus-org.bluez.service" ];
|
|
|
|
};
|
2017-02-01 21:52:12 +00:00
|
|
|
};
|
|
|
|
|
2017-02-17 18:44:04 +00:00
|
|
|
systemd.user.services = {
|
|
|
|
obex.aliases = [ "dbus-org.bluez.obex.service" ];
|
2017-02-01 21:52:12 +00:00
|
|
|
};
|
2013-02-10 18:30:02 +00:00
|
|
|
|
2011-09-14 19:20:50 +01:00
|
|
|
};
|
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
}
|