Files
nix-home-manager/home/embedded.nix
2026-01-26 20:33:31 +01:00

87 lines
2.2 KiB
Nix
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# You should run espup-init once per user to install toolchains.
#
# For STM32/RP2040, youll likely configure chip names in flash-stm.
#
# Add .cargo/config.toml for probe-rs targets like:
# [target.riscv32imac-unknown-none-elf]
# runner = "probe-rs run"
#
# Set up arduino-cli using:
# arduino-cli config init
# arduino-cli core update-index
# arduino-cli core install arduino:avr
#
{ config, pkgs, lib, ... }:
let
cfg = config.homeModules.embedded;
in
lib.mkIf cfg.enable {
home.packages = with pkgs; [
# General embedded tools
rustup
binutils
cargo-binutils
llvmPackages.bintools
openocd
dfu-util
minicom
picocom
lldb
gcc
gdb
# qemu # quick emulator
# gnumake
# pkg-config
# ARM toolchains
gcc-arm-embedded
# Espressif ESP32
espup
espflash
#espmonitor
ldproxy
cargo-espflash
# ST-Link / J-Link / Debug probes
probe-rs
#jlink
# Arduino
arduino-cli
];
# Optional system envs for toolchains or common paths
home.sessionVariables = {
ESPUP_INSTALL_PATH = "${config.home.homeDirectory}/.espressif";
RUSTUP_HOME = "${config.home.homeDirectory}/.rustup";
CARGO_HOME = "${config.home.homeDirectory}/.cargo";
};
# Udev rules for embedded devices (ESP, STLink, J-Link, Arduino)
# These must be placed on a NixOS system-wide level; for non-NixOS we print a helper
home.activation.printUdevHint = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
echo "📎 Embedded development: Make sure you have correct udev rules installed for USB devices."
echo "Examples:"
echo " - https://github.com/espressif/esp-idf/blob/master/tools/udev/60-esper-devices.rules"
echo " - https://probe.rs/docs/getting-started/installation/#udev-rules"
echo " - https://www.arduino.cc/en/guide/linux"
echo " - For STLink and J-Link adapters: udev rules are required for non-root flashing."
'';
# Optional: shell aliases to speed up common flows
programs.zsh.shellAliases = {
espup-init = "espup install";
flash-esp = "cargo espflash";
monitor-esp = "espmonitor";
flash-stm = "cargo flash --chip";
embed = "cargo embed";
};
programs.direnv.enable = true;
programs.direnv.nix-direnv.enable = true;
}