Packages
nerves_bootstrap
1.16.0
1.16.0
1.15.3
1.15.2
1.15.1
1.15.0
1.14.5
1.14.4
1.14.3
1.14.2
1.14.0
1.13.1
1.13.0
1.12.2
1.12.1
1.12.0
1.11.5
1.11.4
1.11.3
1.11.2
1.11.1
1.11.0
1.10.6
1.10.5
1.10.4
1.10.3
1.10.2
1.10.1
1.10.0
1.9.0
1.8.1
1.8.0
1.7.1
1.7.0
1.6.3
1.6.2
1.6.1
1.6.0
1.5.3
1.5.2
1.5.1
1.5.0
1.4.3
1.4.2
1.4.1
1.4.0
1.3.4
1.3.3
1.3.2
1.3.1
1.3.0
1.2.1
1.2.0
1.1.0
1.0.1
1.0.0
1.0.0-rc.4
1.0.0-rc.3
1.0.0-rc.2
1.0.0-rc.1
1.0.0-rc.0
0.8.2
0.8.1
0.8.0
0.7.1
0.7.0
0.6.4
0.6.3
Nerves mix integration bootstrap and new project generator
Current section
Files
Jump to
Current section
Files
lib/mix/tasks/nerves.bootstrap.ex
# SPDX-FileCopyrightText: 2022 Jon Carstens
# SPDX-FileCopyrightText: 2025 Frank Hunleth
#
# SPDX-License-Identifier: Apache-2.0
#
defmodule Mix.Tasks.Nerves.Bootstrap do
# Bootstrap Nerves tooling into the current Mix tooling
#
# The purpose of this task is to ensure the Nerves integration is compiled
# first and available to be injected into the Mix tooling since NervesBootstrap
# is available as an archive. (i.e. this is like having `:nerves` as a
# dependency of this archive even though archives do not allow traditional
# dependencies)
#
# It is not intended to be run manually
@moduledoc false
use Mix.Task
alias NervesBootstrap.UpdateChecker
@impl Mix.Task
def run(_args) do
UpdateChecker.check()
nerves_ver = nerves_version()
if is_nil(nerves_ver) do
Mix.raise("""
Your project is using Nerves bootstrap but doesn't depend on Nerves.
Please check the dependency section of your mix.exs.
""")
end
# Check that the Nerves version is new enough to support this
# version of Nerves Bootstrap.
#
# This version of Nerves Bootstrap fails to install when the
# Elixir version is less than 1.15, so we're guaranteed that
# version. That forces a constraint on what Nerves versions
# can be used. Here's a truncated list for convenience.
#
# | Nerves version | Min Elixir version | Max Elixir |
# |----------------|-----------------------------|------------|
# | 1.11.3 | 1.13 | 1.18 |
# | 1.12.0 | 1.15.1 | 1.19. |
# | 1.14.3 | 1.15.1 (inherited) | 1.20. |
if Version.match?(nerves_ver, "< 1.11.3") do
Mix.raise("""
You are using :nerves #{nerves_ver} which is incompatible with this version
of nerves_bootstrap and will result in compilation failures.
Please update to :nerves >= 1.11.3.
""")
end
if Mix.target() != :host and not Code.ensure_loaded?(Nerves.Env) do
# The tooling mix tasks are maintained in :nerves so we need to
# ensure it is compiled here first so the tasks are available.
# If the target is host, then this will be handled by the regular
# compilation process
_ = Mix.Tasks.Deps.Loadpaths.run(["--no-compile"])
Mix.Tasks.Deps.Compile.run(["nerves", "--include-children"])
end
# Do not call Nerves Bootstrap code from other modules here. The modules
# aren't available in Elixir 1.18 and earlier if `:nerves` doesn't pull
# them in.
end
defp nerves_version() do
if path = Mix.Project.deps_paths()[:nerves] do
Mix.Project.in_project(:nerves, path, fn _ -> Mix.Project.config()[:version] end)
end
catch
_, _ -> nil
end
end