1{
2 lib,
3 fetchFromGitHub,
4 fetchFromGitLab,
5 python3,
6 copyDesktopItems,
7 makeDesktopItem,
8 pkg-config,
9 SDL2,
10}:
11let
12 # steamos-devkit requires a build of the unreleased pyimgui 2.0 branch, move to pythonPackages when 2.0 is released.
13 pyimgui = python3.pkgs.buildPythonPackage {
14 pname = "pyimgui";
15 version = "2.0.0";
16 format = "setuptools";
17
18 src = fetchFromGitHub {
19 owner = "pyimgui";
20 repo = "pyimgui";
21 rev = "2.0.0";
22 fetchSubmodules = true;
23 sha256 = "sha256-sw/bLTdrnPhBhrnk5yyXCbEK4kMo+PdEvoMJ9aaZbsE=";
24 };
25
26 nativeBuildInputs = with python3.pkgs; [
27 cython_0
28 pkg-config
29 SDL2
30 ];
31
32 propagatedBuildInputs = with python3.pkgs; [
33 click
34 pyopengl
35 pysdl2
36 ];
37
38 # Requires OpenGL acceleration
39 doCheck = false;
40 pythonImportsCheck = [ "imgui" ];
41 };
42 steamos-devkit-script = ''
43 #!${python3.interpreter}
44 import os
45
46 # Change the cwd to avoid imgui using cwd which often is ~ to store the state, use the same location as the settings
47 path = os.path.expanduser(os.path.join("~", ".devkit-client-gui"))
48 os.makedirs(path, exist_ok=True)
49 os.chdir(path)
50
51 # Workaround to get pysdl to work on wayland, remove when https://gitlab.steamos.cloud/devkit/steamos-devkit/-/issues/1 is solved.
52 if os.environ.get("XDG_SESSION_TYPE") == "wayland":
53 os.environ["SDL_VIDEODRIVER"] = "wayland"
54
55 import devkit_client.gui2
56 devkit_client.gui2.main()
57 '';
58in
59python3.pkgs.buildPythonPackage rec {
60 pname = "steamos-devkit";
61 version = "0.20240216.0";
62 format = "setuptools";
63
64 src = fetchFromGitLab {
65 domain = "gitlab.steamos.cloud";
66 owner = "devkit";
67 repo = "steamos-devkit";
68 rev = "v${version}";
69 sha256 = "sha256-eOtESkGMIjcijAFITOcYKPsXH6xH/Xcj9D+OItMqebM=";
70 };
71
72 propagatedBuildInputs = with python3.pkgs; [
73 appdirs
74 bcrypt
75 cffi
76 cryptography
77 idna
78 ifaddr
79 netifaces
80 numpy
81 paramiko
82 pycparser
83 pyimgui
84 pynacl
85 pysdl2
86 signalslot
87 six
88 ];
89
90 nativeBuildInputs = [
91 copyDesktopItems
92 ];
93
94 postUnpack = ''
95 # Find the absolute source root to link correctly to the previous root
96 prevRoot=$(realpath $sourceRoot)
97
98 # Update the source root to the devkit_client package
99 sourceRoot="$sourceRoot/client"
100
101 # Link the setup script into the new source root
102 ln -s $prevRoot/setup/shiv-linux-setup.py $sourceRoot/setup.py
103 '';
104
105 postInstall = ''
106 mkdir -p $out/bin
107
108 # These are various assets like scripts that steamos-devkit will copy to the remote device
109 cp -R ./devkit-utils $out/${python3.sitePackages}/devkit-utils
110
111 # writeScript + symlink will be ignored by wrapPythonPrograms
112 # Copying it is undesirable too, just write it directly to a script instead
113 cat << EOF > $out/bin/steamos-devkit
114 ${steamos-devkit-script}
115 EOF
116 chmod +x $out/bin/steamos-devkit
117 '';
118
119 # There are no checks for steamos-devkit
120 doCheck = false;
121 pythonImportsCheck = [ "devkit_client" ];
122
123 desktopItems = [
124 (makeDesktopItem {
125 name = "SteamOS-Devkit";
126 exec = "steamos-devkit";
127 desktopName = "SteamOS Devkit Client";
128 })
129 ];
130
131 meta = with lib; {
132 description = "SteamOS Devkit Client";
133 mainProgram = "steamos-devkit";
134 homepage = "https://gitlab.steamos.cloud/devkit/steamos-devkit";
135 license = licenses.mit;
136 maintainers = with maintainers; [ myaats ];
137 };
138}