LoginSignup
4
2

Nerves関連のMixタスクを列挙する

Last updated at Posted at 2024-01-15

Nerves関連のMixタスクを列挙する方法を考えてみます。

Nerves(なあぶす)フレームワーク

Nerves(なあぶす)という IoT フレームワークを使うと、Elixirの強力な性能をラズパイ等の手のひらサイズのコンピュータの上で活用し、堅牢な IoT システムの構築が比較的簡単にできてしまいます。すごいです!

Nerves について詳しくは@takasehideki さんの「Slideshare:Elixir で IoT!?ナウでヤングで cool な Nerves フレームワーク」がわかりやすいです。

Mixタスク

Mix は、Elixir プロジェクトの作成、コンパイル、テスト、依存関係の管理などのタスクを提供するビルド ツールです。

Elixirプロジェクト内のMixタスクを列挙

mix help を実行しることにより、現在の環境で Mix が提供するすべての機能を確認することができます。

ここでは例として、nerves_livebook プロジェクト配下で試してみます。

terminal
cd path/to/nerves_livebook

mix help

行数を数えてみると65ありました。

terminal
mix help | wc -l

Nerves関連のMixタスクだけに絞り込む

単純にgrepしたらうまくNerves関連のMixタスクだけに絞り込めました!

terminal
mix help | grep 'mix' | grep -iE 'nerves|firmware'

結果は以下の通りです。

mix burn                    # Write a firmware image to an SDCard
mix compile.nerves_package  # Nerves Package Compiler
mix firmware                # Build a firmware bundle
mix firmware.burn           # Build a firmware bundle and write it to an SDCard
mix firmware.gen.gdb        # Generates a helper shell script for using gdb to analyze core dumps
mix firmware.gen.script     # Generates a shell script for pushing firmware updates
mix firmware.image          # Create a firmware image file
mix firmware.metadata       # Print out metadata for the current firmware
mix firmware.patch          # Build a firmware patch
mix firmware.unpack         # Unpack a firmware bundle for inspection
mix local.nerves            # Checks for updates to nerves_bootstrap
mix nerves.artifact         # Creates system and toolchain artifacts for Nerves
mix nerves.artifact.details # Prints Nerves artifact details
mix nerves.clean            # Cleans dependencies and build artifacts
mix nerves.info             # Prints Nerves information
mix nerves.new              # Creates a new Nerves application
mix nerves.system.shell     # Enter a shell to configure a custom system
mix nerves_key.device       # Simulate NervesKey device key creation
mix nerves_key.signer       # Manages NervesKey signing keys
mix upload                  # Uploads firmware to a Nerves device over SSH

Nerves関連のMixタスクは何処から来たのか

これが大変でした。Nervesプロジェクトは関心事ごとにパッケージ化されています。ですので、様々な機能が別々の場所で管理されているのです。

Our project is spread over many repositories in order to focus on a limited scope per repository.

This repository (nerves-project/nerves) is an entrance to Nerves and provides the core tooling and documentation.

私たちのプロジェクトは、リポジトリごとの限られた範囲に焦点を当てるために、多くのリポジトリに分散されています。

このリポジトリ (nerves-project/nerves) は Nerves への入り口であり、コアツールとドキュメントを提供します。

nerves パッケージの README.md に何がどこで管理されているか説明されています。

Nervesコミュニティーで質問したら、NervesコアチームのJonさんが即答してくださいました。

nerve s-mix-tasks-whereabouts 2024-01-14 at 21.15.45@2x.png

nerves パッケージ

mix burn                    # Write a firmware image to an SDCard
mix compile.nerves_package  # Nerves Package Compiler
mix firmware                # Build a firmware bundle
mix firmware.burn           # Build a firmware bundle and write it to an SDCard
mix firmware.gen.gdb        # Generates a helper shell script for using gdb to analyze core dumps
mix firmware.image          # Create a firmware image file
mix firmware.metadata       # Print out metadata for the current firmware
mix firmware.patch          # Build a firmware patch
mix firmware.unpack         # Unpack a firmware bundle for inspection
mix nerves.artifact         # Creates system and toolchain artifacts for Nerves
mix nerves.artifact.details # Prints Nerves artifact details
mix nerves.clean            # Cleans dependencies and build artifacts
mix nerves.info             # Prints Nerves information
mix nerves.system.shell     # Enter a shell to configure a custom system

nerves_bootstrap パッケージ

mix local.nerves            # Checks for updates to nerves_bootstrap
mix nerves.new              # Creates a new Nerves application

nerves_key パッケージ

mix nerves_key.device       # Simulate NervesKey device key creation
mix nerves_key.signer       # Manages NervesKey signing keys

ssh_subsystem_fwup パッケージ

mix firmware.gen.script     # Generates a shell script for pushing firmware updates
mix upload                  # Uploads firmware to a Nerves device over SSH

:tada::tada::tada:

最後に一言

mix nerves.infoについて知りました。迷った時にとりあえずこれをランすると何か手がかりが得られそうです。

実は基本的なコマンド以外はほとんど使ったことがありません。何かいいテクニックをお持ちの方は是非教えてください!

本記事は autoracex #269 の成果です。ありがとうございます。

toukon-qiita-macbook_20230912_091808.jpg

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2