1{
2 lib,
3 python3Packages,
4 fetchFromGitHub,
5 fetchpatch,
6 installShellFiles,
7 git,
8 spdx-license-list-data,
9 replaceVars,
10 writableTmpDirAsHomeHook,
11 udevCheckHook,
12}:
13
14with python3Packages;
15buildPythonApplication rec {
16 pname = "platformio";
17 version = "6.1.18";
18 pyproject = true;
19
20 # pypi tarballs don't contain tests - https://github.com/platformio/platformio-core/issues/1964
21 src = fetchFromGitHub {
22 owner = "platformio";
23 repo = "platformio-core";
24 tag = "v${version}";
25 hash = "sha256-h9/xDWXCoGHQ9r2f/ZzAtwTAs4qzDrvVAQ2kuLS9Lk8=";
26 };
27
28 outputs = [
29 "out"
30 "udev"
31 ];
32
33 patches = [
34 (replaceVars ./interpreter.patch {
35 interpreter = (python3Packages.python.withPackages (_: dependencies)).interpreter;
36 })
37 (replaceVars ./use-local-spdx-license-list.patch {
38 spdx_license_list_data = spdx-license-list-data.json;
39 })
40 ./missing-udev-rules-nixos.patch
41 (fetchpatch {
42 # restore PYTHONPATH when calling scons
43 # https://github.com/platformio/platformio-core/commit/097de2be98af533578671baa903a3ae825d90b94
44 url = "https://github.com/platformio/platformio-core/commit/097de2be98af533578671baa903a3ae825d90b94.patch";
45 hash = "sha256-yq+/QHCkhAkFND11MbKFiiWT3oF1cHhgWj5JkYjwuY0=";
46 revert = true;
47 })
48 ./builder-prioritize-python-env-in-path.patch
49 ];
50
51 postPatch = ''
52 # Disable update checks at runtime
53 substituteInPlace platformio/maintenance.py --replace-fail ' check_platformio_upgrade()' ""
54
55 # Remove filterwarnings which fails on new deprecations in Python 3.12 for 3.14
56 rm tox.ini
57 '';
58
59 nativeBuildInputs = [
60 installShellFiles
61 udevCheckHook
62 ];
63
64 build-system = [ setuptools ];
65
66 pythonRelaxDeps = true;
67
68 dependencies = [
69 aiofiles
70 ajsonrpc
71 bottle
72 click
73 click-completion
74 colorama
75 git
76 intelhex
77 lockfile
78 marshmallow
79 pip
80 pyelftools
81 pyserial
82 pyyaml
83 requests
84 semantic-version
85 setuptools
86 spdx-license-list-data.json
87 starlette
88 tabulate
89 uvicorn
90 wheel
91 wsproto
92 zeroconf
93 ]
94 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
95 chardet
96 ];
97
98 preCheck = ''
99 export PATH=$PATH:$out/bin
100 '';
101
102 nativeCheckInputs = [
103 jsondiff
104 pytestCheckHook
105 writableTmpDirAsHomeHook
106 ];
107
108 # Install udev rules into a separate output so all of platformio-core is not a dependency if
109 # you want to use the udev rules on NixOS but not install platformio in your system packages.
110 postInstall = ''
111 mkdir -p $udev/lib/udev/rules.d
112 cp platformio/assets/system/99-platformio-udev.rules $udev/lib/udev/rules.d/99-platformio-udev.rules
113
114 installShellCompletion --cmd platformio \
115 --bash <(_PLATFORMIO_COMPLETE=bash_source $out/bin/platformio) \
116 --zsh <(_PLATFORMIO_COMPLETE=zsh_source $out/bin/platformio) \
117 --fish <(_PLATFORMIO_COMPLETE=fish_source $out/bin/platformio)
118
119 installShellCompletion --cmd pio \
120 --bash <(_PIO_COMPLETE=bash_source $out/bin/pio) \
121 --zsh <(_PIO_COMPLETE=zsh_source $out/bin/pio) \
122 --fish <(_PIO_COMPLETE=fish_source $out/bin/pio)
123 '';
124
125 enabledTestPaths = [
126 "tests"
127 ];
128
129 disabledTestPaths = [
130 "tests/commands/pkg/test_install.py"
131 "tests/commands/pkg/test_list.py"
132 "tests/commands/pkg/test_outdated.py"
133 "tests/commands/pkg/test_search.py"
134 "tests/commands/pkg/test_show.py"
135 "tests/commands/pkg/test_uninstall.py"
136 "tests/commands/pkg/test_update.py"
137 "tests/commands/test_boards.py"
138 "tests/commands/test_check.py"
139 "tests/commands/test_platform.py"
140 "tests/commands/test_run.py"
141 "tests/commands/test_test.py"
142 "tests/misc/test_maintenance.py"
143
144 # requires internet connection
145 "tests/misc/ino2cpp/test_ino2cpp.py"
146
147 "tests/commands/pkg/test_exec.py::test_pkg_specified"
148 "tests/commands/pkg/test_exec.py::test_unrecognized_options"
149 "tests/commands/test_ci.py::test_ci_boards"
150 "tests/commands/test_ci.py::test_ci_build_dir"
151 "tests/commands/test_ci.py::test_ci_keep_build_dir"
152 "tests/commands/test_ci.py::test_ci_lib_and_board"
153 "tests/commands/test_ci.py::test_ci_project_conf"
154 "tests/commands/test_init.py::test_init_custom_framework"
155 "tests/commands/test_init.py::test_init_duplicated_boards"
156 "tests/commands/test_init.py::test_init_enable_auto_uploading"
157 "tests/commands/test_init.py::test_init_ide_atom"
158 "tests/commands/test_init.py::test_init_ide_clion"
159 "tests/commands/test_init.py::test_init_ide_eclipse"
160 "tests/commands/test_init.py::test_init_ide_vscode"
161 "tests/commands/test_init.py::test_init_incorrect_board"
162 "tests/commands/test_init.py::test_init_special_board"
163 "tests/commands/test_lib.py::test_global_install_archive"
164 "tests/commands/test_lib.py::test_global_install_registry"
165 "tests/commands/test_lib.py::test_global_install_repository"
166 "tests/commands/test_lib.py::test_global_lib_list"
167 "tests/commands/test_lib.py::test_global_lib_uninstall"
168 "tests/commands/test_lib.py::test_global_lib_update"
169 "tests/commands/test_lib.py::test_global_lib_update_check"
170 "tests/commands/test_lib.py::test_install_duplicates"
171 "tests/commands/test_lib.py::test_lib_show"
172 "tests/commands/test_lib.py::test_lib_stats"
173 "tests/commands/test_lib.py::test_saving_deps"
174 "tests/commands/test_lib.py::test_search"
175 "tests/commands/test_lib.py::test_update"
176 "tests/commands/test_lib_complex.py::test_global_install_archive"
177 "tests/commands/test_lib_complex.py::test_global_install_registry"
178 "tests/commands/test_lib_complex.py::test_global_install_repository"
179 "tests/commands/test_lib_complex.py::test_global_lib_list"
180 "tests/commands/test_lib_complex.py::test_global_lib_uninstall"
181 "tests/commands/test_lib_complex.py::test_global_lib_update"
182 "tests/commands/test_lib_complex.py::test_global_lib_update_check"
183 "tests/commands/test_lib_complex.py::test_install_duplicates"
184 "tests/commands/test_lib_complex.py::test_lib_show"
185 "tests/commands/test_lib_complex.py::test_lib_stats"
186 "tests/commands/test_lib_complex.py::test_search"
187 "tests/package/test_manager.py::test_download"
188 "tests/package/test_manager.py::test_install_force"
189 "tests/package/test_manager.py::test_install_from_registry"
190 "tests/package/test_manager.py::test_install_lib_depndencies"
191 "tests/package/test_manager.py::test_registry"
192 "tests/package/test_manager.py::test_uninstall"
193 "tests/package/test_manager.py::test_update_with_metadata"
194 "tests/package/test_manager.py::test_update_without_metadata"
195 "tests/test_builder.py::test_build_flags"
196 "tests/test_builder.py::test_build_unflags"
197 "tests/test_builder.py::test_debug_custom_build_flags"
198 "tests/test_builder.py::test_debug_default_build_flags"
199 "tests/test_misc.py::test_api_cache"
200 "tests/test_misc.py::test_ping_internet_ips"
201 "tests/test_misc.py::test_platformio_cli"
202 "tests/test_pkgmanifest.py::test_packages"
203 ];
204
205 disabledTests = [
206 # requires internet connection
207 "test_api_cache"
208 "test_ping_internet_ips"
209 "test_metadata_dump"
210 ];
211
212 passthru = {
213 python = python3Packages.python;
214 };
215
216 meta = with lib; {
217 changelog = "https://github.com/platformio/platformio-core/releases/tag/${src.tag}";
218 description = "Open source ecosystem for IoT development";
219 downloadPage = "https://github.com/platformio/platformio-core";
220 homepage = "https://platformio.org";
221 license = licenses.asl20;
222 maintainers = with maintainers; [
223 mog
224 makefu
225 ];
226 mainProgram = "platformio";
227 };
228}