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