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; with lib;
let 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 in
{ {
@ -58,10 +26,21 @@ in
config = mkIf config.hardware.bluetooth.enable { config = mkIf config.hardware.bluetooth.enable {
environment.systemPackages = [ bluez-bluetooth pkgs.openobex pkgs.obexftp ]; environment.systemPackages = [ bluez-bluetooth pkgs.openobex pkgs.obexftp ];
services.udev.packages = [ bluez-bluetooth ]; services.udev.packages = [ bluez-bluetooth ];
services.dbus.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 fi
done 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. # requiredBy options.
${concatStrings (mapAttrsToList (name: unit: ${concatStrings (mapAttrsToList (name: unit:
concatMapStrings (name2: '' concatMapStrings (name2: ''

View File

@ -52,6 +52,12 @@ in rec {
description = "Units that want (i.e. depend on) this unit."; 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 // { concreteUnitOptions = sharedOptions // {

View File

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

View File

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

View File

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