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