1{
2 stdenv,
3 lib,
4 isKde ? false,
5 python3Packages,
6 fetchFromGitHub,
7 copyDesktopItems,
8 makeDesktopItem,
9 wrapGAppsHook4,
10 gobject-introspection,
11 libadwaita,
12 libportal,
13 libportal-gtk4,
14 xdg-desktop-portal,
15 xdg-desktop-portal-gtk,
16 kdotool,
17 udevCheckHook,
18}:
19let
20 # We have to hardcode revision because upstream often create multiple releases for the same version number.
21 # This is the commit hash that maps to 1.5.0-beta.8 released on 2025-03-12
22 rev = "de11d84afac7873044568606a8468c78d57aceda";
23in
24stdenv.mkDerivation {
25 pname = "streamcontroller";
26
27 version = "1.5.0-beta.8";
28
29 src = fetchFromGitHub {
30 repo = "StreamController";
31 owner = "StreamController";
32 inherit rev;
33 hash = "sha256-pE92/oX9iZYCIhwDkPkjPq/cDUQLUGs+Ou5rjFEIBpo=";
34 };
35
36 # The installation method documented upstream
37 # (https://streamcontroller.github.io/docs/latest/installation/) is to clone the repo,
38 # run `pip install`, then run `python3 main.py` to launch the program.
39 # Due to how the code is structured upstream, it's infeasible to use `buildPythonApplication`.
40
41 dontBuild = true;
42 installPhase =
43 # Some plugins needs to load things dynamically and in that case we won't find python3 without this
44 let
45 binPath = [
46 python3Packages.python.interpreter
47 ]
48 # Allows automatic detection of windows to switch pages on KDE
49 ++ lib.optional isKde kdotool;
50 in
51 ''
52 runHook preInstall
53
54 mkdir -p $out/usr/lib/streamcontroller
55 cp -r ./* $out/usr/lib/streamcontroller/
56
57 mkdir -p $out/bin/
58
59 # Note that the implementation of main.py assumes
60 # working directory to be at the root of the project's source code
61 makeWrapper \
62 ${python3Packages.python.interpreter} \
63 $out/bin/streamcontroller \
64 --add-flags main.py \
65 --chdir $out/usr/lib/streamcontroller \
66 --prefix PYTHONPATH : "$PYTHONPATH" \
67 --prefix PATH : "$PATH:${lib.makeBinPath binPath}"
68
69 mkdir -p "$out/etc/udev/rules.d"
70 cp ./udev.rules $out/etc/udev/rules.d/70-streamcontroller.rules
71
72 install -D ./flatpak/icon_256.png $out/share/icons/hicolor/256x256/apps/com.core447.StreamController.png
73
74 runHook postInstall
75 '';
76
77 desktopItems = [
78 (makeDesktopItem {
79 name = "StreamController";
80 desktopName = "StreamController";
81 exec = "streamcontroller";
82 icon = "com.core447.StreamController";
83 comment = "Control your Elgato Stream Decks";
84 categories = [ "Utility" ];
85 })
86 ];
87
88 nativeBuildInputs = [
89 copyDesktopItems
90 wrapGAppsHook4
91 udevCheckHook
92 gobject-introspection
93 ];
94
95 buildInputs = [
96 libadwaita
97 libportal
98 libportal-gtk4
99 xdg-desktop-portal
100 xdg-desktop-portal-gtk
101 ]
102 ++ (with python3Packages; [
103 annotated-types
104 async-lru
105 cairocffi
106 cairosvg
107 certifi
108 cffi
109 charset-normalizer
110 click
111 colorama
112 contourpy
113 cssselect2
114 cycler
115 dbus-python
116 decorator
117 defusedxml
118 distlib
119 dnspython
120 evdev
121 filelock
122 fonttools
123 fuzzywuzzy
124 gcodepy
125 get-video-properties
126 gitdb
127 idna
128 imageio
129 imageio-ffmpeg
130 indexed-bzip2
131 jinja2
132 joblib
133 kiwisolver
134 levenshtein
135 linkify-it-py
136 loguru
137 markdown-it-py
138 markupsafe
139 matplotlib
140 mdit-py-plugins
141 mdurl
142 meson
143 meson-python
144 natsort
145 nltk
146 numpy
147 opencv4
148 packaging
149 pillow
150 platformdirs
151 plumbum
152 proglog
153 psutil
154 pulsectl
155 pycairo
156 pyclip
157 pycparser
158 pydantic
159 pydantic-core
160 pyenchant
161 pygments
162 pygobject3
163 pymongo
164 pyparsing
165 pyperclip
166 pyproject-metadata
167 pyro5
168 pyspellchecker
169 python-dateutil
170 pyudev
171 pyusb
172 pyyaml
173 rapidfuzz
174 regex
175 requests
176 requirements-parser
177 rich
178 rpyc
179 serpent
180 setproctitle
181 six
182 smmap
183 speedtest-cli
184 streamcontroller-plugin-tools
185 streamdeck
186 textual
187 tinycss2
188 tqdm
189 types-setuptools
190 typing-extensions
191 uc-micro-py
192 urllib3
193 usb-monitor
194 webencodings
195 websocket-client
196 ]);
197
198 doInstallCheck = true;
199
200 meta = with lib; {
201 description = "Elegant Linux app for the Elgato Stream Deck with support for plugins";
202 homepage = "https://core447.com/";
203 license = licenses.gpl3;
204 mainProgram = "streamcontroller";
205 maintainers = with maintainers; [ sifmelcara ];
206 platforms = lib.platforms.linux;
207 };
208}