Refactor README and flake.nix for improved development environment setup; remove embedded Rust tooling references and add Cargo productivity tools

This commit is contained in:
2026-05-23 09:56:42 -05:00
parent 6a825d1e83
commit 5794b593fa
3 changed files with 28 additions and 61 deletions
@@ -0,0 +1 @@
disable = true
+11 -28
View File
@@ -15,8 +15,6 @@ direnv allow
When you enter the devShell (via `direnv allow` or `nix develop`), the following happens automatically: When you enter the devShell (via `direnv allow` or `nix develop`), the following happens automatically:
**Git Repository**: Initializes `.git` if not present **Git Repository**: Initializes `.git` if not present
**Rust Targets**: Automatically adds common embedded Rust targets (ARM Cortex-M, RISC-V)
**Cargo Paths**: Sets up `$HOME/.cargo/bin` in PATH for cargo-installed binaries
**Welcome Banner**: Displays available tools and quick commands **Welcome Banner**: Displays available tools and quick commands
No manual setup needed! Just start coding. No manual setup needed! Just start coding.
@@ -24,32 +22,17 @@ No manual setup needed! Just start coding.
## Quickstart ## Quickstart
```sh ```sh
nix flake init -t path:../flakes#rust
nix develop nix develop
cargo build cargo build
``` ```
## Embedded Rust Support
The devShell automatically installs common embedded Rust targets via `rustup`:
| Target | Platform | Use Case |
|--------|----------|----------|
| `thumbv6m-none-eabi` | ARM Cortex-M0/M0+ | RP2040 (Pico) |
| `thumbv7em-none-eabihf` | ARM Cortex-M4F/M7F | STM32, nRF52840 |
| `riscv32imc-unknown-none-elf` | RISC-V 32-bit | ESP32-C3 (basic) |
| `riscv32imac-unknown-none-elf` | RISC-V 32-bit (atomic) | ESP32-C3 (advanced) |
**Note:** ESP32 Xtensa targets require espup or custom toolchains (see [esp-rs](https://github.com/esp-rs)).
## Flatpak Packaging ## Flatpak Packaging
This project supports building Flatpak packages for the FeDIY application. This project supports building Flatpak packages for the FeDIY application.
### Build Flatpak Package ### Build Flatpak Package
1. Ensure you have `flatpak-builder` installed. 1. Run:
2. Run:
```bash ```bash
make flatpak-build make flatpak-build
@@ -80,14 +63,11 @@ flatpak run com.moturpin.fediy
| **rustfmt** | Rust code formatter | | **rustfmt** | Rust code formatter |
| **rust-analyzer** | Language server for IDE integration | | **rust-analyzer** | Language server for IDE integration |
| **rust-src** | Rust source code (for tools like rust-analyzer) | | **rust-src** | Rust source code (for tools like rust-analyzer) |
| **probe-rs** | Embedded debugger/flasher for ARM targets | | **cargo-deny** | Audit dependencies for advisories and license policy |
| **espflash** | Flashing tool for ESP32 boards | | **cargo-edit** | Add/remove/upgrade Cargo dependencies from the CLI |
| **openocd** | JTAG/SWD debugger for ARM and other targets | | **cargo-watch** | Auto-rebuild on file changes |
| **minicom** | Serial terminal for device output | | **flatpak-builder** | Build Flatpak distribution packages |
| **elf2uf2-rs** | Convert ELF to UF2 format (RP2040) | | **pre-commit** | Run pre-commit hooks |
| **picotool** | Pico-specific firmware operations |
| **avrdude** | AVR microcontroller programmer |
| **ravedude** | Rapid AVR development utility |
## Testing & Development Features ## Testing & Development Features
@@ -109,8 +89,11 @@ cargo clippy
# Format code # Format code
cargo fmt cargo fmt
# Build for embedded target # Watch and rebuild on changes
cargo build --target thumbv7em-none-eabihf --release cargo watch -x build
# Build a Flatpak
make flatpak-build
``` ```
## Project Layout ## Project Layout
+16 -33
View File
@@ -60,30 +60,22 @@
{ {
default = pkgs.mkShell { default = pkgs.mkShell {
packages = with pkgs; [ packages = with pkgs; [
# Rust toolchain (managed by fenix overlay)
rustToolchain rustToolchain
rust-analyzer
# Build essentials
git git
gnumake gnumake
openssl openssl
pkg-config pkg-config
# Cargo productivity tools
cargo-deny cargo-deny
cargo-edit cargo-edit
cargo-watch cargo-watch
cargo-generate # Code quality
rust-analyzer
rustup
# Embedded Rust tooling
probe-rs-tools
espflash
openocd
minicom
# RP2040 UF2 workflows
elf2uf2-rs
picotool
avrdude
pkgsCross.avr.buildPackages.libc
pkgsCross.avr.buildPackages.gcc
ravedude
pre-commit pre-commit
# Packaging
flatpak-builder
]; ];
env = { env = {
@@ -98,20 +90,9 @@
echo " Initialized git repository" echo " Initialized git repository"
fi fi
# Ensure user's Cargo-installed binaries are available echo "[FeDIY] Welcome to the dev shell!"
export PATH="$HOME/.cargo/bin:$PATH" echo "Tools: cargo, rustc, clippy, rustfmt, rust-analyzer, flatpak-builder"
echo "Run 'cargo build' to build, 'make flatpak-build' for Flatpak, or 'nix run .#dev-helper' for a tool summary."
if command -v rustup >/dev/null 2>&1; then
echo "Ensuring common embedded Rust targets are available (idempotent)..."
rustup target add thumbv6m-none-eabi >/dev/null 2>&1 || true # Cortex-M0/M0+ (RP2040)
rustup target add thumbv7em-none-eabihf >/dev/null 2>&1 || true # Cortex-M4F/M7F (many STM32/nRF52)
rustup target add riscv32imc-unknown-none-elf >/dev/null 2>&1 || true
rustup target add riscv32imac-unknown-none-elf >/dev/null 2>&1 || true # ESP32-C3 class
echo "Note: ESP32 Xtensa targets require espup/custom toolchains (see esp-rs)."
fi
echo "[FeDIY] Welcome to the Rust dev shell!"
echo "Tools: cargo, rustc, clippy, rustfmt, rust-analyzer, probe-rs, espflash, openocd, minicom, elf2uf2-rs, picotool, avrdude, ravedude"
echo "Run 'cargo build' to build, or 'nix run .#dev-helper' for a tool summary."
echo "See README.md for usage." echo "See README.md for usage."
''; '';
}; };
@@ -130,10 +111,12 @@
}; };
devHelper = pkgs.writeShellScriptBin "dev-helper" '' devHelper = pkgs.writeShellScriptBin "dev-helper" ''
echo "Rust toolchain available:" echo "=== FeDIY dev shell tools ==="
command -v cargo >/dev/null 2>&1 && cargo --version || true command -v cargo >/dev/null 2>&1 && echo "cargo: $(cargo --version)" || echo "cargo: not found"
command -v rustc >/dev/null 2>&1 && rustc --version || true command -v rustc >/dev/null 2>&1 && echo "rustc: $(rustc --version)" || echo "rustc: not found"
echo "This binary is built by Nix (packages.default)." command -v rust-analyzer >/dev/null 2>&1 && echo "rust-analyzer: $(rust-analyzer --version)" || echo "rust-analyzer: not found"
command -v flatpak-builder >/dev/null 2>&1 && echo "flatpak-builder: $(flatpak-builder --version)" || echo "flatpak-builder: not found"
command -v pre-commit >/dev/null 2>&1 && echo "pre-commit: $(pre-commit --version)" || echo "pre-commit: not found"
''; '';
} }
); );