summary refs log tree commit diff
path: root/pkgs/os-specific/linux/joycond/default.nix
blob: a203073b081c5fe8c98726ba50ce53a365cd7b01 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, libevdev, udev }:

stdenv.mkDerivation rec {
  pname = "joycond";
  version = "unstable-2021-03-27";

  src = fetchFromGitHub {
    owner = "DanielOgorchock";
    repo = "joycond";
    rev = "2d3f553060291f1bfee2e49fc2ca4a768b289df8";
    sha256 = "0dpmwspll9ar3pxg9rgnh224934par8h8bixdz9i2pqqbc3dqib7";
  };

  nativeBuildInputs = [ cmake pkg-config ];
  buildInputs = [ libevdev udev ];

  # CMake has hardcoded install paths
  installPhase = ''
    mkdir -p $out/{bin,etc/{systemd/system,udev/rules.d},lib/modules-load.d}

    cp ./joycond $out/bin
    cp $src/udev/{89,72}-joycond.rules $out/etc/udev/rules.d
    cp $src/systemd/joycond.service $out/etc/systemd/system
    cp $src/systemd/joycond.conf $out/lib/modules-load.d

    substituteInPlace $out/etc/systemd/system/joycond.service --replace \
      "ExecStart=/usr/bin/joycond" "ExecStart=$out/bin/joycond"
  '';

  meta = with lib; {
    homepage = "https://github.com/DanielOgorchock/joycond";
    description = "Userspace daemon to combine joy-cons from the hid-nintendo kernel driver";
    license = licenses.gpl3Only;
    maintainers = [ maintainers.ivar ];
    platforms = platforms.linux;
  };
}