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