View Source Nerves.Env (nerves v1.11.2)

Contains package info for Nerves dependencies

The Nerves Env is used to load information from dependencies that contain a nerves.exs config file in the root of the dependency path. Nerves loads this config because it needs access to information about Nerves compile time dependencies before any code is compiled.

Summary

Functions

Export environment variables used by Elixir, Erlang, C/C++ and other tools so that they use Nerves toolchain parameters and not the host's.

Re evaluates the mix file under a different target.

Cleans the artifacts for the package build_runners of all specified packages.

The location for storing global nerves data.

Disable the Nerves Env compilers

The download location for artifact downloads.

Enable the Nerves Env compilers

Check if the env compilers are disabled

Ensures that an application which contains a Nerves package config has been loaded into the environment agent.

The path to the firmware file

Returns the architecture for the host system.

Returns the os for the host system.

The path to where firmware build files are stored This can be overridden in a Mix project by setting the :images_path key.

Check if the Nerves.Env is loaded

Gets a package by app name.

Lists all Nerves packages loaded in the Nerves environment.

Lists packages by package type.

Starts the Nerves environment agent and loads package information. If the Nerves.Env is already started, the function returns {:error, {:already_started, pid}} with the pid of that process

Stop the Nerves environment agent.

Helper function for returning the system type package

Helper function for returning the system_platform type package

Helper function for returning the toolchain type package

Helper function for returning the toolchain_platform type package

Functions

@spec bootstrap() :: :ok

Export environment variables used by Elixir, Erlang, C/C++ and other tools so that they use Nerves toolchain parameters and not the host's.

For a comprehensive list of environment variables, see the documentation for the package defining system_platform.

@spec change_target(String.t()) :: :ok

Re evaluates the mix file under a different target.

This allows you to start in one target, like host, but then switch to a different target.

@spec clean([Nerves.Package.t()]) :: :ok

Cleans the artifacts for the package build_runners of all specified packages.

@spec data_dir() :: path :: String.t()

The location for storing global nerves data.

The base directory is normally set by the XDG_DATA_HOME environment variable (i.e. $XDG_DATA_HOME/nerves/). If XDG_DATA_HOME is unset, the user's home directory is used (i.e. $HOME/.nerves).

@spec disable() :: :ok

Disable the Nerves Env compilers

@spec download_dir() :: path :: String.t()

The download location for artifact downloads.

Placing an artifact tar in this location will bypass the need for it to be downloaded.

@spec enable() :: :ok

Enable the Nerves Env compilers

@spec enabled?() :: boolean()

Check if the env compilers are disabled

Link to this function

ensure_loaded(app, path \\ nil)

View Source
@spec ensure_loaded(app :: atom(), path :: String.t() | nil) ::
  {:ok, Nerves.Package.t()} | {:error, term()}

Ensures that an application which contains a Nerves package config has been loaded into the environment agent.

Options

  • app - The atom of the app to load
  • path - Optional path for the app
Link to this function

export_package_env(package)

View Source
@spec export_package_env(Nerves.Package.t()) :: :ok
Link to this function

firmware_path(config \\ mix_config())

View Source
@spec firmware_path(keyword()) :: String.t()

The path to the firmware file

@spec host_arch() :: String.t()

Returns the architecture for the host system.

Example return values

"x86_64" "arm"

@spec host_os() :: String.t()

Returns the os for the host system.

Example return values

"win" "linux" "darwin"

Link to this function

images_path(config \\ mix_config())

View Source
@spec images_path(keyword()) :: String.t()

The path to where firmware build files are stored This can be overridden in a Mix project by setting the :images_path key.

images_path: "/some/other/location"

Defaults to (build_path)/nerves/images

@spec loaded?() :: boolean()

Check if the Nerves.Env is loaded

@spec package(name :: atom()) :: Nerves.Package.t() | nil

Gets a package by app name.

@spec packages() :: [Nerves.Package.t()]

Lists all Nerves packages loaded in the Nerves environment.

Link to this function

packages_by_type(type, packages \\ nil)

View Source
@spec packages_by_type(type :: atom(), [Nerves.Package.t()] | nil) :: [
  Nerves.Package.t()
]

Lists packages by package type.

@spec start() :: Agent.on_start()

Starts the Nerves environment agent and loads package information. If the Nerves.Env is already started, the function returns {:error, {:already_started, pid}} with the pid of that process

@spec stop() :: :ok | :not_running

Stop the Nerves environment agent.

@spec system() :: Nerves.Package.t() | nil

Helper function for returning the system type package

@spec system_platform() :: module()

Helper function for returning the system_platform type package

@spec toolchain() :: Nerves.Package.t() | nil

Helper function for returning the toolchain type package

@spec toolchain_platform() :: atom()

Helper function for returning the toolchain_platform type package