1{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, libevdev, udev, acl }:
2
3stdenv.mkDerivation rec {
4 pname = "joycond";
5 version = "unstable-2021-07-30";
6
7 src = fetchFromGitHub {
8 owner = "DanielOgorchock";
9 repo = "joycond";
10 rev = "f9a66914622514c13997c2bf7ec20fa98e9dfc1d";
11 sha256 = "sha256-quw7yBHDDZk1+6uHthsfMCej7g5uP0nIAqzvI6436B8=";
12 };
13
14 nativeBuildInputs = [ cmake pkg-config ];
15 buildInputs = [ libevdev udev ];
16
17 # CMake has hardcoded install paths
18 installPhase = ''
19 mkdir -p $out/{bin,etc/{systemd/system,udev/rules.d},lib/modules-load.d}
20
21 cp ./joycond $out/bin
22 cp $src/udev/{89,72}-joycond.rules $out/etc/udev/rules.d
23 cp $src/systemd/joycond.service $out/etc/systemd/system
24 cp $src/systemd/joycond.conf $out/lib/modules-load.d
25
26 substituteInPlace $out/etc/systemd/system/joycond.service --replace \
27 "ExecStart=/usr/bin/joycond" "ExecStart=$out/bin/joycond"
28
29 substituteInPlace $out/etc/udev/rules.d/89-joycond.rules --replace \
30 "/bin/setfacl" "${acl}/bin/setfacl"
31 '';
32
33 meta = with lib; {
34 homepage = "https://github.com/DanielOgorchock/joycond";
35 description = "Userspace daemon to combine joy-cons from the hid-nintendo kernel driver";
36 license = licenses.gpl3Only;
37 maintainers = [ maintainers.ivar ];
38 platforms = platforms.linux;
39 };
40}