1{
2 copyDesktopItems,
3 fetchFromGitHub,
4 lib,
5 makeDesktopItem,
6 python3Packages,
7 qt6,
8 wrapGAppsHook3,
9 writeText,
10 xvfb-run,
11 udevCheckHook,
12}:
13
14python3Packages.buildPythonApplication rec {
15 pname = "streamdeck-ui";
16 version = "4.1.3";
17 pyproject = true;
18
19 src = fetchFromGitHub {
20 repo = "streamdeck-linux-gui";
21 owner = "streamdeck-linux-gui";
22 rev = "v${version}";
23 hash = "sha256-KpsW3EycYRYU5YOg7NNGv5eeZbS9MAikj0Ke2ybPzAU=";
24 };
25
26 pythonRelaxDeps = [
27 "importlib-metadata"
28 "pillow"
29 ];
30
31 build-system = [
32 python3Packages.poetry-core
33 ];
34
35 nativeBuildInputs = [
36 copyDesktopItems
37 qt6.wrapQtAppsHook
38 wrapGAppsHook3
39 udevCheckHook
40 ];
41
42 propagatedBuildInputs =
43 with python3Packages;
44 [
45 setuptools
46 filetype
47 cairosvg
48 pillow
49 pynput
50 pyside6
51 streamdeck
52 xlib
53 importlib-metadata
54 evdev
55 ]
56 ++ lib.optionals stdenv.hostPlatform.isLinux [ qt6.qtwayland ];
57
58 nativeCheckInputs = [
59 xvfb-run
60 ]
61 ++ (with python3Packages; [
62 pytest
63 pytest-qt
64 pytest-mock
65 ]);
66
67 checkPhase = ''
68 runHook preCheck
69
70 # The tests needs to find the log file
71 export STREAMDECK_UI_LOG_FILE=$(pwd)/.streamdeck_ui.log
72 xvfb-run pytest tests
73
74 runHook postCheck
75 '';
76
77 postInstall =
78 let
79 udevRules = ''
80 SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", TAG+="uaccess"
81 '';
82 in
83 ''
84 mkdir -p $out/lib/systemd/user
85 substitute scripts/streamdeck.service $out/lib/systemd/user/streamdeck.service \
86 --replace '<path to streamdeck>' $out/bin/streamdeck
87
88 mkdir -p "$out/etc/udev/rules.d"
89 cp ${writeText "70-streamdeck.rules" udevRules} $out/etc/udev/rules.d/70-streamdeck.rules
90
91 mkdir -p "$out/share/pixmaps"
92 cp streamdeck_ui/logo.png $out/share/pixmaps/streamdeck-ui.png
93 '';
94
95 desktopItems =
96 let
97 common = {
98 name = "streamdeck-ui";
99 desktopName = "Stream Deck UI";
100 icon = "streamdeck-ui";
101 exec = "streamdeck";
102 comment = "UI for the Elgato Stream Deck";
103 categories = [ "Utility" ];
104 };
105 in
106 builtins.map makeDesktopItem [
107 common
108 (
109 common
110 // {
111 name = "${common.name}-noui";
112 exec = "${common.exec} --no-ui";
113 noDisplay = true;
114 }
115 )
116 ];
117
118 dontWrapQtApps = true;
119 dontWrapGApps = true;
120 makeWrapperArgs = [
121 "\${qtWrapperArgs[@]}"
122 "\${gappsWrapperArgs[@]}"
123 ];
124
125 meta = {
126 changelog = "https://github.com/streamdeck-linux-gui/streamdeck-linux-gui/releases/tag/v${version}";
127 description = "Linux compatible UI for the Elgato Stream Deck";
128 downloadPage = "https://github.com/streamdeck-linux-gui/streamdeck-linux-gui/";
129 homepage = "https://streamdeck-linux-gui.github.io/streamdeck-linux-gui/";
130 license = lib.licenses.mit;
131 mainProgram = "streamdeck";
132 maintainers = with lib.maintainers; [ majiir ];
133 };
134}