nixpkgs/nixos/modules/services/hardware/bluetooth.nix

48 lines
943 B
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
with lib;
let
2017-02-01 13:52:12 -08:00
isBluez4 = config.services.xserver.desktopManager.kde4.enable;
bluez-bluetooth = if isBluez4 then pkgs.bluez4 else pkgs.bluez;
in
{
###### interface
options = {
hardware.bluetooth.enable = mkOption {
2013-10-30 09:37:45 -07:00
type = types.bool;
default = false;
description = "Whether to enable support for Bluetooth.";
};
};
###### implementation
config = mkIf config.hardware.bluetooth.enable {
environment.systemPackages = [ bluez-bluetooth pkgs.openobex pkgs.obexftp ];
2017-02-01 13:52:12 -08:00
services.udev.packages = [ bluez-bluetooth ];
2017-02-01 13:52:12 -08:00
services.dbus.packages = [ bluez-bluetooth ];
2017-02-01 13:52:12 -08:00
systemd.packages = [ bluez-bluetooth ];
systemd.services.bluetooth = {
wantedBy = [ "bluetooth.target" ];
aliases = [ "dbus-org.bluez.service" ];
};
systemd.user.services.obex = mkIf (!isBluez4) {
aliases = [ "dbus-org.bluez.obex.service" ];
};
};
}