{ description = "A Nix-flake-based Rust ESP IDF development environment"; inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; outputs = { self, nixpkgs }: let supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; nixpkgs-esp-dev = builtins.fetchGit { url = "https://github.com/mirrexagon/nixpkgs-esp-dev.git"; # Optionally pin to a specific commit of `nixpkgs-esp-dev`. rev = "f37890edc9b327fcbc6d48c4cf174e65e4c0d148"; }; forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: let pkgs = import nixpkgs { inherit system; overlays = [ (import "${nixpkgs-esp-dev}/overlay.nix") ]; }; libxml2Shared = pkgs.libxml2.overrideAttrs (old: { configureFlags = (old.configureFlags or [ ]) ++ [ "--enable-shared" ]; # cursed patch necessary to fix linking errors postInstall = '' ln -sf libxml2.so $out/lib/libxml2.so.2 ${old.postInstall or ""} ''; }); in f { inherit pkgs libxml2Shared; } ); in { devShells = forEachSupportedSystem ({ pkgs, libxml2Shared }: { default = pkgs.mkShell { packages = with pkgs; [ esp-idf-full espflash cargo-espflash espup llvmPackages_16.libclang # Explicitly add libclang llvmPackages_16.clang # Include clang/headers pkg-config # Often needed for bindgen to find clang glibc.dev # Needed for C headers libxml2Shared.out ldproxy ]; env = { # Set LD_LIBRARY_PATH so libstdc++.so.6 zlib and libxml2 can be found LD_LIBRARY_PATH = with pkgs; pkgs.lib.makeLibraryPath [ gcc.cc.lib zlib libxml2Shared.out ]; }; }; }); }; }