| 
									
										
										
										
											2014-04-14 16:26:48 +02:00
										 |  |  | { config, lib, pkgs, ... }: | 
					
						
							| 
									
										
										
										
											2009-08-10 18:25:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-14 16:26:48 +02:00
										 |  |  | with lib; | 
					
						
							| 
									
										
										
										
											2016-01-29 22:08:42 +00:00
										 |  |  | let | 
					
						
							|  |  |  |     bluez-bluetooth = if config.services.xserver.desktopManager.kde4.enable then pkgs.bluez else pkgs.bluez5; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     configBluez = { | 
					
						
							|  |  |  |         description = "Bluetooth Service"; | 
					
						
							|  |  |  |         serviceConfig = { | 
					
						
							|  |  |  |           Type = "dbus"; | 
					
						
							|  |  |  |           BusName = "org.bluez"; | 
					
						
							|  |  |  |           ExecStart = "${bluez-bluetooth}/sbin/bluetoothd -n"; | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  |         wantedBy = [ "bluetooth.target" ]; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     configBluez5 =  { | 
					
						
							|  |  |  |         description = "Bluetooth Service"; | 
					
						
							|  |  |  |         serviceConfig = { | 
					
						
							|  |  |  |           Type = "dbus"; | 
					
						
							|  |  |  |           BusName = "org.bluez"; | 
					
						
							|  |  |  |           ExecStart = "${bluez-bluetooth}/sbin/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 = "${bluez-bluetooth}/sbin/obexd"; | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bluezConfig = if config.services.xserver.desktopManager.kde4.enable then configBluez else configBluez5; | 
					
						
							|  |  |  | in | 
					
						
							| 
									
										
										
										
											2009-08-10 18:25:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   ###### interface | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   options = { | 
					
						
							| 
									
										
										
										
											2010-08-27 15:32:49 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     hardware.bluetooth.enable = mkOption { | 
					
						
							| 
									
										
										
										
											2013-10-30 17:37:45 +01:00
										 |  |  |       type = types.bool; | 
					
						
							| 
									
										
										
										
											2010-08-27 15:32:49 +00:00
										 |  |  |       default = false; | 
					
						
							|  |  |  |       description = "Whether to enable support for Bluetooth."; | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2011-09-14 18:20:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-10 18:25:09 +00:00
										 |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   ###### implementation | 
					
						
							| 
									
										
										
										
											2016-01-29 22:08:42 +00:00
										 |  |  |    | 
					
						
							| 
									
										
										
										
											2010-08-27 15:32:49 +00:00
										 |  |  |   config = mkIf config.hardware.bluetooth.enable { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-29 22:08:42 +00:00
										 |  |  |     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; | 
					
						
							| 
									
										
										
										
											2013-02-10 20:30:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-14 18:20:50 +00:00
										 |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-10 18:25:09 +00:00
										 |  |  | } |