diff options
| author | andromeda <andromeda@lenovo> | 2026-04-06 17:21:54 +0200 |
|---|---|---|
| committer | andromeda <andromeda@lenovo> | 2026-04-06 17:21:54 +0200 |
| commit | ab2ae6d0e8911dcbd1477cbf199528f158f10140 (patch) | |
| tree | b96639698f0b870964a64a466ba275762fae5699 /flake.nix | |
| parent | a5d01131120f538292cbbf831006ae4db80b0f7a (diff) | |
use fenix to build package, have runner script; nix run works now!
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 39 |
1 files changed, 30 insertions, 9 deletions
@@ -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 + ''; + }; }; } |
