Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
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 nativeBuildInputs = [ wrapGAppsHook gobject-introspection ];
22
23 buildInputs = [ gtk3 libappindicator-gtk3 librsvg ];
24
25 propagatedBuildInputs = [ evdev pygobject3 pylibacl vdf ];
26
27 nativeCheckInputs = [ pytestCheckHook ];
28
29 patches = [
30 # Fix a broken test
31 (fetchpatch {
32 url = "https://github.com/Ryochan7/sc-controller/pull/73.patch";
33 sha256 = "sha256-qU8hIReZE3cEPCMOFc4RCUCIhiS0gJ3PushMkfDlPns=";
34 })
35 ];
36
37 postPatch = ''
38 substituteInPlace scc/paths.py --replace sys.prefix "'$out'"
39 substituteInPlace scc/uinput.py --replace /usr/include ${linuxHeaders}/include
40 substituteInPlace scc/device_monitor.py --replace "find_library('bluetooth')" "'libbluetooth.so.3'"
41 '';
42
43 LD_LIBRARY_PATH = lib.makeLibraryPath [ libX11 libXext libXfixes libusb1 udev bluez ];
44
45 preFixup = ''
46 gappsWrapperArgs+=(--prefix LD_LIBRARY_PATH : "$LD_LIBRARY_PATH")
47 '';
48
49 postFixup = ''
50 (
51 # scc runs these scripts as programs. (See find_binary() in scc/tools.py.)
52 cd $out/lib/python*/site-packages/scc/x11
53 patchPythonScript scc-autoswitch-daemon.py
54 patchPythonScript scc-osd-daemon.py
55 )
56 '';
57
58 meta = with lib; {
59 homepage = "https://github.com/Ryochan7/sc-controller";
60 # donations: https://www.patreon.com/kozec
61 description = "User-mode driver and GUI for Steam Controller and other controllers";
62 license = licenses.gpl2;
63 platforms = platforms.linux;
64 maintainers = with maintainers; [ orivej rnhmjoj ];
65 };
66}