3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #22353 from abbradar/bluetooth

Bluetooth improvements
This commit is contained in:
Nikolay Amiantov 2017-02-05 13:18:48 +03:00 committed by GitHub
commit 90bc1a8595
6 changed files with 40 additions and 47 deletions

View file

@ -2,41 +2,9 @@
with lib;
let
bluez-bluetooth = if config.services.xserver.desktopManager.kde4.enable then pkgs.bluez else pkgs.bluez5;
isBluez4 = config.services.xserver.desktopManager.kde4.enable;
bluez-bluetooth = if isBluez4 then pkgs.bluez4 else pkgs.bluez;
configBluez = {
description = "Bluetooth Service";
serviceConfig = {
Type = "dbus";
BusName = "org.bluez";
ExecStart = "${getBin bluez-bluetooth}/bin/bluetoothd -n";
};
wantedBy = [ "bluetooth.target" ];
};
configBluez5 = {
description = "Bluetooth Service";
serviceConfig = {
Type = "dbus";
BusName = "org.bluez";
ExecStart = "${getBin bluez-bluetooth}/bin/bluetoothd -n";
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";
ExecStart = "${getBin bluez-bluetooth}/bin/obexd";
};
};
bluezConfig = if config.services.xserver.desktopManager.kde4.enable then configBluez else configBluez5;
in
{
@ -58,10 +26,21 @@ in
config = mkIf config.hardware.bluetooth.enable {
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;
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" ];
};
};

View file

@ -159,7 +159,13 @@ rec {
fi
done
# Created .wants and .requires symlinks from the wantedBy and
# Create service aliases from aliases option.
${concatStrings (mapAttrsToList (name: unit:
concatMapStrings (name2: ''
ln -sfn '${name}' $out/'${name2}'
'') unit.aliases) units)}
# Create .wants and .requires symlinks from the wantedBy and
# requiredBy options.
${concatStrings (mapAttrsToList (name: unit:
concatMapStrings (name2: ''

View file

@ -52,6 +52,12 @@ in rec {
description = "Units that want (i.e. depend on) this unit.";
};
aliases = mkOption {
default = [];
type = types.listOf types.str;
description = "Aliases of that unit.";
};
};
concreteUnitOptions = sharedOptions // {

View file

@ -313,7 +313,7 @@ let
'';
targetToUnit = name: def:
{ inherit (def) wantedBy requiredBy enable;
{ inherit (def) aliases wantedBy requiredBy enable;
text =
''
[Unit]
@ -322,7 +322,7 @@ let
};
serviceToUnit = name: def:
{ inherit (def) wantedBy requiredBy enable;
{ inherit (def) aliases wantedBy requiredBy enable;
text = commonUnitText def +
''
[Service]
@ -342,7 +342,7 @@ let
};
socketToUnit = name: def:
{ inherit (def) wantedBy requiredBy enable;
{ inherit (def) aliases wantedBy requiredBy enable;
text = commonUnitText def +
''
[Socket]
@ -352,7 +352,7 @@ let
};
timerToUnit = name: def:
{ inherit (def) wantedBy requiredBy enable;
{ inherit (def) aliases wantedBy requiredBy enable;
text = commonUnitText def +
''
[Timer]
@ -361,7 +361,7 @@ let
};
pathToUnit = name: def:
{ inherit (def) wantedBy requiredBy enable;
{ inherit (def) aliases wantedBy requiredBy enable;
text = commonUnitText def +
''
[Path]
@ -370,7 +370,7 @@ let
};
mountToUnit = name: def:
{ inherit (def) wantedBy requiredBy enable;
{ inherit (def) aliases wantedBy requiredBy enable;
text = commonUnitText def +
''
[Mount]
@ -379,7 +379,7 @@ let
};
automountToUnit = name: def:
{ inherit (def) wantedBy requiredBy enable;
{ inherit (def) aliases wantedBy requiredBy enable;
text = commonUnitText def +
''
[Automount]
@ -388,7 +388,7 @@ let
};
sliceToUnit = name: def:
{ inherit (def) wantedBy requiredBy enable;
{ inherit (def) aliases wantedBy requiredBy enable;
text = commonUnitText def +
''
[Slice]

View file

@ -5,8 +5,8 @@ assert stdenv.isLinux;
let
inherit (pythonPackages) python;
pythonpath = "${pythonPackages.dbus}/lib/${python.libPrefix}/site-packages:"
+ "${pythonPackages.pygobject}/lib/${python.libPrefix}/site-packages";
pythonpath = "${pythonPackages.dbus-python}/lib/${python.libPrefix}/site-packages:"
+ "${pythonPackages.pygobject2}/lib/${python.libPrefix}/site-packages";
in stdenv.mkDerivation rec {
name = "bluez-4.101";

View file

@ -10861,6 +10861,8 @@ with pkgs;
bluez5 = callPackage ../os-specific/linux/bluez/bluez5.nix { };
bluez4 = callPackage ../os-specific/linux/bluez { };
# Needed for LibreOffice
bluez5_28 = lowPrio (callPackage ../os-specific/linux/bluez/bluez5_28.nix { });