{ description = "build rust binaries"; outputs = { self, nixpkgs }: let supportedSystems = [ "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ]; forAllSystems = nixpkgs.lib.genAttrs supportedSystems; nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = [ self.overlays.default ]; }); in { overlays.default = final: prev: { rust-bin = let packageMeta = (final.lib.importTOML ./Cargo.toml).package; in final.rustPlatform.buildRustPackage { pname = packageMeta.name; inherit (packageMeta) version; src = self; cargoLock.lockFile = ./Cargo.lock; }; }; packages = forAllSystems (system: { inherit (nixpkgsFor."${system}") rust-bin; }); defaultPackage = forAllSystems (system: self.packages."${system}".rust-bin); devShell = forAllSystems (system: let pkgs = nixpkgsFor."${ system}"; in pkgs.mkShell { nativeBuildInputs = [ pkgs.rustc pkgs.cargo pkgs.rustfmt pkgs.rust-analyzer pkgs.cargo-watch ]; RUST_BACKTRACE = 1; } ); }; }