No description
| .gitignore | initial commit | |
| esp-tool-env.nix | hopefully fixed dependency on libxml2 | |
| flake.lock | update flake | |
| flake.nix | made esp-idf-sys have esp-clang on riscv too | |
| README.md | add readme | |
esp-dev-flake
nix flake for doing rust dev with esp-idf
this entire thing seems to very hacky but ah well. should still work fine and if not, good luck!!
example
this is meant for use with rust projects created according to https://github.com/esp-rs/esp-idf-template. add a flake.nix like this to your project to make things work (maybe this repo should contain a flake template but that's work lmao).
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
esp-dev = {
url = "gitlab:999eagle/esp-dev-flake?host=git.catgirl.cloud";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = {
self,
nixpkgs,
rust-overlay,
flake-utils,
esp-dev,
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
(import rust-overlay)
# overlay is optional, really. the flake will extend pkgs internally with this overlay if necessary
esp-dev.overlays.default
];
};
rust-toolchain = pkgs.rust-bin.selectLatestNightlyWith (toolchain:
toolchain.default.override {
extensions = ["rust-src"];
});
in {
devShells.default = let
# this is the magic shell thing
shell = esp-dev.lib.mkDevShell {
inherit pkgs;
mcu = "esp32c6"; # of course change this to the specific mcu you're using
# set this to true for less hacky magic and running everything in a fhs env instead
# in that case, all cargo commands need to be run in that fhs env like `esp-idf-fhs -c 'cargo build'`
useFHS = false;
# esp-idf-sys currently doesn't support v5.3+, pick some supported version here
# the hash is just for the github:espressif/esp-idf repo at the specified version
idfVersion = "v5.2.2";
idfSrcHash = "sha256-+GNsDKEONcGubYqOYp1OhOwrGQZNg8KmKpbjT9Dp6tc=";
};
in
# this is useful to have nightly but tbh useless if rust nightly is configured some other way
# (same for the rust-overlay input, that's only required for this single thing)
shell.overrideAttrs (old: {
buildInputs = old.buildInputs ++ [rust-toolchain];
});
});
}
then run cargo build and things should just work! no fhs (okay several actually but only hidden away), no nix-ld, just some hacky magic. (oh also, the shell hook when not using a fhs env will delete .embuild/espressif/tools and replace that with a symlink to the nix store. don't store important data in there. which shouldn't be the case anyway.)