1{
2 lib,
3 fetchFromGitHub,
4 xorg,
5 wrapQtAppsHook,
6 python3,
7}:
8
9python3.pkgs.buildPythonApplication rec {
10 pname = "lenovo-legion-app";
11 version = "0.0.20-unstable-2025-04-01";
12 format = "setuptools";
13
14 src = fetchFromGitHub {
15 owner = "johnfanv2";
16 repo = "LenovoLegionLinux";
17 rev = "19fef88dbbb077d99052e06f3cd9a3675e7bf3aa";
18 hash = "sha256-0lQ6LyfjZ1/dc6QjB4a1aBcfxY5lIJJEonwuy9a4V4I=";
19 };
20
21 sourceRoot = "${src.name}/python/legion_linux";
22
23 nativeBuildInputs = [ wrapQtAppsHook ];
24
25 propagatedBuildInputs = with python3.pkgs; [
26 pyqt6
27 argcomplete
28 pyyaml
29 darkdetect
30 xorg.libxcb
31 ];
32
33 postPatch = ''
34 # only fixup application (legion-linux-gui), service (legiond) currently not installed so do not fixup
35 # version
36 substituteInPlace ./setup.cfg \
37 --replace-fail "_VERSION" "${builtins.head (lib.splitString "-" version)}"
38
39 # /etc
40 substituteInPlace ./legion_linux/legion.py \
41 --replace-fail "/etc/legion_linux" "$out/share/legion_linux"
42
43 # /usr
44 substituteInPlace ./legion_linux/legion_gui.desktop \
45 --replace-fail "Icon=/usr/share/pixmaps/legion_logo.png" "Icon=legion_logo"
46 '';
47
48 dontWrapQtApps = true;
49
50 preFixup = ''
51 makeWrapperArgs+=("''${qtWrapperArgs[@]}")
52 '';
53
54 meta = {
55 description = "Utility to control Lenovo Legion laptop";
56 homepage = "https://github.com/johnfanv2/LenovoLegionLinux";
57 license = lib.licenses.gpl2Only;
58 platforms = lib.platforms.linux;
59 maintainers = with lib.maintainers; [
60 ulrikstrid
61 realsnick
62 chn
63 ];
64 mainProgram = "legion_gui";
65 };
66}