diff --git a/flake.nix b/flake.nix index 6e6ac13..47e2647 100644 --- a/flake.nix +++ b/flake.nix @@ -13,13 +13,28 @@ # Optionally pin to a specific commit of `nixpkgs-esp-dev`. rev = "f37890edc9b327fcbc6d48c4cf174e65e4c0d148"; }; - forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { - pkgs = import nixpkgs { inherit system; overlays = [ (import "${nixpkgs-esp-dev}/overlay.nix") ]; }; - }); + + 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 }: { + ({ pkgs, libxml2Shared }: { default = pkgs.mkShell { packages = with pkgs; [ @@ -27,7 +42,23 @@ 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 + ]; + }; }; }); };