diff options
author | Pooya Moradi <pvonmoradi@gmail.com> | 2021-08-14 19:02:33 +0430 |
---|---|---|
committer | Pooya Moradi <pvonmoradi@gmail.com> | 2021-08-16 15:29:57 +0430 |
commit | 08d9ac46db3304a6f10b015d04839c3b1d13aa36 (patch) | |
tree | 5aac2a73ca6759a3c3d635cbedf265fec80f6c80 /pkgs/development/embedded/platformio | |
parent | 9f62ba081e3f0d87227939c3453296fd65746842 (diff) | |
download | nixpkgs-08d9ac46db3304a6f10b015d04839c3b1d13aa36.tar nixpkgs-08d9ac46db3304a6f10b015d04839c3b1d13aa36.tar.gz nixpkgs-08d9ac46db3304a6f10b015d04839c3b1d13aa36.tar.bz2 nixpkgs-08d9ac46db3304a6f10b015d04839c3b1d13aa36.tar.lz nixpkgs-08d9ac46db3304a6f10b015d04839c3b1d13aa36.tar.xz nixpkgs-08d9ac46db3304a6f10b015d04839c3b1d13aa36.tar.zst nixpkgs-08d9ac46db3304a6f10b015d04839c3b1d13aa36.zip |
platformio: move the directory to pkgs/development/embedded/
Diffstat (limited to 'pkgs/development/embedded/platformio')
6 files changed, 265 insertions, 0 deletions
diff --git a/pkgs/development/embedded/platformio/chrootenv.nix b/pkgs/development/embedded/platformio/chrootenv.nix new file mode 100644 index 00000000000..72384c0994a --- /dev/null +++ b/pkgs/development/embedded/platformio/chrootenv.nix @@ -0,0 +1,44 @@ +{ lib, buildFHSUserEnv, version, src }: + +let + pio-pkgs = pkgs: + let + python = pkgs.python3.override { + packageOverrides = self: super: { + platformio = self.callPackage ./core.nix { inherit version src; }; + }; + }; + in (with pkgs; [ + zlib + git + ]) ++ (with python.pkgs; [ + python + setuptools + pip + bottle + platformio + ]); + +in buildFHSUserEnv { + name = "platformio"; + + targetPkgs = pio-pkgs; + multiPkgs = pio-pkgs; + + meta = with lib; { + description = "An open source ecosystem for IoT development"; + homepage = "https://platformio.org"; + maintainers = with maintainers; [ mog ]; + license = licenses.asl20; + platforms = with platforms; linux; + }; + + extraInstallCommands = '' + mkdir -p $out/lib/udev/rules.d + + ln -s $out/bin/platformio $out/bin/pio + ln -s ${src}/scripts/99-platformio-udev.rules $out/lib/udev/rules.d/99-platformio-udev.rules + ''; + + runScript = "platformio"; +} diff --git a/pkgs/development/embedded/platformio/core.nix b/pkgs/development/embedded/platformio/core.nix new file mode 100644 index 00000000000..344835b831b --- /dev/null +++ b/pkgs/development/embedded/platformio/core.nix @@ -0,0 +1,160 @@ +{ stdenv, lib, python3 +, fetchFromGitHub +, git +, spdx-license-list-data +, version, src +}: + +let + python = python3.override { + packageOverrides = self: super: { + aiofiles = super.aiofiles.overridePythonAttrs (oldAttrs: rec { + version = "0.6.0"; + src = oldAttrs.src.override { + inherit version; + sha256 = "e0281b157d3d5d59d803e3f4557dcc9a3dff28a4dd4829a9ff478adae50ca092"; + }; + }); + + click = super.click.overridePythonAttrs (oldAttrs: rec { + version = "7.1.2"; + src = oldAttrs.src.override { + inherit version; + sha256 = "06kbzd6sjfkqan3miwj9wqyddfxc2b6hi7p5s4dvqjb3gif2bdfj"; + }; + }); + + uvicorn = super.uvicorn.overridePythonAttrs (oldAttrs: rec { + version = "0.13.2"; + src = fetchFromGitHub { + owner = "encode"; + repo = "uvicorn"; + rev = version; + sha256 = "04zgmp9z46k72ay6cz7plga6d3w3a6x41anabm7ramp7jdqf6na9"; + }; + }); + }; + }; +in +with python.pkgs; buildPythonApplication rec { + pname = "platformio"; + inherit version src; + + propagatedBuildInputs = [ + ajsonrpc + bottle + click + click-completion + colorama + git + lockfile + marshmallow + pyelftools + pyserial + requests + semantic-version + starlette + tabulate + uvicorn + wsproto + zeroconf + ]; + + HOME = "/tmp"; + + checkInputs = [ + jsondiff + pytestCheckHook + tox + ]; + + pytestFlagsArray = (map (e: "--deselect tests/${e}") [ + "commands/test_ci.py::test_ci_boards" + "commands/test_ci.py::test_ci_build_dir" + "commands/test_ci.py::test_ci_keep_build_dir" + "commands/test_ci.py::test_ci_lib_and_board" + "commands/test_ci.py::test_ci_project_conf" + "commands/test_init.py::test_init_custom_framework" + "commands/test_init.py::test_init_duplicated_boards" + "commands/test_init.py::test_init_enable_auto_uploading" + "commands/test_init.py::test_init_ide_atom" + "commands/test_init.py::test_init_ide_eclipse" + "commands/test_init.py::test_init_ide_vscode" + "commands/test_init.py::test_init_incorrect_board" + "commands/test_init.py::test_init_special_board" + "commands/test_lib.py::test_global_install_archive" + "commands/test_lib.py::test_global_install_registry" + "commands/test_lib.py::test_global_install_repository" + "commands/test_lib.py::test_global_lib_list" + "commands/test_lib.py::test_global_lib_uninstall" + "commands/test_lib.py::test_global_lib_update" + "commands/test_lib.py::test_global_lib_update_check" + "commands/test_lib.py::test_install_duplicates" + "commands/test_lib.py::test_lib_show" + "commands/test_lib.py::test_lib_stats" + "commands/test_lib.py::test_saving_deps" + "commands/test_lib.py::test_search" + "commands/test_lib.py::test_update" + "commands/test_lib_complex.py::test_global_install_archive" + "commands/test_lib_complex.py::test_global_install_registry" + "commands/test_lib_complex.py::test_global_install_repository" + "commands/test_lib_complex.py::test_global_lib_list" + "commands/test_lib_complex.py::test_global_lib_uninstall" + "commands/test_lib_complex.py::test_global_lib_update" + "commands/test_lib_complex.py::test_global_lib_update_check" + "commands/test_lib_complex.py::test_install_duplicates" + "commands/test_lib_complex.py::test_lib_show" + "commands/test_lib_complex.py::test_lib_stats" + "commands/test_lib_complex.py::test_search" + "commands/test_test.py::test_local_env" + "commands/test_test.py::test_multiple_env_build" + "commands/test_test.py::test_setup_teardown_are_compilable" + "package/test_manager.py::test_download" + "package/test_manager.py::test_install_force" + "package/test_manager.py::test_install_from_registry" + "package/test_manager.py::test_install_lib_depndencies" + "package/test_manager.py::test_registry" + "package/test_manager.py::test_uninstall" + "package/test_manager.py::test_update_with_metadata" + "package/test_manager.py::test_update_without_metadata" + "test_builder.py::test_build_flags" + "test_builder.py::test_build_unflags" + "test_builder.py::test_debug_custom_build_flags" + "test_builder.py::test_debug_default_build_flags" + "test_misc.py::test_api_cache" + "test_misc.py::test_ping_internet_ips" + "test_misc.py::test_platformio_cli" + "test_pkgmanifest.py::test_packages" + ]) ++ (map (e: "--ignore=tests/${e}") [ + "commands/test_boards.py" + "commands/test_check.py" + "commands/test_platform.py" + "commands/test_update.py" + "test_maintenance.py" + "test_ino2cpp.py" + ]) ++ [ + "tests" + ]; + + patches = [ + ./fix-searchpath.patch + ./use-local-spdx-license-list.patch + ./missing-udev-rules-nixos.patch + ]; + + postPatch = '' + substitute platformio/package/manifest/schema.py platformio/package/manifest/schema.py \ + --subst-var-by SPDX_LICENSE_LIST_DATA '${spdx-license-list-data}' + + substituteInPlace setup.py \ + --replace "zeroconf==0.28.*" "zeroconf" + ''; + + meta = with lib; { + broken = stdenv.isAarch64; + description = "An open source ecosystem for IoT development"; + homepage = "http://platformio.org"; + license = licenses.asl20; + maintainers = with maintainers; [ mog makefu ]; + }; +} diff --git a/pkgs/development/embedded/platformio/default.nix b/pkgs/development/embedded/platformio/default.nix new file mode 100644 index 00000000000..312c2d1044b --- /dev/null +++ b/pkgs/development/embedded/platformio/default.nix @@ -0,0 +1,21 @@ + +{ newScope, fetchFromGitHub }: + +let + callPackage = newScope self; + + version = "5.1.1"; + + # pypi tarballs don't contain tests - https://github.com/platformio/platformio-core/issues/1964 + src = fetchFromGitHub { + owner = "platformio"; + repo = "platformio-core"; + rev = "v${version}"; + sha256 = "1m9vq5r4g04n3ckmb3hrrc4ar5v31k6isc76bw4glrn2xb7r8c00"; + }; + + self = { + platformio-chrootenv = callPackage ./chrootenv.nix { inherit version src; }; + }; + +in self diff --git a/pkgs/development/embedded/platformio/fix-searchpath.patch b/pkgs/development/embedded/platformio/fix-searchpath.patch new file mode 100644 index 00000000000..46e84d15a82 --- /dev/null +++ b/pkgs/development/embedded/platformio/fix-searchpath.patch @@ -0,0 +1,13 @@ +diff --git a/platformio/proc.py b/platformio/proc.py +index 80e50201..15cee5a5 100644 +--- a/platformio/proc.py ++++ b/platformio/proc.py +@@ -167,7 +167,7 @@ def copy_pythonpath_to_osenv(): + conditions.append(isdir(join(p, "click")) or isdir(join(p, "platformio"))) + if all(conditions): + _PYTHONPATH.append(p) +- os.environ["PYTHONPATH"] = os.pathsep.join(_PYTHONPATH) ++ os.environ["PYTHONPATH"] = os.pathsep.join(sys.path) + + + def where_is_program(program, envpath=None): diff --git a/pkgs/development/embedded/platformio/missing-udev-rules-nixos.patch b/pkgs/development/embedded/platformio/missing-udev-rules-nixos.patch new file mode 100644 index 00000000000..36af82245c5 --- /dev/null +++ b/pkgs/development/embedded/platformio/missing-udev-rules-nixos.patch @@ -0,0 +1,12 @@ +diff --git a/platformio/exception.py b/platformio/exception.py +index ef1d3bab..445174fc 100644 +--- a/platformio/exception.py ++++ b/platformio/exception.py +@@ -57,6 +57,7 @@ class MissedUdevRules(InvalidUdevRules): + MESSAGE = ( + "Warning! Please install `99-platformio-udev.rules`. \nMore details: " + "https://docs.platformio.org/page/faq.html#platformio-udev-rules" ++ "On NixOS add the platformio package to services.udev.packages" + ) + + diff --git a/pkgs/development/embedded/platformio/use-local-spdx-license-list.patch b/pkgs/development/embedded/platformio/use-local-spdx-license-list.patch new file mode 100644 index 00000000000..e0016adcf7d --- /dev/null +++ b/pkgs/development/embedded/platformio/use-local-spdx-license-list.patch @@ -0,0 +1,15 @@ +diff --git a/platformio/package/manifest/schema.py b/platformio/package/manifest/schema.py +index addc4c5..514b0ad 100644 +--- a/platformio/package/manifest/schema.py ++++ b/platformio/package/manifest/schema.py +@@ -253,9 +253,4 @@ class ManifestSchema(BaseSchema): + @staticmethod + @memoized(expire="1h") + def load_spdx_licenses(): +- version = "3.12" +- spdx_data_url = ( +- "https://raw.githubusercontent.com/spdx/license-list-data/" +- "v%s/json/licenses.json" % version +- ) +- return json.loads(fetch_remote_content(spdx_data_url)) ++ return json.load(open("@SPDX_LICENSE_LIST_DATA@/json/licenses.json")) |