Skip to main content
Documentation

Build an Image with Yocto

Add Nexigon Agent to a Yocto image with the meta-nexigon layers and connect a device built from it to Nexigon Hub. This guide assumes that you already build images with Yocto. The examples configure the build with Kas; the same variables work in local.conf.

Choose the Layers

meta-nexigon contains three layers:

  • meta-nexigon-core installs and configures Nexigon Agent. Every image needs it.
  • meta-nexigon-rugix adds system updates with Rugix Ctrl.
  • meta-nexigon-rauc adds system updates with RAUC.

Use at most one of the update layers. The main branch supports Yocto 6.0 (wrynose). The scarthgap branch for Yocto 5.0 does not include the system update integration of Nexigon Agent that the update guides use.

Add the layers to your Kas configuration, for example with Rugix Ctrl:

kas/nexigon.yaml
repos:
  meta-nexigon:
    url: https://github.com/nexigon/meta-nexigon.git
    branch: main
    layers:
      meta-nexigon-core:
      meta-nexigon-rugix:

Configure Nexigon Agent

The nexigon-agent-conf recipe writes the agent’s configuration from BitBake variables. Installing it also installs Nexigon Agent and its systemd service:

conf/local.conf
IMAGE_INSTALL:append = " nexigon-agent-conf nexigon-power nexigon-systemd"

The optional nexigon-power and nexigon-systemd packages add device commands that reboot the device and manage systemd services. They require commands to be enabled, as shown under Features.

Credentials

Choose how devices obtain their credentials:

  • Static credentials: Set NEXIGON_HUB_URL and NEXIGON_TOKEN to your Nexigon Hub URL and a deployment token. Every device built from the image joins the project on its first boot.
  • Provisioning: Set NEXIGON_PROVISIONING = "1" and leave the other two variables empty. Each device then waits for a one-time provisioning token, as Provision Devices describes. The image contains no credentials.

Device Fingerprint

NEXIGON_DEVICE_FINGERPRINT selects how the agent identifies the device. The build fails without it:

ValueFingerprint Source
machine-id/etc/machine-id. Suits systems with a single root filesystem and Rugix, which keeps the machine ID across updates.
random-uuidA UUID generated on first boot and stored at NEXIGON_DEVICE_FINGERPRINT_FILE. Use it with RAUC or another A/B scheme where /etc differs between slots.
A script pathYour own fingerprint script, for example one that reads a board serial number.

Persistent State

The agent’s TLS certificate, private key, and saved credentials must survive system updates. meta-nexigon-rugix persists them with Rugix Ctrl’s state management. For RAUC and other A/B systems, place them on a shared data partition:

conf/local.conf
NEXIGON_AGENT_SSL_DIR = "/data/nexigon/agent/ssl"
NEXIGON_AGENT_DATA_DIR = "/data/nexigon/agent"
NEXIGON_DEVICE_FINGERPRINT_FILE = "/data/nexigon/device-fingerprint-uuid"

The agent’s service then waits until these directories are mounted.

Features

Enable the features that your devices need:

conf/local.conf
NEXIGON_COMMANDS_ENABLED = "1"
NEXIGON_TERMINAL_ENABLED = "1"
NEXIGON_TERMINAL_USER = "root"
NEXIGON_AGENT_EXTRA_CONF = "[forwarding]\nenabled = true\nallowed-tcp-ports = [22]"

NEXIGON_AGENT_EXTRA_CONF appends settings to the agent’s configuration, with \n separating lines. This example permits SSH forwarding to port 22.

Build and Connect

Build the image, flash it, and boot the device. With static credentials, the device appears under Devices in Nexigon. With provisioning, pair it as Provision Devices describes.

If the device does not appear, inspect journalctl -u nexigon-agent on the device. The example Kas configurations build complete images for QEMU and Raspberry Pi with Rugix Ctrl or RAUC.

Next Steps

Set Up System Updates configures the update layers and the release workflow. Access Devices Remotely connects to the device.