summary refs log tree commit diff
path: root/pkgs/development/arduino
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/arduino')
-rw-r--r--pkgs/development/arduino/arduino-ci/default.nix45
-rw-r--r--pkgs/development/arduino/arduino-cli/default.nix39
-rw-r--r--pkgs/development/arduino/arduino-core/default.nix53
-rw-r--r--pkgs/development/arduino/arduino-core/downloads.nix18
-rw-r--r--pkgs/development/arduino/arduino-mk/default.nix23
-rw-r--r--pkgs/development/arduino/ino/default.nix10
-rw-r--r--pkgs/development/arduino/platformio/chrootenv.nix12
-rw-r--r--pkgs/development/arduino/platformio/core.nix164
-rw-r--r--pkgs/development/arduino/platformio/default.nix14
-rw-r--r--pkgs/development/arduino/platformio/missing-udev-rules-nixos.patch10
-rw-r--r--pkgs/development/arduino/platformio/use-local-spdx-license-list.patch15
11 files changed, 264 insertions, 139 deletions
diff --git a/pkgs/development/arduino/arduino-ci/default.nix b/pkgs/development/arduino/arduino-ci/default.nix
new file mode 100644
index 00000000000..fe28a962e10
--- /dev/null
+++ b/pkgs/development/arduino/arduino-ci/default.nix
@@ -0,0 +1,45 @@
+{ lib, stdenv, fetchFromGitHub,  makeWrapper, arduino-cli, ruby, python3 }:
+
+let
+
+  runtimePath = lib.makeBinPath [
+    arduino-cli
+    python3 # required by the esp8266 core
+  ];
+
+in
+stdenv.mkDerivation rec {
+  pname = "arduino-ci";
+  version = "0.2.0";
+
+  src = fetchFromGitHub {
+    owner  = "pololu";
+    repo   = "arduino-ci";
+    rev    = "v${version}";
+    sha256 = "sha256-9RbBxgwsSQ7oGGKr1Vsn9Ug9AsacoRgvQgd9jbRQ034=";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out/bin
+    install $src/ci.rb $out/bin/arduino-ci
+
+    runHook postInstall
+  '';
+
+  fixupPhase = ''
+    substituteInPlace $out/bin/arduino-ci --replace "/usr/bin/env nix-shell" "${ruby}/bin/ruby"
+    wrapProgram $out/bin/arduino-ci --prefix PATH ":" "${runtimePath}"
+  '';
+
+  meta = with lib; {
+    description = "CI for Arduino Libraries";
+    homepage = src.meta.homepage;
+    license = licenses.mit;
+    maintainers = with maintainers; [ ryantm ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/arduino/arduino-cli/default.nix b/pkgs/development/arduino/arduino-cli/default.nix
index 0fe9ed435d1..84c39dba900 100644
--- a/pkgs/development/arduino/arduino-cli/default.nix
+++ b/pkgs/development/arduino/arduino-cli/default.nix
@@ -1,29 +1,29 @@
-{ stdenv, buildGoModule, fetchFromGitHub, buildFHSUserEnv }:
+{ lib, stdenv, buildGoModule, fetchFromGitHub, buildFHSUserEnv }:
 
 let
 
   pkg = buildGoModule rec {
     pname = "arduino-cli";
-    version = "0.11.0";
+    version = "0.18.1";
 
     src = fetchFromGitHub {
       owner = "arduino";
       repo = pname;
       rev = version;
-      sha256 = "0k9091ci7n7hl44nyzlxkmbwibgrrh9s6z7pgyj9v0mzxjmgz8h2";
+      sha256 = "sha256-EtkONrP/uaetsdC47WsyQOE71Gsz0wKUiTiYThj8Kq8=";
     };
 
     subPackages = [ "." ];
 
-    vendorSha256 = "1qybym95a38az8lk8bqc53ngn08hijckajv8v2giifc4q7sb17d2";
+    vendorSha256 = "sha256-kPIhG6lsH+0IrYfdlzdv/X/cUQb22Xza9Q6ywjKae/4=";
 
     doCheck = false;
 
     buildFlagsArray = [
       "-ldflags=-s -w -X github.com/arduino/arduino-cli/version.versionString=${version} -X github.com/arduino/arduino-cli/version.commit=unknown"
-    ] ++ stdenv.lib.optionals stdenv.isLinux [ "-extldflags '-static'" ];
+    ] ++ lib.optionals stdenv.isLinux [ "-extldflags '-static'" ];
 
-    meta = with stdenv.lib; {
+    meta = with lib; {
       inherit (src.meta) homepage;
       description = "Arduino from the command line";
       license = licenses.gpl3Only;
@@ -32,15 +32,24 @@ let
 
   };
 
+in
+if stdenv.isLinux then
 # buildFHSUserEnv is needed because the arduino-cli downloads compiler
 # toolchains from the internet that have their interpreters pointed at
 # /lib64/ld-linux-x86-64.so.2
-in buildFHSUserEnv {
-  inherit (pkg) name meta;
-
-  runScript = "${pkg.outPath}/bin/arduino-cli";
-
-  extraInstallCommands = ''
-    mv $out/bin/$name $out/bin/arduino-cli
-  '';
-}
+  buildFHSUserEnv
+  {
+    inherit (pkg) name meta;
+
+    runScript = "${pkg.outPath}/bin/arduino-cli";
+
+    extraInstallCommands = ''
+      mv $out/bin/$name $out/bin/arduino-cli
+    '';
+
+    targetPkgs = pkgs: with pkgs; [
+      zlib
+    ];
+  }
+else
+  pkg
diff --git a/pkgs/development/arduino/arduino-core/default.nix b/pkgs/development/arduino/arduino-core/default.nix
index 1c537edd0b4..529be6e2a56 100644
--- a/pkgs/development/arduino/arduino-core/default.nix
+++ b/pkgs/development/arduino/arduino-core/default.nix
@@ -11,7 +11,8 @@
 , ncurses
 , readline
 , withGui ? false
-, gtk2 ? null
+, gtk3 ? null
+, wrapGAppsHook
 , withTeensyduino ? false
   /* Packages needed for Teensyduino */
 , upx
@@ -22,6 +23,7 @@
 , glib
 , pango
 , gdk-pixbuf
+, gtk2
 , libpng12
 , expat
 , freetype
@@ -29,7 +31,7 @@
 , udev
 }:
 
-assert withGui -> gtk2 != null;
+assert withGui -> gtk3 != null && wrapGAppsHook != null;
 assert withTeensyduino -> withGui;
 let
   externalDownloads = import ./downloads.nix {
@@ -46,7 +48,7 @@ let
   ;
   # abiVersion 6 is default, but we need 5 for `avrdude_bin` executable
   ncurses5 = ncurses.override { abiVersion = "5"; };
-  teensy_libpath = stdenv.lib.makeLibraryPath [
+  teensy_libpath = lib.makeLibraryPath [
     atk
     cairo
     expat
@@ -75,52 +77,55 @@ let
                         else throw "${stdenv.hostPlatform.system} is not supported in teensy";
 
   flavor = (if withTeensyduino then "teensyduino" else "arduino")
-             + stdenv.lib.optionalString (!withGui) "-core";
+             + lib.optionalString (!withGui) "-core";
 in
 stdenv.mkDerivation rec {
-  version = "1.8.12";
+  version = "1.8.13";
   name = "${flavor}-${version}";
 
   src = fetchFromGitHub {
     owner = "arduino";
     repo = "Arduino";
     rev = version;
-    sha256 = "0lxkyvsh55biz2q20ba4qabraind5cpxznl41zfq027vl22j6kd2";
+    sha256 = "0qg3qyj1b7wbaw2rsfly7nf3115h26nskl4ggrn6plhx272ni84p";
   };
 
-  teensyduino_version = "151";
+  teensyduino_version = "153";
   teensyduino_src = fetchurl {
     url = "https://www.pjrc.com/teensy/td_${teensyduino_version}/TeensyduinoInstall.${teensy_architecture}";
     sha256 = {
-      linux64 = "0q8mw9bm2vb5vwa98gwcs6ad164i98hc1qqh2qw029yhwm599pn0";
-      linux32 = "1rq6sx0048ab200jy0cz5vznwxi99avidngj42rjnh7kcfas5c4m";
-      linuxarm = "19j55bq36040rpdpfxcqimda76rkbx137q15bs8nvxj13wrbl4ip";
-      linuxaarch64 = "09k78dycn1vcpcx37c1dak8bgjv8gs34l89n9r9s0c3rqmv3pg4x";
+      linux64 = "02qgsj4h4zrjxkcclx7clsqbqd699kg0dq1xxa9hbj3vfnddjv1f";
+      linux32 = "14xaff8xj176ih8ifdvxsly5xgjjm82dqbn7lqq81a43i0svjjyn";
+      linuxarm = "0xpg9axa6dqyhccm9cpvsv2al7rgwy4gv2l8b2kffvn974dl5759";
+      linuxaarch64 = "1lyn4zy4l5mml3c19fw6i2pk1ypnq6mgjmxmzk9d54wpf6n3j5dk";
     }.${teensy_architecture} or (throw "No arduino binaries for ${teensy_architecture}");
   };
   # Used because teensyduino requires jars be a specific size
   arduino_dist_src = fetchurl {
-    url = "http://downloads.arduino.cc/arduino-${version}-${teensy_architecture}.tar.xz";
+    url = "https://downloads.arduino.cc/arduino-${version}-${teensy_architecture}.tar.xz";
     sha256 =
       {
-        linux64 = "128f34kkxz7ab6ir5mqyr8d1mgxig8f9jygwxy44pdnq2rk6gmh9";
-        linux32 = "11n85lwsn1w4ysfacyw08v85s3f3zvl8j8ac7rld19yxgjslvisi";
-        linuxarm = "1k8yjivaydm6y16mplrjyblgx7l0wjzm3mjxh5saxrjq7drswmxx";
-        linuxaarch64 = "04v2nhyjhahml6nmz23bfb63c0an4a7zxgcgxqqq442i8vd304wa";
+        linux64 = "1bdlk51dqiyg5pw23hs8rfv8nrjqy0jqfl89h1466ahahpnd080v";
+        linux32 = "0mgsw9wpwv1pgs2jslzflh7zf4ggqjgcd55hmdzrj0dvgkyw4cr2";
+        linuxarm = "08n4lpak3i7yfyi0085j4nq14gb2n7zx85wl9drp8gaavxnfbp5f";
+        linuxaarch64 = "0m4nhykzknm2hdpz1fhr2hbpncry53kvzs9y5lgj7rx3sy6ygbh7";
       }.${teensy_architecture} or (throw "No arduino binaries for ${teensy_architecture}");
   };
 
 
+  # the glib setup hook will populate GSETTINGS_SCHEMAS_PATH,
+  # wrapGAppHooks (among other things) adds it to XDG_DATA_DIRS
+  # so 'save as...' works:
+  nativeBuildInputs = [ glib wrapGAppsHook unzip ];
   buildInputs = [
     jdk
     ant
     libusb-compat-0_1
     libusb1
-    unzip
     zlib
     ncurses5
     readline
-  ] ++ stdenv.lib.optionals withTeensyduino [ upx ];
+  ] ++ lib.optionals withTeensyduino [ upx ];
   downloadSrcList = builtins.attrValues externalDownloads;
   downloadDstList = builtins.attrNames externalDownloads;
 
@@ -149,7 +154,7 @@ stdenv.mkDerivation rec {
 
   # This will be patched into `arduino` wrapper script
   # Java loads gtk dynamically, so we need to provide it using LD_LIBRARY_PATH
-  dynamicLibraryPath = lib.makeLibraryPath [ gtk2 ];
+  dynamicLibraryPath = lib.makeLibraryPath [ gtk3 ];
   javaPath = lib.makeBinPath [ jdk ];
 
   # Everything else will be patched into rpath
@@ -160,7 +165,7 @@ stdenv.mkDerivation rec {
     cp -r ./build/linux/work/* "$out/share/arduino/"
     echo -n ${version} > $out/share/arduino/lib/version.txt
 
-    ${stdenv.lib.optionalString withGui ''
+    ${lib.optionalString withGui ''
       mkdir -p $out/bin
       substituteInPlace $out/share/arduino/arduino \
         --replace "JAVA=java" "JAVA=$javaPath/java" \
@@ -175,7 +180,7 @@ stdenv.mkDerivation rec {
         --replace '<ICON_NAME>' "$out/share/arduino/icons/128x128/apps/arduino.png"
     ''}
 
-    ${stdenv.lib.optionalString withTeensyduino ''
+    ${lib.optionalString withTeensyduino ''
       # Back up the original jars
       mv $out/share/arduino/lib/arduino-core.jar $out/share/arduino/lib/arduino-core.jar.bak
       mv $out/share/arduino/lib/pde.jar $out/share/arduino/lib/pde.jar.bak
@@ -230,16 +235,16 @@ stdenv.mkDerivation rec {
     mkdir $out/lib/
     ln -s ${lib.makeLibraryPath [ ncurses5 ]}/libtinfo.so.5 $out/lib/libtinfo.so.5
 
-    ${stdenv.lib.optionalString withTeensyduino ''
+    ${lib.optionalString withTeensyduino ''
       # Patch the Teensy loader binary
       patchelf --debug \
           --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
           --set-rpath "${teensy_libpath}" \
-          $out/share/arduino/hardware/tools/teensy
+          $out/share/arduino/hardware/tools/teensy{,_ports,_reboot,_restart,_serialmon}
     ''}
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Open-source electronics prototyping platform";
     homepage = "http://arduino.cc/";
     license = if withTeensyduino then licenses.unfreeRedistributable else licenses.gpl2;
diff --git a/pkgs/development/arduino/arduino-core/downloads.nix b/pkgs/development/arduino/arduino-core/downloads.nix
index f2edf64ceb6..76fa7664f0e 100644
--- a/pkgs/development/arduino/arduino-core/downloads.nix
+++ b/pkgs/development/arduino/arduino-core/downloads.nix
@@ -107,20 +107,20 @@
     url = "https://github.com/arduino-libraries/WiFi101-FirmwareUpdater-Plugin/releases/download/v0.10.10/WiFi101-Updater-ArduinoIDE-Plugin-0.10.10.zip";
     sha256 = "0bs5qdglsfc2q5c48m6wdjpzhz4ya4askh1g8364dp6p7jmg6w0d";
   };
-  "build/avr-1.8.2.tar.bz2" = fetchurl {
-    url = "https://downloads.arduino.cc/cores/avr-1.8.2.tar.bz2";
-    sha256 = "06zl8fwphknd0qdx87fcr1003gid1yqsazaj674mm9widqfd84v2";
+  "build/avr-1.8.3.tar.bz2" = fetchurl {
+    url = "https://downloads.arduino.cc/cores/avr-1.8.3.tar.bz2";
+    sha256 = "051wnc0nmsmxvvs4c79zvjag33yx5il2pz2j7qyjsxkp4jc9p2ny";
   };
 }
 
 // optionalAttrs (system == "x86_64-linux") {
-  "build/arduino-builder-linux64-1.5.2.tar.bz2" = fetchurl {
-    url = "https://downloads.arduino.cc/tools/arduino-builder-linux64-1.5.2.tar.bz2";
-    sha256 = "0wypr9a2cbv9r0ignsr13raw09i3vfc5zvkjxp2xwb7mv35y77z3";
+  "build/arduino-builder-linux64-1.5.4.tar.bz2" = fetchurl {
+    url = "https://downloads.arduino.cc/tools/arduino-builder-linux64-1.5.4.tar.bz2";
+    sha256 = "1cgvwlvxzzpjaj4njz1mrsif27l26dwkz9c7gbhdj0lvlk3xsa7s";
   };
-  "build/linux/avr-gcc-7.3.0-atmel3.6.1-arduino5-x86_64-pc-linux-gnu.tar.bz2" = fetchurl {
-    url = "https://downloads.arduino.cc/tools/avr-gcc-7.3.0-atmel3.6.1-arduino5-x86_64-pc-linux-gnu.tar.bz2";
-    sha256 = "1yq6a811dabrkcgzfi3jsys41r19qsna46kglkjbcy0rza7yvzry";
+  "build/linux/avr-gcc-7.3.0-atmel3.6.1-arduino7-x86_64-pc-linux-gnu.tar.bz2" = fetchurl {
+    url = "https://downloads.arduino.cc/tools/avr-gcc-7.3.0-atmel3.6.1-arduino7-x86_64-pc-linux-gnu.tar.bz2";
+    sha256 = "07nrzv7gsq7bi7ichlw3xsdvgzk0lvv56b73ksn3089ajpv3g35x";
   };
   "build/linux/avrdude-6.3.0-arduino17-x86_64-pc-linux-gnu.tar.bz2" = fetchurl {
     url = "https://downloads.arduino.cc/tools/avrdude-6.3.0-arduino17-x86_64-pc-linux-gnu.tar.bz2";
diff --git a/pkgs/development/arduino/arduino-mk/default.nix b/pkgs/development/arduino/arduino-mk/default.nix
index ff7b7274ca9..d5f506038ca 100644
--- a/pkgs/development/arduino/arduino-mk/default.nix
+++ b/pkgs/development/arduino/arduino-mk/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub }:
+{ stdenv, lib, fetchFromGitHub, python3Packages, installShellFiles }:
 
 stdenv.mkDerivation rec {
   version = "1.6.0";
@@ -11,15 +11,22 @@ stdenv.mkDerivation rec {
     sha256 = "0flpl97d2231gp51n3y4qvf3y1l8xzafi1sgpwc305vwc2h4dl2x";
   };
 
-  phases = ["installPhase"];
-  installPhase = "ln -s $src $out";
+  nativeBuildInputs = [ python3Packages.wrapPython installShellFiles ];
+  propagatedBuildInputs = with python3Packages; [ pyserial ];
+  installPhase = ''
+    mkdir $out
+    cp -rT $src $out
+    installManPage *.1
+  '';
+  postFixupPhase = ''
+    wrapPythonPrograms
+  '';
 
-  meta = {
+  meta = with lib; {
     description = "Makefile for Arduino sketches";
     homepage = "https://github.com/sudar/Arduino-Makefile";
-    license = stdenv.lib.licenses.lgpl21;
-    maintainers = [ stdenv.lib.maintainers.eyjhb ];
-    platforms = stdenv.lib.platforms.unix;
+    license = licenses.lgpl21;
+    maintainers = [ maintainers.eyjhb ];
+    platforms = platforms.unix;
   };
 }
-
diff --git a/pkgs/development/arduino/ino/default.nix b/pkgs/development/arduino/ino/default.nix
index c51d3f89d07..822cfb0e361 100644
--- a/pkgs/development/arduino/ino/default.nix
+++ b/pkgs/development/arduino/ino/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, python2Packages, picocom
+{ lib, fetchurl, python2Packages, picocom
 , avrdude, arduino-core }:
 
 python2Packages.buildPythonApplication rec {
@@ -36,11 +36,11 @@ python2Packages.buildPythonApplication rec {
       --replace "'-C', self.e['avrdude.conf']," ""
   '';
 
-  meta = {
+  meta = with lib; {
     description = "Command line toolkit for working with Arduino hardware";
     homepage = "http://inotool.org/";
-    license = stdenv.lib.licenses.mit;
-    maintainers = with stdenv.lib.maintainers; [ antono ];
-    platforms = stdenv.lib.platforms.linux;
+    license = licenses.mit;
+    maintainers = with maintainers; [ antono ];
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/development/arduino/platformio/chrootenv.nix b/pkgs/development/arduino/platformio/chrootenv.nix
index 62a1d190a00..72384c0994a 100644
--- a/pkgs/development/arduino/platformio/chrootenv.nix
+++ b/pkgs/development/arduino/platformio/chrootenv.nix
@@ -1,11 +1,11 @@
-{ lib, buildFHSUserEnv, fetchFromGitHub }:
+{ lib, buildFHSUserEnv, version, src }:
 
 let
   pio-pkgs = pkgs:
     let
       python = pkgs.python3.override {
         packageOverrides = self: super: {
-          platformio = self.callPackage ./core.nix { };
+          platformio = self.callPackage ./core.nix { inherit version src; };
         };
       };
     in (with pkgs; [
@@ -19,14 +19,6 @@ let
       platformio
     ]);
 
-  src = fetchFromGitHub {
-    owner = "platformio";
-    repo = "platformio-core";
-    rev = "v4.3.4";
-    sha256 = "0vf2j79319ypr4yrdmx84853igkb188sjfvlxgw06rlsvsm3kacq";
-  };
-
-
 in buildFHSUserEnv {
   name = "platformio";
 
diff --git a/pkgs/development/arduino/platformio/core.nix b/pkgs/development/arduino/platformio/core.nix
index 891d613da51..344835b831b 100644
--- a/pkgs/development/arduino/platformio/core.nix
+++ b/pkgs/development/arduino/platformio/core.nix
@@ -1,41 +1,126 @@
-{ stdenv, lib, buildPythonApplication, fetchFromGitHub, fetchpatch
-, bottle, click, colorama, semantic-version
-, lockfile, pyserial, requests
-, tabulate, pyelftools, marshmallow
-, pytest, tox, jsondiff
-, git, spdx-license-list-data
+{ stdenv, lib, python3
+, fetchFromGitHub
+, git
+, spdx-license-list-data
+, version, src
 }:
 
 let
-  args = lib.concatStringsSep " " ((map (e: "--deselect tests/${e}") [
+  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_project_conf"
-    "commands/test_ci.py::test_ci_lib_and_board"
     "commands/test_ci.py::test_ci_build_dir"
     "commands/test_ci.py::test_ci_keep_build_dir"
-    "commands/test_init.py::test_init_enable_auto_uploading"
+    "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_incorrect_board"
+    "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_duplicated_boards"
+    "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_search"
-    "commands/test_lib.py::test_install_duplicates"
-    "commands/test_lib.py::test_global_lib_update_check"
-    "commands/test_lib.py::test_global_lib_update"
-    "commands/test_lib.py::test_global_lib_uninstall"
-    "commands/test_lib.py::test_lib_show"
-    "commands/test_lib.py::test_lib_stats"
-    "commands/test_lib.py::test_global_install_registry"
     "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_default_build_flags"
     "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"
@@ -47,38 +132,10 @@ let
     "commands/test_update.py"
     "test_maintenance.py"
     "test_ino2cpp.py"
-  ]));
-
-in buildPythonApplication rec {
-  pname = "platformio";
-  version = "4.3.4";
-
-  # 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 = "0vf2j79319ypr4yrdmx84853igkb188sjfvlxgw06rlsvsm3kacq";
-  };
-
-  propagatedBuildInputs =  [
-    bottle click colorama git lockfile
-    pyserial requests semantic-version
-    tabulate pyelftools marshmallow
+  ]) ++ [
+    "tests"
   ];
 
-  HOME = "/tmp";
-
-  checkInputs = [ pytest tox jsondiff ];
-
-  checkPhase = ''
-    runHook preCheck
-
-    py.test -v tests ${args}
-
-    runHook postCheck
-  '';
-
   patches = [
     ./fix-searchpath.patch
     ./use-local-spdx-license-list.patch
@@ -88,9 +145,12 @@ in buildPythonApplication rec {
   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 stdenv.lib; {
+  meta = with lib; {
     broken = stdenv.isAarch64;
     description = "An open source ecosystem for IoT development";
     homepage = "http://platformio.org";
diff --git a/pkgs/development/arduino/platformio/default.nix b/pkgs/development/arduino/platformio/default.nix
index 280fd496650..312c2d1044b 100644
--- a/pkgs/development/arduino/platformio/default.nix
+++ b/pkgs/development/arduino/platformio/default.nix
@@ -1,11 +1,21 @@
 
-{ newScope }:
+{ 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 { };
+    platformio-chrootenv = callPackage ./chrootenv.nix { inherit version src; };
   };
 
 in self
diff --git a/pkgs/development/arduino/platformio/missing-udev-rules-nixos.patch b/pkgs/development/arduino/platformio/missing-udev-rules-nixos.patch
index f29b93cef4d..36af82245c5 100644
--- a/pkgs/development/arduino/platformio/missing-udev-rules-nixos.patch
+++ b/pkgs/development/arduino/platformio/missing-udev-rules-nixos.patch
@@ -1,13 +1,11 @@
 diff --git a/platformio/exception.py b/platformio/exception.py
-index d291ad7f..4761a35b 100644
+index ef1d3bab..445174fc 100644
 --- a/platformio/exception.py
 +++ b/platformio/exception.py
-@@ -195,7 +195,8 @@ class MissedUdevRules(InvalidUdevRules):
- 
+@@ -57,6 +57,7 @@ class MissedUdevRules(InvalidUdevRules):
      MESSAGE = (
-         "Warning! Please install `99-platformio-udev.rules`. \nMode details: "
--        "https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules"
-+        "https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules\n"
+         "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/arduino/platformio/use-local-spdx-license-list.patch b/pkgs/development/arduino/platformio/use-local-spdx-license-list.patch
index 953eb3c9289..e0016adcf7d 100644
--- a/pkgs/development/arduino/platformio/use-local-spdx-license-list.patch
+++ b/pkgs/development/arduino/platformio/use-local-spdx-license-list.patch
@@ -1,16 +1,15 @@
 diff --git a/platformio/package/manifest/schema.py b/platformio/package/manifest/schema.py
-index be49b3ee..d1390a88 100644
+index addc4c5..514b0ad 100644
 --- a/platformio/package/manifest/schema.py
 +++ b/platformio/package/manifest/schema.py
-@@ -240,9 +240,5 @@ class ManifestSchema(BaseSchema):
+@@ -253,9 +253,4 @@ class ManifestSchema(BaseSchema):
      @staticmethod
      @memoized(expire="1h")
      def load_spdx_licenses():
--        r = requests.get(
--            "https://raw.githubusercontent.com/spdx/license-list-data"
--            "/v3.9/json/licenses.json"
+-        version = "3.12"
+-        spdx_data_url = (
+-            "https://raw.githubusercontent.com/spdx/license-list-data/"
+-            "v%s/json/licenses.json" % version
 -        )
--        r.raise_for_status()
--        return r.json()
-+        import json
+-        return json.loads(fetch_remote_content(spdx_data_url))
 +        return json.load(open("@SPDX_LICENSE_LIST_DATA@/json/licenses.json"))