2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2009-08-10 20:25:09 +02:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2017-02-17 19:44:04 +01:00
|
|
|
|
2016-01-29 23:08:42 +01:00
|
|
|
let
|
2017-02-11 20:01:13 +01:00
|
|
|
bluez-bluetooth = pkgs.bluez;
|
2017-02-17 19:44:04 +01:00
|
|
|
cfg = config.hardware.bluetooth;
|
|
|
|
|
2017-04-13 04:48:58 +02:00
|
|
|
in {
|
2009-08-10 20:25:09 +02:00
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2010-08-27 17:32:49 +02:00
|
|
|
|
2017-03-20 14:28:02 +01:00
|
|
|
hardware.bluetooth = {
|
|
|
|
enable = mkEnableOption "support for Bluetooth.";
|
2017-02-17 19:44:04 +01:00
|
|
|
|
2017-03-20 14:28:02 +01: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 04:48:58 +02:00
|
|
|
|
|
|
|
NOTE: We already include [Policy], so any configuration under the Policy group should come first.
|
2017-03-20 14:28:02 +01:00
|
|
|
'';
|
|
|
|
};
|
2010-08-27 17:32:49 +02:00
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-08-10 20:25:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
2017-02-10 03:25:03 +01:00
|
|
|
|
2017-02-17 19:44:04 +01:00
|
|
|
config = mkIf cfg.enable {
|
2010-08-27 17:32:49 +02:00
|
|
|
|
2016-01-29 23:08:42 +01:00
|
|
|
environment.systemPackages = [ bluez-bluetooth pkgs.openobex pkgs.obexftp ];
|
2017-02-01 22:52:12 +01:00
|
|
|
|
2017-03-20 14:28:02 +01:00
|
|
|
environment.etc = singleton {
|
2017-04-13 04:48:58 +02:00
|
|
|
source = pkgs.writeText "main.conf" ''
|
|
|
|
[Policy]
|
|
|
|
AutoEnable=${lib.boolToString cfg.powerOnBoot}
|
|
|
|
|
|
|
|
${cfg.extraConfig}
|
|
|
|
'';
|
2017-03-20 14:28:02 +01:00
|
|
|
target = "bluetooth/main.conf";
|
|
|
|
};
|
|
|
|
|
2016-01-29 23:08:42 +01:00
|
|
|
services.udev.packages = [ bluez-bluetooth ];
|
|
|
|
services.dbus.packages = [ bluez-bluetooth ];
|
2017-02-17 19:44:04 +01:00
|
|
|
systemd.packages = [ bluez-bluetooth ];
|
|
|
|
|
|
|
|
systemd.services = {
|
|
|
|
bluetooth = {
|
|
|
|
wantedBy = [ "bluetooth.target" ];
|
|
|
|
aliases = [ "dbus-org.bluez.service" ];
|
|
|
|
};
|
2017-02-01 22:52:12 +01:00
|
|
|
};
|
|
|
|
|
2017-02-17 19:44:04 +01:00
|
|
|
systemd.user.services = {
|
|
|
|
obex.aliases = [ "dbus-org.bluez.obex.service" ];
|
2017-02-01 22:52:12 +01:00
|
|
|
};
|
2013-02-10 19:30:02 +01:00
|
|
|
|
2011-09-14 20:20:50 +02:00
|
|
|
};
|
|
|
|
|
2009-08-10 20:25:09 +02:00
|
|
|
}
|