This blog post explains how to setup a PlayStation 3 or PlayStation 4 controller so it can be used over Bluetooth on NixOS. This uses a NixOS package called
I wanted to use my PlayStation 3 controllers over Bluetooth to play games on NixOS.
bluez package originally didn't have support for the PlayStation 3 and PlayStation 4 Bluetooth controllers, so it took a little work to be able to use them. I ended up creating a new
bluez derivation that enables support for PlayStation controllers called
In order to use your PlayStation 3 or PlayStation 4 controllers over Bluetooth, you must enable Bluetooth and make sure the
bluezFull package is used. This can be done by specifying the following in your
bluezFull is different from
bluez because it enables all the Bluez plugins, including support for the PlayStation 3 and PlayStation 4 controllers (called "sixaxis"), the Wiimote, and midi.
After adding this to your
/etc/nixos/configuration.nix file, you will need to run
sudo nixos-rebuild switch to actually enable the Bluetooth systemd service.
How to actually use the PlayStation 3 controller
In order to actually use a Bluetooth PlayStation controller, you need to pair it with your computer.
You can do so with the following steps1:
bluetoothctl(which is provided by the
Enable the agent and set it as default:
[bluetooth]# agent on [bluetooth]# default-agent
Power on your laptop's Bluetooth receiver, and set it as discoverable and pairable:
[bluetooth]# power on [bluetooth]# discoverable on [bluetooth]# pairable on
Connect the PlayStation 3 controller to the system using a USB cable and press the PlayStation button.
bluetoothctlshould show the new device and ask you if you want to allow the service authorization request. Type
[NEW] Device 00:07:F4:1E:B5:AA Sony PLAYSTATION(R)3 Controller [agent] Authorize service 00018824-1234-1234-8000-00b04bbb34ff (yes/no): yes
If your PlayStation controller is not listed automatically, there is a big chance that either your controller is broken or you're accidentally using the
bluezpackage instead of
You might also try the
Disconnect the USB cable from the PlayStation 3 controller.
Trust the PlayStation 3 controller.
[bluetooth]# trust 00:07:F4:1E:B5:AA
This makes it so that you computer will automatically connect to the PlayStation 3 controller over bluetooth the next time the controller is turned on.
The PlayStation 3 controller is now paired. Quit
Now you should be able to use your PlayStation 3 controller as a normal joystick.
Unlike the actual PlayStation, your PlayStation 3 controller will not turn off automatically after a period of inactivity. You must turn the controller off manually by pressing and holding the PlayStation button for 15 seconds.
The steps for setting up a PlayStation 4 controller are similar. They can be found on the Gentoo Wiki.
Earlier Versions of NixOS
bluezFull package is available in the
master branch of
nixpkgs as of December 13th, 2018. This means you will be able to use it with NixOS-19.03, but not with earlier NixOS releases like NixOS-18.09.
If you're using NixOS-18.09, you should be able to add support for the PlayStation 3 and PlayStation 4 controllers to
bluez like the following. Add this to your
This enables Bluetooth, as well as setting the Bluetooth package to use. This uses the normal
bluez package, but it adds the
--enable-sixaxis flag to the flags passed to
./configure when building
This works well, but the
bluez package will have to be rebuilt with this new flag. The
bluez package is relatively small, so rebuilding should only take a few minutes.
Knock-off or imitation PlayStation controllers may not work with
bluez. I don't know a good way around this.
I've had trouble with an imitation PlayStation 3 controller being detected as a keyboard instead of as a controller.
Using PlayStation 3 or PlayStation 4 controllers on NixOS is relatively straight-forward, as long as you use the