Platformio
PlatformIO is a SDK/toolchain manager for various microcontrollers and and embedded platforms i.e. esp32.
Basic development environment
{ pkgs ? import <nixpkgs> {} }:
let
in
pkgs.mkShell {
buildInputs = [
pkgs.platformio
# optional: needed as a programmer i.e. for esp32
# pkgs.avrdude
];
}
NixOS
Add the required udev rules.
{
services.udev.packages = [
pkgs.platformio-core
pkgs.openocd
];
}
Use in vscode
To use the nix-shell provided PlatformIO rather the builtin one first open vscode
within the nix-shell
and also modify it's settings.json
to also contain the following line:
{
"platformio-ide.useBuiltinPIOCore": false,
}
As of PlatformIO IDE 2.0.0, you will need a shell that allows the extension to run “python -m platformio” (#237313):
{ pkgs ? import (builtins.fetchTarball {
# NixOS/nixpkgs#237313 = ppenguin:refactor-platformio-fix-ide
url = "https://github.com/NixOS/nixpkgs/archive/3592b10a67b518700002f1577e301d73905704fe.tar.gz";
}) {},
}:
let
envname = "platformio-fhs";
mypython = pkgs.python3.withPackages (ps: with ps; [ platformio ]);
in
(pkgs.buildFHSUserEnv {
name = envname;
targetPkgs = pkgs: (with pkgs; [
platformio-core
mypython
openocd
]);
# NixOS/nixpkgs#263201, NixOS/nixpkgs#262775, NixOS/nixpkgs#262080
runScript = "env LD_LIBRARY_PATH= bash";
}).env