Updated project details

This commit is contained in:
2026-08-18 20:56:07 -05:00
parent 168bbd9300
commit 84c79bce65
11 changed files with 4308 additions and 299 deletions
+82 -117
View File
@@ -1,5 +1,5 @@
{
description = "A Nix-flake-based Rust development environment";
description = "ColdIron - Learning Rust and Iced";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
@@ -9,19 +9,16 @@
};
};
outputs =
inputs@{ self, ... }:
let
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forEachSupportedSystem =
f:
inputs.nixpkgs.lib.genAttrs supportedSystems (
system:
outputs = inputs @ {self, ...}: let
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forEachSupportedSystem = f:
inputs.nixpkgs.lib.genAttrs supportedSystems (
system:
f {
pkgs = import inputs.nixpkgs {
inherit system;
@@ -30,36 +27,58 @@
];
};
}
);
in {
overlays.default = _final: prev: {
rustToolchain = with inputs.fenix.packages.${prev.stdenv.hostPlatform.system};
combine (
with stable; [
clippy
rustc
cargo
rustfmt
rust-src
]
);
in
{
templates = {
coldiron = prev.callPackage ./package.nix {};
};
packages = forEachSupportedSystem (
{pkgs}: {
default = pkgs.callPackage ./package.nix {};
coldiron = pkgs.callPackage ./package.nix {};
}
);
apps = forEachSupportedSystem (
{pkgs}: {
default = {
path = ./.;
description = "Rust dev environment using fenix; includes a skeletal Cargo project and packaged helper app";
type = "app";
program = pkgs.lib.getExe self.packages.${pkgs.stdenv.hostPlatform.system}.default;
};
};
coldiron = {
type = "app";
program = pkgs.lib.getExe self.packages.${pkgs.stdenv.hostPlatform.system}.coldiron;
};
}
);
overlays.default = _final: prev: {
rustToolchain =
with inputs.fenix.packages.${prev.stdenv.hostPlatform.system};
combine (
with stable;
devShells = forEachSupportedSystem (
{pkgs}: let
runtimeLibs = with pkgs; [
wayland
libxkbcommon
libGL
vulkan-loader
libx11
libxcursor
libxrandr
libxi
];
in {
default = pkgs.mkShell {
packages = with pkgs;
[
clippy
rustc
cargo
rustfmt
rust-src
]
);
};
devShells = forEachSupportedSystem (
{ pkgs }:
{
default = pkgs.mkShell {
packages = with pkgs; [
rustToolchain
git
gnumake
@@ -73,88 +92,34 @@
cargo-deny
cargo-edit
cargo-watch
cargo-generate
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
];
]
++ runtimeLibs;
env = {
# Required by rust-analyzer
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
};
shellHook = ''
# Initialize git repository if not already present
if [ ! -d .git ]; then
git init
echo "✓ Initialized git repository"
fi
# Ensure user's Cargo-installed binaries are available
export PATH="$HOME/.cargo/bin:$PATH"
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 "[rust-template] 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."
'';
};
}
);
packages = forEachSupportedSystem (
{ pkgs }:
{
# Build the skeletal Cargo project
default = pkgs.rustPlatform.buildRustPackage {
pname = "sample-rust-app";
version = "0.1.0";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
env = {
# Required by rust-analyzer
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath runtimeLibs;
};
devHelper = pkgs.writeShellScriptBin "dev-helper" ''
echo "Rust toolchain available:"
command -v cargo >/dev/null 2>&1 && cargo --version || true
command -v rustc >/dev/null 2>&1 && rustc --version || true
echo "This binary is built by Nix (packages.default)."
shellHook = ''
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath runtimeLibs}:$LD_LIBRARY_PATH"
# Initialize git repository if not already present
if [ ! -d .git ]; then
git init
echo "✓ Initialized git repository"
fi
# Ensure user's Cargo-installed binaries are available
export PATH="$HOME/.cargo/bin:$PATH"
echo "[ColdIron] Welcome to the ColdIron development shell!"
echo "Commands: 'cargo run' to start GUI, 'cargo test' to run tests, 'make flatpak-build' for Flatpak."
'';
}
);
apps = forEachSupportedSystem (
{ pkgs }:
{
default = {
type = "app";
program = pkgs.lib.getExe self.packages.${pkgs.stdenv.hostPlatform.system}.default;
};
dev-helper = {
type = "app";
program = pkgs.lib.getExe self.packages.${pkgs.stdenv.hostPlatform.system}.devHelper;
};
}
);
};
};
}
);
};
}