git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #22353 from abbradar/bluetooth

Bluetooth improvements

commit90bc1a8595792d87927a65db172f55aa22176944 authorNikolay Amiantov <ab@fmap.me> dateSun 5 Feb 2017, 13:18 (10 years ago) parent91869fb4abcef2
6 files changed+40−47
nixos/modules/services/hardware/bluetooth.nix+15−36 nixos/modules/system/boot/systemd-lib.nix+7−1 nixos/modules/system/boot/systemd-unit-options.nix+6 nixos/modules/system/boot/systemd.nix+8−8 pkgs/os-specific/linux/bluez/default.nix+2−2 pkgs/top-level/all-packages.nix+2
nixos/modules/services/hardware/bluetooth.nix+15−36
@@ -2,41 +2,9 @@
22
33with lib;
44let
5− bluez-bluetooth = if config.services.xserver.desktopManager.kde4.enable then pkgs.bluez else pkgs.bluez5;
6−
7− configBluez = {
8− description = "Bluetooth Service";
9− serviceConfig = {
10− Type = "dbus";
11− BusName = "org.bluez";
12− ExecStart = "${getBin bluez-bluetooth}/bin/bluetoothd -n";
13− };
14− wantedBy = [ "bluetooth.target" ];
15− };
16−
17− configBluez5 = {
18− description = "Bluetooth Service";
19− serviceConfig = {
20− Type = "dbus";
21− BusName = "org.bluez";
22− ExecStart = "${getBin bluez-bluetooth}/bin/bluetoothd -n";
23− NotifyAccess="main";
24− CapabilityBoundingSet="CAP_NET_ADMIN CAP_NET_BIND_SERVICE";
25− LimitNPROC=1;
26− };
27− wantedBy = [ "bluetooth.target" ];
28− };
5+ isBluez4 = config.services.xserver.desktopManager.kde4.enable;
6+ bluez-bluetooth = if isBluez4 then pkgs.bluez4 else pkgs.bluez;
297
30− obexConfig = {
31− description = "Bluetooth OBEX service";
32− serviceConfig = {
33− Type = "dbus";
34− BusName = "org.bluez.obex";
35− ExecStart = "${getBin bluez-bluetooth}/bin/obexd";
36− };
37− };
38−
39− bluezConfig = if config.services.xserver.desktopManager.kde4.enable then configBluez else configBluez5;
408in
419
4210{
@@ -58,10 +26,21 @@ in
5826 config = mkIf config.hardware.bluetooth.enable {
5927
6028 environment.systemPackages = [ bluez-bluetooth pkgs.openobex pkgs.obexftp ];
29+
6130 services.udev.packages = [ bluez-bluetooth ];
31+
6232 services.dbus.packages = [ bluez-bluetooth ];
63− systemd.services."dbus-org.bluez" = bluezConfig;
64− systemd.services."dbus-org.bluez.obex" = obexConfig;
33+
34+ systemd.packages = [ bluez-bluetooth ];
35+
36+ systemd.services.bluetooth = {
37+ wantedBy = [ "bluetooth.target" ];
38+ aliases = [ "dbus-org.bluez.service" ];
39+ };
40+
41+ systemd.user.services.obex = mkIf (!isBluez4) {
42+ aliases = [ "dbus-org.bluez.obex.service" ];
43+ };
6544
6645 };
6746
nixos/modules/system/boot/systemd-lib.nix+7−1
@@ -159,7 +159,13 @@ rec {
159159 fi
160160 done
161161
162− # Created .wants and .requires symlinks from the wantedBy and
162+ # Create service aliases from aliases option.
163+ ${concatStrings (mapAttrsToList (name: unit:
164+ concatMapStrings (name2: ''
165+ ln -sfn '${name}' $out/'${name2}'
166+ '') unit.aliases) units)}
167+
168+ # Create .wants and .requires symlinks from the wantedBy and
163169 # requiredBy options.
164170 ${concatStrings (mapAttrsToList (name: unit:
165171 concatMapStrings (name2: ''
nixos/modules/system/boot/systemd-unit-options.nix+6
@@ -52,6 +52,12 @@ in rec {
5252 description = "Units that want (i.e. depend on) this unit.";
5353 };
5454
55+ aliases = mkOption {
56+ default = [];
57+ type = types.listOf types.str;
58+ description = "Aliases of that unit.";
59+ };
60+
5561 };
5662
5763 concreteUnitOptions = sharedOptions // {
nixos/modules/system/boot/systemd.nix+8−8
@@ -313,7 +313,7 @@ let
313313 '';
314314
315315 targetToUnit = name: def:
316− { inherit (def) wantedBy requiredBy enable;
316+ { inherit (def) aliases wantedBy requiredBy enable;
317317 text =
318318 ''
319319 [Unit]
@@ -322,7 +322,7 @@ let
322322 };
323323
324324 serviceToUnit = name: def:
325− { inherit (def) wantedBy requiredBy enable;
325+ { inherit (def) aliases wantedBy requiredBy enable;
326326 text = commonUnitText def +
327327 ''
328328 [Service]
@@ -342,7 +342,7 @@ let
342342 };
343343
344344 socketToUnit = name: def:
345− { inherit (def) wantedBy requiredBy enable;
345+ { inherit (def) aliases wantedBy requiredBy enable;
346346 text = commonUnitText def +
347347 ''
348348 [Socket]
@@ -352,7 +352,7 @@ let
352352 };
353353
354354 timerToUnit = name: def:
355− { inherit (def) wantedBy requiredBy enable;
355+ { inherit (def) aliases wantedBy requiredBy enable;
356356 text = commonUnitText def +
357357 ''
358358 [Timer]
@@ -361,7 +361,7 @@ let
361361 };
362362
363363 pathToUnit = name: def:
364− { inherit (def) wantedBy requiredBy enable;
364+ { inherit (def) aliases wantedBy requiredBy enable;
365365 text = commonUnitText def +
366366 ''
367367 [Path]
@@ -370,7 +370,7 @@ let
370370 };
371371
372372 mountToUnit = name: def:
373− { inherit (def) wantedBy requiredBy enable;
373+ { inherit (def) aliases wantedBy requiredBy enable;
374374 text = commonUnitText def +
375375 ''
376376 [Mount]
@@ -379,7 +379,7 @@ let
379379 };
380380
381381 automountToUnit = name: def:
382− { inherit (def) wantedBy requiredBy enable;
382+ { inherit (def) aliases wantedBy requiredBy enable;
383383 text = commonUnitText def +
384384 ''
385385 [Automount]
@@ -388,7 +388,7 @@ let
388388 };
389389
390390 sliceToUnit = name: def:
391− { inherit (def) wantedBy requiredBy enable;
391+ { inherit (def) aliases wantedBy requiredBy enable;
392392 text = commonUnitText def +
393393 ''
394394 [Slice]
pkgs/os-specific/linux/bluez/default.nix+2−2
@@ -5,8 +5,8 @@ assert stdenv.isLinux;
55
66let
77 inherit (pythonPackages) python;
8− pythonpath = "${pythonPackages.dbus}/lib/${python.libPrefix}/site-packages:"
9− + "${pythonPackages.pygobject}/lib/${python.libPrefix}/site-packages";
8+ pythonpath = "${pythonPackages.dbus-python}/lib/${python.libPrefix}/site-packages:"
9+ + "${pythonPackages.pygobject2}/lib/${python.libPrefix}/site-packages";
1010in stdenv.mkDerivation rec {
1111 name = "bluez-4.101";
1212
pkgs/top-level/all-packages.nix+2
@@ -10861,6 +10861,8 @@ with pkgs;
1086110861
1086210862 bluez5 = callPackage ../os-specific/linux/bluez/bluez5.nix { };
1086310863
10864+ bluez4 = callPackage ../os-specific/linux/bluez { };
10865+
1086410866 # Needed for LibreOffice
1086510867 bluez5_28 = lowPrio (callPackage ../os-specific/linux/bluez/bluez5_28.nix { });
1086610868