1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchpatch,
6 cmake,
7 makeWrapper,
8 pkg-config,
9 SDL2,
10 libX11,
11 dbus,
12 libdecor,
13 libnotify,
14 dejavu_fonts,
15 zenity,
16}:
17
18stdenv.mkDerivation (finalAttrs: {
19 pname = "trigger-control";
20 version = "1.5.1";
21
22 src = fetchFromGitHub {
23 owner = "Etaash-mathamsetty";
24 repo = "trigger-control";
25 # upstream does not use consistent tags pattern, so we use git commit hash
26 # https://github.com/Etaash-mathamsetty/trigger-control/tags
27 rev = "7b46e743227830d3a97720067d0a6cf20133af90";
28 hash = "sha256-nWSvsgksZ4Cxy1+i0xy8pNalgsiAuaqxNVwT/CThaBI=";
29 };
30
31 nativeBuildInputs = [
32 cmake
33 makeWrapper
34 pkg-config
35 ];
36
37 buildInputs = [
38 SDL2
39 libX11
40 dbus
41 libnotify
42 ]
43 ++ lib.optionals stdenv.hostPlatform.isLinux [
44 libdecor
45 ];
46
47 patches = [
48 # Fix build on clang https://github.com/Etaash-mathamsetty/trigger-control/pull/23
49 (fetchpatch {
50 name = "clang.patch";
51 url = "https://github.com/Etaash-mathamsetty/trigger-control/commit/bbec33296fdac7e2ca0398ae19ca8de8ad883407.patch";
52 hash = "sha256-x6RymdzBlzAJ8O8QGqXQtvkZkjdTaC5X8syFPunqZik=";
53 })
54 ];
55
56 # The app crashes without a changed fontdir and upstream recommends dejavu as font
57 postPatch = ''
58 substituteInPlace trigger-control.cpp --replace "/usr/share/fonts/" "${dejavu_fonts}/share/fonts/"
59 '';
60
61 installPhase = ''
62 runHook preInstall
63
64 install -D trigger-control $out/bin/trigger-control
65
66 runHook postInstall
67 '';
68
69 postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
70 wrapProgram $out/bin/trigger-control \
71 --prefix PATH : ${lib.makeBinPath [ zenity ]}
72 '';
73
74 meta = with lib; {
75 description = "Control the dualsense's triggers on Linux (and Windows) with a gui and C++ api";
76 homepage = "https://github.com/Etaash-mathamsetty/trigger-control";
77 license = licenses.mit;
78 mainProgram = "trigger-control";
79 maintainers = with maintainers; [ azuwis ];
80 platforms = platforms.all;
81 };
82})