use fenix to build package, have runner script; nix run works now!
This commit is contained in:
39
flake.nix
39
flake.nix
@@ -1,32 +1,53 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||
rust-overlay = {
|
||||
fenix = {
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
url = "github:oxalica/rust-overlay";
|
||||
url = "github:nix-community/fenix";
|
||||
};
|
||||
naersk = {
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
url = "github:nix-community/naersk";
|
||||
};
|
||||
};
|
||||
outputs = {
|
||||
fenix,
|
||||
naersk,
|
||||
nixpkgs,
|
||||
rust-overlay,
|
||||
...
|
||||
}: let
|
||||
pkgs = import nixpkgs {
|
||||
system = "x86_64-linux";
|
||||
overlays = [(import rust-overlay)];
|
||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
toolchain = fenix.packages.x86_64-linux.fromToolchainFile {
|
||||
file = ./rust-toolchain.toml;
|
||||
sha256 = "sha256-zC8E38iDVJ1oPIzCqTk/Ujo9+9kx9dXq7wAwPMpkpg0=";
|
||||
};
|
||||
rust-bin = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
in {
|
||||
devShells.x86_64-linux.default = pkgs.mkShell {
|
||||
buildInputs = [
|
||||
pkgs.espflash
|
||||
pkgs.esp-generate
|
||||
pkgs.rust-analyzer
|
||||
rust-bin
|
||||
toolchain
|
||||
];
|
||||
shellHook = ''
|
||||
export RUSTUP_TOOLCHAIN=${rust-bin}
|
||||
export RUSTUP_TOOLCHAIN=${toolchain}
|
||||
'';
|
||||
};
|
||||
packages.x86_64-linux.default =
|
||||
(naersk.lib.x86_64-linux.override {
|
||||
cargo = toolchain;
|
||||
rustc = toolchain;
|
||||
}).buildPackage {
|
||||
src = ./.;
|
||||
# UPDATE .cargo/config.toml to reflect changes here in the runner
|
||||
postInstall = ''
|
||||
mv $out/bin/esp32c6-play $out/bin/.esp32c6-play
|
||||
cat<<EOF>$out/bin/esp32c6-play
|
||||
#!/usr/bin/bash
|
||||
${pkgs.lib.getExe pkgs.espflash} flash --monitor --chip esp32c6 $(echo $out)/bin/.esp32c6-play
|
||||
EOF
|
||||
chmod +x $out/bin/esp32c6-play
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user