Runtime helpers for Application-bearing NBPR packages.
The generated NBPR.<Name>.Application module calls into here to decide
whether to load kernel modules and how. Keeping these as plain functions
in a stable module means: the codegen stays trivial, behaviour can be
changed centrally without rebuilding every package, and tests can target
the helpers directly.
Summary
Functions
Loads kernel module name for the package otp_app, and raises on failure.
Runs modprobe <name> and raises on failure.
Returns true when the current process is running on a Nerves target.
Functions
Loads kernel module name for the package otp_app, and raises on failure.
Prefers the package's own priv-shipped .ko: stock Nerves systems index
only the modules the system was built with in /lib/modules/<ver>/modules.dep
(the rootfs is read-only, so depmod can't re-index on device), which makes
an out-of-tree module invisible to modprobe-by-name. Instead the .ko is
located under the package's priv dir and loaded by path with insmod from
:nbpr_kmod, after modprobe-ing its in-tree dependencies (read from the
module's depends: field via modinfo).
Falls back to plain modprobe <name> when the package doesn't ship the
.ko itself — i.e. the module is already indexed on the rootfs.
Idempotent: modules already loaded (per /sys/module/) are skipped.
@spec modprobe!(String.t()) :: :ok
Runs modprobe <name> and raises on failure.
modprobe is idempotent (re-loading an already-loaded module is fine) and
resolves its own dependency graph from modules.dep, so transitive kernel
modules don't need to be loaded explicitly. Only works for modules the
system's modules.dep indexes — for a package-shipped out-of-tree .ko,
see load_kernel_module!/2.
@spec on_nerves_target?() :: boolean()
Returns true when the current process is running on a Nerves target.
Every Nerves system ships ID=nerves in /etc/os-release. Used to gate
kernel-module loading so mix test and dev workflows on macOS/Linux are
unaffected by package Applications.