1{ lib, buildPythonApplication, fetchFromGitHub, wrapGAppsHook
2, pytestCheckHook
3, fetchpatch
4, gtk3, gobject-introspection, libappindicator-gtk3, librsvg
5, evdev, pygobject3, pylibacl, bluez, vdf
6, linuxHeaders
7, libX11, libXext, libXfixes, libusb1, udev
8}:
9
10buildPythonApplication rec {
11 pname = "sc-controller";
12 version = "0.4.8.9";
13
14 src = fetchFromGitHub {
15 owner = "Ryochan7";
16 repo = pname;
17 rev = "v${version}";
18 sha256 = "sha256-ym5fkOTRhibBaUqT0+p/jyqqKOVsyMz5INgfkoz0IJA=";
19 };
20
21 # see https://github.com/NixOS/nixpkgs/issues/56943
22 strictDeps = false;
23
24 nativeBuildInputs = [ wrapGAppsHook ];
25
26 buildInputs = [ gtk3 gobject-introspection libappindicator-gtk3 librsvg ];
27
28 propagatedBuildInputs = [ evdev pygobject3 pylibacl vdf ];
29
30 checkInputs = [ pytestCheckHook ];
31
32 patches = [
33 # Fix a broken test
34 (fetchpatch {
35 url = "https://github.com/Ryochan7/sc-controller/pull/73.patch";
36 sha256 = "sha256-qU8hIReZE3cEPCMOFc4RCUCIhiS0gJ3PushMkfDlPns=";
37 })
38 ];
39
40 postPatch = ''
41 substituteInPlace scc/paths.py --replace sys.prefix "'$out'"
42 substituteInPlace scc/uinput.py --replace /usr/include ${linuxHeaders}/include
43 substituteInPlace scc/device_monitor.py --replace "find_library('bluetooth')" "'libbluetooth.so.3'"
44 '';
45
46 LD_LIBRARY_PATH = lib.makeLibraryPath [ libX11 libXext libXfixes libusb1 udev bluez ];
47
48 preFixup = ''
49 gappsWrapperArgs+=(--prefix LD_LIBRARY_PATH : "$LD_LIBRARY_PATH")
50 '';
51
52 postFixup = ''
53 (
54 # scc runs these scripts as programs. (See find_binary() in scc/tools.py.)
55 cd $out/lib/python*/site-packages/scc/x11
56 patchPythonScript scc-autoswitch-daemon.py
57 patchPythonScript scc-osd-daemon.py
58 )
59 '';
60
61 meta = with lib; {
62 homepage = "https://github.com/Ryochan7/sc-controller";
63 # donations: https://www.patreon.com/kozec
64 description = "User-mode driver and GUI for Steam Controller and other controllers";
65 license = licenses.gpl2;
66 platforms = platforms.linux;
67 maintainers = with maintainers; [ orivej rnhmjoj ];
68 };
69}