xtensa zig flake

This commit is contained in:
Priec
2026-02-24 01:00:33 +01:00
parent fe4af063e0
commit 8082994802
3 changed files with 41 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
{ {
description = "Zig Master Development Environment"; description = "Zig Host + Zig Xtensa (ESP32) Environment";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
@@ -11,18 +11,44 @@
let let
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
zig = zig-overlay.packages.${system}.master; zig_host = zig-overlay.packages.${system}.master;
zls = zls-overlay.packages.${system}.zls; zls = zls-overlay.packages.${system}.zls;
zig_xtensa = pkgs.stdenvNoCC.mkDerivation {
pname = "zig-xtensa";
version = "0.15.2";
src = pkgs.fetchzip {
url = "https://github.com/haivivi/embed-zig/releases/download/espressif-0.15.2/zig-x86_64-linux-gnu-baseline.tar.xz";
# Opraveny hash podla hlásenia Nixu
hash = "sha256-Wyc36nKM2PqljI4W8LsnEcVtrmchwQDoaUHAYOI0g1I=";
stripRoot = false;
};
dontBuild = true;
installPhase = ''
mkdir -p $out/bin
cp -r . $out/
# Symlink na binárku vo vnútri vnoreného adresára
ln -s $out/zig-x86_64-linux-gnu-baseline/zig $out/bin/zig-xtensa
'';
};
in { in {
devShells.${system}.default = pkgs.mkShell { devShells.${system}.default = pkgs.mkShell {
buildInputs = [ packages = [
zig zig_host
zls zls
zig_xtensa
pkgs.esptool
pkgs.espflash
]; ];
shellHook = '' shellHook = ''
echo "Entering Zig Master Environment" echo ">>> Zig Master (host): $(zig version)"
echo "Zig: $(zig version)" echo ">>> Zig Xtensa (esp32): $(zig-xtensa version 2>/dev/null || echo 'Executable ready')"
echo "ZLS: $(zls --version)"
export PATH=$HOME/.rustup/toolchains/esp/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin:$PATH
if command -v xtensa-esp32-elf-gcc >/dev/null; then
echo ">>> Xtensa GCC: $(xtensa-esp32-elf-gcc --version | head -n 1)"
fi
''; '';
}; };
}; };

BIN
test.o Normal file

Binary file not shown.

6
test.zig Normal file
View File

@@ -0,0 +1,6 @@
export fn main() void {
var i: u32 = 0;
while (i < 10) : (i += 1) {
asm volatile ("nop");
}
}