# `Nerves.BuildAction`
[🔗](https://github.com/nerves-project/nerves/blob/v2.0.0-pre.2/lib/nerves/build_action.ex#L5)

Behaviour for all functionality in the Nerves firmware build process

Implementations should add `use Nerves.BuildAction` and only implement
the callbacks they use. Most actions will only implement one callback

# `image_creation`

```elixir
@callback image_creation(build_plan :: Nerves.BuildPlan.t(), opts :: keyword()) :: :ok
```

Callback for creating the firmware image

# `post_assemble_steps`

```elixir
@callback post_assemble_steps(
  build_plan :: Nerves.BuildPlan.t(),
  release :: Mix.Release.t(),
  opts :: keyword()
) :: Mix.Release.t()
```

Callback for processing the release right after assembly, but before rootfs creation

# `post_extract`

```elixir
@callback post_extract(build_plan :: Nerves.BuildPlan.t(), opts :: keyword()) ::
  Nerves.BuildPlan.t()
```

Callback for updating the build plan once artifacts are extracted

This can be used to look through artifact contents to adjust to plan. Since actions can be
added dynamically up to this callback, It's the only callback that can modify the build plan
that's guaranteed to be called. However, as it is past the extraction phase, no new files
can be downloaded.

# `post_image_creation`

```elixir
@callback post_image_creation(build_plan :: Nerves.BuildPlan.t(), opts :: keyword()) ::
  :ok
```

Callback for everything after firmware image creation

# `pre_assemble_steps`

```elixir
@callback pre_assemble_steps(
  build_plan :: Nerves.BuildPlan.t(),
  release :: Mix.Release.t(),
  opts :: keyword()
) :: Mix.Release.t()
```

Callback for anything that should run before the Mix release gets assembled

# `pre_download`

```elixir
@callback pre_download(build_plan :: Nerves.BuildPlan.t(), opts :: keyword()) ::
  Nerves.BuildPlan.t()
```

Callback for updating the build plan before any downloads occur

It's possible to add files to be downloaded to the plan in this callback.

This is the only callback that may not be called. If an action is registered in another
action's `post_extract/2` callback, then that's after the download phase and therefore
after `pre_download/2` functions are called.

# `pre_image_creation`

```elixir
@callback pre_image_creation(build_plan :: Nerves.BuildPlan.t(), opts :: keyword()) :: :ok
```

Callback for everything after rootfs creation and before making the firmware image

# `rootfs_creation_steps`

```elixir
@callback rootfs_creation_steps(
  build_plan :: Nerves.BuildPlan.t(),
  release :: Mix.Release.t(),
  opts :: keyword()
) :: Mix.Release.t()
```

Callback for creating the rootfs

---

*Consult [api-reference.md](api-reference.md) for complete listing*
