1{
2 lib,
3 rustPlatform,
4 fetchFromGitHub,
5 pkg-config,
6 installShellFiles,
7 stdenv,
8 nix-update-script,
9 openssl,
10}:
11
12rustPlatform.buildRustPackage rec {
13 pname = "espflash";
14 version = "4.0.1";
15
16 src = fetchFromGitHub {
17 owner = "esp-rs";
18 repo = "espflash";
19 tag = "v${version}";
20 hash = "sha256-5G5oThlOmd3XG6JwdjYV6p7To51bdFpjlNMR2XJicHw";
21 };
22
23 nativeBuildInputs = [
24 pkg-config
25 installShellFiles
26 ];
27
28 # Needed to get openssl-sys to use pkg-config.
29 env.OPENSSL_NO_VENDOR = 1;
30
31 buildInputs = [ openssl ];
32
33 cargoHash = "sha256-dLX5FC5A3+Dr3Dex+YEAnDgNNOQYd2JgGujXWpnSNUo=";
34
35 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
36 installShellCompletion --cmd espflash \
37 --bash <($out/bin/espflash completions bash) \
38 --zsh <($out/bin/espflash completions zsh) \
39 --fish <($out/bin/espflash completions fish)
40 '';
41
42 passthru.updateScript = nix-update-script { };
43
44 meta = {
45 description = "Serial flasher utility for Espressif SoCs and modules based on esptool.py";
46 homepage = "https://github.com/esp-rs/espflash";
47 changelog = "https://github.com/esp-rs/espflash/blob/v${version}/CHANGELOG.md";
48 mainProgram = "espflash";
49 license = with lib.licenses; [
50 mit # or
51 asl20
52 ];
53 maintainers = with lib.maintainers; [ matthiasbeyer ];
54 };
55}